Salome HOME
Copyright update: 2016
[modules/yacs.git] / src / engine / Test / ComponentInstanceTest.cxx
1 // Copyright (C) 2006-2016  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 #include "ComponentInstanceTest.hxx"
21 #include "ToyNode.hxx"
22
23 using namespace std;
24 using namespace YACS::ENGINE;
25
26 ComponentInstanceTest1::ComponentInstanceTest1(const ComponentInstanceTest1& other):ComponentInstance(other),_loaded(false)
27 {
28 }
29
30 ComponentInstanceTest1::ComponentInstanceTest1(const std::string& name):ComponentInstance(name),_loaded(false)
31 {
32 }
33
34 void ComponentInstanceTest1::load(Task *askingNode)
35 {
36   _loaded=true;
37 }
38
39 void ComponentInstanceTest1::unload(Task *askingNode)
40 {
41   _loaded=false;
42 }
43
44 bool ComponentInstanceTest1::isLoaded(Task *askingNode) const
45 {
46   return _loaded;
47 }
48
49 std::string ComponentInstanceTest1::getKind() const
50 {
51   return ToyNode1S::KIND;
52 }
53
54 std::string ComponentInstanceTest1::getKindForNode() const
55 {
56   return ToyNode1S::KIND;
57 }
58
59 ServiceNode* ComponentInstanceTest1::createNode(const std::string& name)
60 {
61   ToyNode1S* node=new ToyNode1S(name);
62   node->setComponent(this);
63   return node;
64 }
65
66 ComponentInstance *ComponentInstanceTest1::clone() const
67 {
68   if(isAttachedOnCloning())
69     {
70       incrRef();
71       return (ComponentInstance *) this;
72     }
73   else
74     return new ComponentInstanceTest1(*this);
75 }
76
77 ComponentInstance *ComponentInstanceTest1::cloneAlways() const
78 {
79   return new ComponentInstanceTest1(*this);
80 }
81
82 ComponentInstanceTest2::ComponentInstanceTest2(const ComponentInstanceTest2& other):ComponentInstance(other),_loaded(false)
83 {
84 }
85
86 ComponentInstanceTest2::ComponentInstanceTest2(const std::string& name):ComponentInstance(name),_loaded(false)
87 {
88 }
89
90 void ComponentInstanceTest2::load(Task *askingNode)
91 {
92   _loaded=true;
93 }
94
95 void ComponentInstanceTest2::unload(Task *askingNode)
96 {
97   _loaded=false;
98 }
99
100 bool ComponentInstanceTest2::isLoaded(Task *askingNode) const
101 {
102   return _loaded;
103 }
104
105 std::string ComponentInstanceTest2::getKind() const
106 {
107   return ToyNode2S::KIND;
108 }
109
110 std::string ComponentInstanceTest2::getKindForNode() const
111 {
112   return ToyNode2S::KIND;
113 }
114
115 ServiceNode* ComponentInstanceTest2::createNode(const std::string& name)
116 {
117   ToyNode2S* node=new ToyNode2S(name);
118   node->setComponent(this);
119   return node;
120 }
121
122 ComponentInstance *ComponentInstanceTest2::clone() const
123 {
124   if(isAttachedOnCloning())
125     {
126       incrRef();
127       return (ComponentInstance *) this;
128     }
129   else
130     return new ComponentInstanceTest2(*this);
131 }
132
133 ComponentInstance *ComponentInstanceTest2::cloneAlways() const
134 {
135   return new ComponentInstanceTest2(*this);
136 }