1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "ComponentInstance.hxx"
20 #include "Container.hxx"
26 #include "YacsTrace.hxx"
28 using namespace YACS::ENGINE;
31 const char ComponentInstance::KIND[]="";
32 int ComponentInstance::_total = 0;
35 const char ComponentInstance::NULL_FILE_REPR[]="No repr specified for ComponentInstance";
37 void ComponentInstance::setContainer(Container *cont)
39 if (cont == _container) return;
42 cont->checkCapabilityToDealWith(this);
44 _container->decrRef();
47 _container->incrRef();
50 ComponentInstance::ComponentInstance(const std::string& name):_compoName(name),_isAttachedOnCloning(false),_container(0)
53 stringstream instName;
54 instName << _compoName << "_" << _numId;
55 _instanceName = instName.str();
58 ComponentInstance::ComponentInstance(const ComponentInstance& other):_compoName(other._compoName),
60 _isAttachedOnCloning(other._isAttachedOnCloning)
63 stringstream instName;
64 instName << _compoName << "_" << _numId;
65 _instanceName = instName.str();
67 _container=other._container->clone();
70 ComponentInstance::~ComponentInstance()
73 _container->decrRef();
77 * By calling this method the current container 'this' is not destined to be deeply copied on clone call.
79 void ComponentInstance::attachOnCloning() const
81 _isAttachedOnCloning=true;
84 std::string ComponentInstance::getFileRepr() const
86 return NULL_FILE_REPR;
90 * By calling this method the current container 'this' will be deeply copied on clone call.
92 void ComponentInstance::dettachOnCloning() const
94 _isAttachedOnCloning=false;
97 bool ComponentInstance::isAttachedOnCloning() const
99 return _isAttachedOnCloning;
102 string ComponentInstance::getKind() const