Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / DeploymentTree.hxx
1 #ifndef __DEPLOYMENTTREE_HXX__
2 #define __DEPLOYMENTTREE_HXX__
3
4 #include <vector>
5
6 namespace YACS
7 {
8   namespace ENGINE
9   {
10     class Task;
11     class Container;
12     class Scheduler;
13     class ComponentInstance;
14
15     class DeploymentTreeOnHeap
16     {
17     public:
18       DeploymentTreeOnHeap();
19       ~DeploymentTreeOnHeap();
20       bool decrRef();
21       void incrRef() const;
22       //
23       unsigned char appendTask(Task *task, Scheduler *cloner);
24       //
25       unsigned getNumberOfCTDefContainer() const;
26       unsigned getNumberOfRTODefContainer() const;
27       unsigned getNumberOfCTDefComponentInstances() const;
28       unsigned getNumberOfRTODefComponentInstances() const;
29       //
30       std::vector<Container *> getAllContainers() const;
31       std::vector<Container *> getAllCTDefContainers() const;
32       std::vector<Container *> getAllRTODefContainers() const;
33       std::vector<Task *> getTasksLinkedToComponent(ComponentInstance *comp) const;
34       std::vector<ComponentInstance *> getComponentsLinkedToContainer(Container *cont) const;
35       //
36       bool presenceOfDefaultContainer() const;
37       std::vector<Task *> getFreeDeployableTasks() const;
38     private:
39       static bool isConsistentTaskRegardingShCompInst(std::vector< std::pair<Task *, Scheduler * > >& tasksSharingSameCompInst, Scheduler *cloner);
40     private:
41       mutable int _cnt;
42       std::vector< std::pair<Task *,Scheduler *> > _freePlacableTasks;
43       //! internal representation of tree. Scheduler is the duplicating Task, \b if it exists, on runtime unpredictable times on compil-time
44       std::vector< std::vector< std::vector< std::pair<Task *, Scheduler * > > > > _tree;
45     };
46
47     class DeploymentTree
48     {
49     public:
50       DeploymentTree();
51       ~DeploymentTree();
52       DeploymentTree(const DeploymentTree& other);
53       const DeploymentTree &operator=(const DeploymentTree& other);
54       unsigned char appendTask(Task *task, Scheduler *cloner);
55       //
56       unsigned getNumberOfCTDefContainer() const;
57       unsigned getNumberOfRTODefContainer() const;
58       unsigned getNumberOfCTDefComponentInstances() const;
59       unsigned getNumberOfRTODefComponentInstances() const;
60       //
61       bool presenceOfDefaultContainer() const;
62       std::vector<Container *> getAllContainers() const;
63       std::vector<Container *> getAllCTDefContainers() const;
64       std::vector<Container *> getAllRTODefContainers() const;
65       std::vector<Task *> getTasksLinkedToComponent(ComponentInstance *comp) const;
66       std::vector<ComponentInstance *> getComponentsLinkedToContainer(Container *cont) const;
67       //
68       bool isNull() const;
69       std::vector<Task *> getFreeDeployableTasks() const;
70     public:
71       //possible return of appendTask method.
72       static const unsigned char NULL_TASK = 3;
73       static const unsigned char APPEND_OK = 0;
74       static const unsigned char NULL_TREE = 199;
75       static const unsigned char ALREADY_IN_TREE = 1;
76       static const unsigned char NOT_DEPLOYABLE_TASK = 2;
77       static const unsigned char DEPLOYABLE_BUT_NOT_SPECIFIED = 5;
78       static const unsigned char DUP_TASK_NOT_COMPATIBLE_WITH_EXISTING_TREE = 4;
79     private:
80       DeploymentTreeOnHeap *_treeHandle;
81     };
82   }
83 }
84
85 #endif