Version: 9.16.0
ComponentInstance.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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 "ComponentInstance.hxx"
21#include "Container.hxx"
22
23#include <iostream>
24#include <sstream>
25
26//#define _DEVDEBUG_
27#include "YacsTrace.hxx"
28
29using namespace YACS::ENGINE;
30using namespace std;
31
46const char ComponentInstance::KIND[]="";
47int ComponentInstance::_total = 0;
48
49
50const char ComponentInstance::NULL_FILE_REPR[]="No repr specified for ComponentInstance";
51
52bool ComponentInstance::setContainer(Container *cont)
53{
54 if (cont == _container) return false;
55
56 if(cont)
57 cont->checkCapabilityToDealWith(this);
58 if(_container)
60 _container=cont;
61 if(_container)
63 return true;
64}
65
66ComponentInstance::ComponentInstance(const std::string& name):_compoName(name),_isAttachedOnCloning(false),_container(0),_anonymous(true)
67{
68 _numId = _total++;
69 stringstream instName;
70 instName << _compoName << "_" << _numId;
71 _instanceName = instName.str();
72}
73
74ComponentInstance::ComponentInstance(const ComponentInstance& other):_compoName(other._compoName),
75 _container(0),
76 _isAttachedOnCloning(other._isAttachedOnCloning),
77 _anonymous(true)
78{
79 _numId = _total++;
80 stringstream instName;
81 instName << _compoName << "_" << _numId;
82 _instanceName = instName.str();
83 if(other._container)
85}
86
88{
89 if(_container)
91}
92
97{
99}
100
103{
104 return NULL_FILE_REPR;
105}
106
111{
113}
114
116{
118}
119
121
127{
128 return KIND;
129}
130
132{
133 return KIND;
134}
135
137{
138}
Base class for all component instances.
ComponentInstance(const std::string &name)
virtual std::string getKindForNode() const
virtual void shutdown(int level)
std::string _instanceName
WARNING : _InstanceName has a strong semantic. It discriminates ComponentInstance instances each othe...
virtual void attachOnCloning() const
std::string _compoName
WARNING : _compoName identify only the component type.
virtual std::string getFileRepr() const
For dump in file.
virtual std::string getKind() const
Return the component kind.
virtual Container * clone() const =0
WARNING ! clone behaviour MUST be in coherence with what is returned by isAttachedOnCloning() method
virtual void checkCapabilityToDealWith(const ComponentInstance *inst) const =0