Salome HOME
Merge branch V7_3_1_BR
[modules/yacs.git] / src / engine / DeploymentTree.hxx
1 // Copyright (C) 2006-2014  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __DEPLOYMENTTREE_HXX__
21 #define __DEPLOYMENTTREE_HXX__
22
23 #include "YACSlibEngineExport.hxx"
24
25 #include <vector>
26
27 namespace YACS
28 {
29   namespace ENGINE
30   {
31     class Task;
32     class Container;
33     class Scheduler;
34     class ComponentInstance;
35
36     class YACSLIBENGINE_EXPORT DeploymentTreeOnHeap
37     {
38     public:
39       DeploymentTreeOnHeap();
40       ~DeploymentTreeOnHeap();
41       bool decrRef();
42       void incrRef() const;
43       //
44       unsigned char appendTask(Task *task, Scheduler *cloner);
45       //
46       unsigned getNumberOfCTDefContainer() const;
47       unsigned getNumberOfRTODefContainer() const;
48       unsigned getNumberOfCTDefComponentInstances() const;
49       unsigned getNumberOfRTODefComponentInstances() const;
50       //
51       std::vector<Container *> getAllContainers() const;
52       std::vector<Container *> getAllCTDefContainers() const;
53       std::vector<Container *> getAllRTODefContainers() const;
54       std::vector<Task *> getTasksLinkedToComponent(ComponentInstance *comp) const;
55       std::vector<Task *> getTasksLinkedToContainer(Container *cont) const;
56       std::vector<ComponentInstance *> getComponentsLinkedToContainer(Container *cont) const;
57       //
58       bool presenceOfDefaultContainer() const;
59       std::vector<Task *> getFreeDeployableTasks() const;
60     private:
61       static bool isConsistentTaskRegardingShCompInst(std::vector< std::pair<Task *, Scheduler * > >& tasksSharingSameCompInst, Scheduler *cloner);
62     private:
63       mutable int _cnt;
64       std::vector< std::pair<Task *,Scheduler *> > _freePlacableTasks;
65       //! internal representation of tree. Scheduler is the duplicating Task, \b if it exists, on runtime unpredictable times on compil-time
66       std::vector< std::vector< std::vector< std::pair<Task *, Scheduler * > > > > _tree;
67     };
68
69     class YACSLIBENGINE_EXPORT DeploymentTree
70     {
71     public:
72       DeploymentTree();
73       ~DeploymentTree();
74       DeploymentTree(const DeploymentTree& other);
75       const DeploymentTree &operator=(const DeploymentTree& other);
76       unsigned char appendTask(Task *task, Scheduler *cloner);
77       //
78       unsigned getNumberOfCTDefContainer() const;
79       unsigned getNumberOfRTODefContainer() const;
80       unsigned getNumberOfCTDefComponentInstances() const;
81       unsigned getNumberOfRTODefComponentInstances() const;
82       //
83       bool presenceOfDefaultContainer() const;
84       std::vector<Container *> getAllContainers() const;
85       std::vector<Container *> getAllCTDefContainers() const;
86       std::vector<Container *> getAllRTODefContainers() const;
87       std::vector<Task *> getTasksLinkedToComponent(ComponentInstance *comp) const;
88       std::vector<Task *> getTasksLinkedToContainer(Container *cont) const;
89       std::vector<ComponentInstance *> getComponentsLinkedToContainer(Container *cont) const;
90       //
91       bool isNull() const;
92       std::vector<Task *> getFreeDeployableTasks() const;
93     public:
94       //possible return of appendTask method.
95       static const unsigned char NULL_TASK = 3;
96       static const unsigned char APPEND_OK = 0;
97       static const unsigned char NULL_TREE = 199;
98       static const unsigned char ALREADY_IN_TREE = 1;
99       static const unsigned char NOT_DEPLOYABLE_TASK = 2;
100       static const unsigned char DEPLOYABLE_BUT_NOT_SPECIFIED = 5;
101       static const unsigned char DUP_TASK_NOT_COMPATIBLE_WITH_EXISTING_TREE = 4;
102     private:
103       DeploymentTreeOnHeap *_treeHandle;
104     };
105   }
106 }
107
108 #endif