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