Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / engine / ComponentInstance.cxx
1 #include "ComponentInstance.hxx"
2 #include "Container.hxx"
3
4 #include <iostream>
5
6 //#define _DEVDEBUG_
7 #include "YacsTrace.hxx"
8
9 using namespace YACS::ENGINE;
10 using namespace std;
11
12 const char ComponentInstance::KIND[]="";
13
14 const char ComponentInstance::NULL_FILE_REPR[]="No repr specified for ComponentInstance";
15
16 void ComponentInstance::setContainer(Container *cont)
17 {
18   if (cont == _container) return;
19   
20   if(cont)
21     cont->checkCapabilityToDealWith(this);
22   if(_container)
23     _container->decrRef();
24   _container=cont;
25   if(_container)
26     _container->incrRef();
27 }
28
29 ComponentInstance::ComponentInstance(const std::string& name):_name(name),_isAttachedOnCloning(false),_container(0)
30 {
31 }
32
33 ComponentInstance::ComponentInstance(const ComponentInstance& other):_name(other._name),
34                                                                      _container(0),
35                                                                      _isAttachedOnCloning(other._isAttachedOnCloning)
36 {
37   if(other._container)
38     _container=other._container->clone();
39 }
40
41 ComponentInstance::~ComponentInstance()
42 {
43   if(_container)
44     _container->decrRef();
45 }
46
47 /*!
48  * By calling this method the current container 'this' is not destined to be deeply copied on clone call.
49  */
50 void ComponentInstance::attachOnCloning() const
51 {
52   _isAttachedOnCloning=true;
53 }
54
55 std::string ComponentInstance::getFileRepr() const
56 {
57   return NULL_FILE_REPR;
58 }
59
60 /*!
61  * By calling this method the current container 'this' will be deeply copied on clone call.
62  */
63 void ComponentInstance::dettachOnCloning() const
64 {
65   _isAttachedOnCloning=false;
66 }
67
68 bool ComponentInstance::isAttachedOnCloning() const
69 {
70   return _isAttachedOnCloning;
71 }
72
73 string ComponentInstance::getKind() const
74 {
75   return KIND;
76 }