diff Core/JobsEngine/JobsRegistry.h @ 2673:8e0bc055d18c jobs

JobsRegistry::IObserver
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 Jun 2018 16:29:33 +0200
parents eaf10085ffa1
children 251614c2edac
line wrap: on
line diff
--- a/Core/JobsEngine/JobsRegistry.h	Mon Jun 11 15:57:25 2018 +0200
+++ b/Core/JobsEngine/JobsRegistry.h	Mon Jun 11 16:29:33 2018 +0200
@@ -55,6 +55,21 @@
   // This class handles the state machine of the jobs engine
   class JobsRegistry : public boost::noncopyable
   {
+  public:
+    class IObserver : public boost::noncopyable
+    {
+    public:
+      virtual ~IObserver()
+      {
+      }
+
+      virtual void SignalJobSubmitted(const std::string& jobId) = 0;
+
+      virtual void SignalJobSuccess(const std::string& jobId) = 0;
+
+      virtual void SignalJobFailure(const std::string& jobId) = 0;
+    };
+    
   private:
     class JobHandler;
 
@@ -81,6 +96,8 @@
     boost::condition_variable  someJobComplete_;
     size_t                     maxCompletedJobs_;
 
+    IObserver*                 observer_;
+
 
 #ifndef NDEBUG
     bool IsPendingJob(const JobHandler& job) const;
@@ -118,7 +135,8 @@
     
   public:
     JobsRegistry() :
-      maxCompletedJobs_(10)
+      maxCompletedJobs_(10),
+      observer_(NULL)
     {
     }
 
@@ -162,6 +180,10 @@
     bool GetState(JobState& state,
                   const std::string& id);
 
+    void SetObserver(IObserver& observer);
+
+    void ResetObserver();
+
     class RunningJob : public boost::noncopyable
     {
     private: