Salome HOME
Work in progress : workload manager engine test ok
[modules/yacs.git] / src / workloadmanager / Task.hxx
index bdada0b900931a0535380c39a2c0b00232ce0d48..3dd7c93d08e67b4617b939a97316f726c5c26b76 100644 (file)
@@ -25,24 +25,38 @@ namespace WorkloadManager
 {
   struct ContainerType
   {
-    float neededCores; // needed by WorkloadManager
-    // parameters for client use, not needed by WorkloadManager:
+    float neededCores = 0.0; // needed by WorkloadManager
+    // parameters for client use, used by WorkloadManager to distinguish objects
     std::string name;
-    int id;
+    int id = 0;
+    bool operator==(const ContainerType& other)const
+    { return id == other.id && name == other.name;}
+    bool operator<(const ContainerType& other)const
+    {
+      return (id < other.id) ||
+             (id == other.id && name < other.name);
+    }
   };
   
   struct Resource
   {
     unsigned int nbCores; // needed by WorkloadManager
-    // parameters for client use, not needed by WorkloadManager:
+    // parameters for client use, used by WorkloadManager to distinguish objects
     std::string name;
     int id;
+    bool operator==(const Resource& other)const
+    { return id == other.id && name == other.name;}
+    bool operator<(const Resource& other)const
+    {
+      return (id < other.id) ||
+             (id == other.id && name < other.name);
+    }
   };
   
   struct Container
   {
-    const ContainerType* type;
-    const Resource* resource;
+    ContainerType type;
+    Resource resource;
     unsigned int index; // worker index on the resource for this type
   };
 
@@ -52,7 +66,8 @@ namespace WorkloadManager
   class Task
   {
   public:
-    virtual const ContainerType* type()const =0;
+    virtual ~Task(){};
+    virtual const ContainerType& type()const =0;
     virtual void run(const Container& c)=0;
   };
 }