]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/DeploymentTree.hxx
Salome HOME
09e5ad700004d539bf86b666ba2e1b1f052a57b0
[modules/yacs.git] / src / engine / DeploymentTree.hxx
1 //  Copyright (C) 2006-2008  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.
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 #ifndef __DEPLOYMENTTREE_HXX__
20 #define __DEPLOYMENTTREE_HXX__
21
22 #include <vector>
23
24 namespace YACS
25 {
26   namespace ENGINE
27   {
28     class Task;
29     class Container;
30     class Scheduler;
31     class ComponentInstance;
32
33     class DeploymentTreeOnHeap
34     {
35     public:
36       DeploymentTreeOnHeap();
37       ~DeploymentTreeOnHeap();
38       bool decrRef();
39       void incrRef() const;
40       //
41       unsigned char appendTask(Task *task, Scheduler *cloner);
42       //
43       unsigned getNumberOfCTDefContainer() const;
44       unsigned getNumberOfRTODefContainer() const;
45       unsigned getNumberOfCTDefComponentInstances() const;
46       unsigned getNumberOfRTODefComponentInstances() const;
47       //
48       std::vector<Container *> getAllContainers() const;
49       std::vector<Container *> getAllCTDefContainers() const;
50       std::vector<Container *> getAllRTODefContainers() const;
51       std::vector<Task *> getTasksLinkedToComponent(ComponentInstance *comp) const;
52       std::vector<ComponentInstance *> getComponentsLinkedToContainer(Container *cont) const;
53       //
54       bool presenceOfDefaultContainer() const;
55       std::vector<Task *> getFreeDeployableTasks() const;
56     private:
57       static bool isConsistentTaskRegardingShCompInst(std::vector< std::pair<Task *, Scheduler * > >& tasksSharingSameCompInst, Scheduler *cloner);
58     private:
59       mutable int _cnt;
60       std::vector< std::pair<Task *,Scheduler *> > _freePlacableTasks;
61       //! internal representation of tree. Scheduler is the duplicating Task, \b if it exists, on runtime unpredictable times on compil-time
62       std::vector< std::vector< std::vector< std::pair<Task *, Scheduler * > > > > _tree;
63     };
64
65     class DeploymentTree
66     {
67     public:
68       DeploymentTree();
69       ~DeploymentTree();
70       DeploymentTree(const DeploymentTree& other);
71       const DeploymentTree &operator=(const DeploymentTree& other);
72       unsigned char appendTask(Task *task, Scheduler *cloner);
73       //
74       unsigned getNumberOfCTDefContainer() const;
75       unsigned getNumberOfRTODefContainer() const;
76       unsigned getNumberOfCTDefComponentInstances() const;
77       unsigned getNumberOfRTODefComponentInstances() const;
78       //
79       bool presenceOfDefaultContainer() const;
80       std::vector<Container *> getAllContainers() const;
81       std::vector<Container *> getAllCTDefContainers() const;
82       std::vector<Container *> getAllRTODefContainers() const;
83       std::vector<Task *> getTasksLinkedToComponent(ComponentInstance *comp) const;
84       std::vector<ComponentInstance *> getComponentsLinkedToContainer(Container *cont) const;
85       //
86       bool isNull() const;
87       std::vector<Task *> getFreeDeployableTasks() const;
88     public:
89       //possible return of appendTask method.
90       static const unsigned char NULL_TASK = 3;
91       static const unsigned char APPEND_OK = 0;
92       static const unsigned char NULL_TREE = 199;
93       static const unsigned char ALREADY_IN_TREE = 1;
94       static const unsigned char NOT_DEPLOYABLE_TASK = 2;
95       static const unsigned char DEPLOYABLE_BUT_NOT_SPECIFIED = 5;
96       static const unsigned char DUP_TASK_NOT_COMPATIBLE_WITH_EXISTING_TREE = 4;
97     private:
98       DeploymentTreeOnHeap *_treeHandle;
99     };
100   }
101 }
102
103 #endif