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