]> SALOME platform Git repositories - modules/yacs.git/blob - src/engine/Test/ContainerTest.cxx
Salome HOME
Win32 compilation.
[modules/yacs.git] / src / engine / Test / ContainerTest.cxx
1 // Copyright (C) 2006-2013  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
20 #include "ContainerTest.hxx"
21 #include "ComponentInstance.hxx"
22 #include "ToyNode.hxx"
23 #include <sstream>
24
25 using namespace std;
26 using namespace YACS::ENGINE;
27
28 unsigned ContainerTest::_counter = 0;
29
30 const char ContainerTest::SUPPORTED_COMP_KIND[] = "TESTKIND1";
31
32 unsigned ContainerTest2::_counter = 0;
33
34 const char ContainerTest2::SUPPORTED_COMP_KIND[] = "TESTKIND2";
35
36 ContainerTest::ContainerTest():_alreadyStarted(false),_myCounter(_counter++)
37 {
38 }
39
40 std::string ContainerTest::getPlacementInfo() const
41 {
42   ostringstream stream;
43   stream << "Cont#_" << _myCounter;
44   return stream.str();
45 }
46
47 bool ContainerTest::isAlreadyStarted(const ComponentInstance *inst) const
48 {
49   return _alreadyStarted;
50 }
51
52 void ContainerTest::start(const ComponentInstance *inst) throw(YACS::Exception)
53 {
54   if(_alreadyStarted)
55     throw Exception("ContainerTest already started !!!!");
56   _alreadyStarted=true;
57 }
58
59 Container *ContainerTest::clone() const
60 {
61   if(_isAttachedOnCloning)
62     {
63       incrRef();
64       return (Container *) this;
65     }
66   else
67     return new ContainerTest;
68 }
69
70 void ContainerTest::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
71 {
72   if(inst->getKind()!=SUPPORTED_COMP_KIND)
73     throw Exception("ContainerTest not compatible with this type of instance.");
74 }
75
76 void ContainerTest::initAllContainers()
77 {
78   _counter=0;
79 }
80
81 ContainerTest2::ContainerTest2():_alreadyStarted(false),_myCounter(_counter++)
82 {
83 }
84
85 bool ContainerTest2::isAlreadyStarted(const ComponentInstance *inst) const
86 {
87   return _alreadyStarted;
88 }
89
90 void ContainerTest2::start(const ComponentInstance *inst) throw(YACS::Exception)
91 {
92   if(_alreadyStarted)
93     throw Exception("ContainerTest already started !!!!");
94   _alreadyStarted=true;
95 }
96
97 Container *ContainerTest2::clone() const
98 {
99   if(_isAttachedOnCloning)
100     {
101       incrRef();
102       return (Container *) this;
103     }
104   else
105     return new ContainerTest2;
106 }
107
108 void ContainerTest2::initAllContainers()
109 {
110   _counter=0;
111 }
112
113 void ContainerTest2::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
114 {
115   if(inst->getKind()!=SUPPORTED_COMP_KIND)
116     throw Exception("ContainerTest not compatible with this type of instance.");
117 }