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 "ServiceNode.hxx"
20 #include "Visitor.hxx"
21 #include "ComponentInstance.hxx"
22 #include "ComposedNode.hxx"
23 #include "Runtime.hxx"
28 #include "YacsTrace.hxx"
30 using namespace YACS::ENGINE;
32 const char ServiceNode::KIND[]="";
34 std::string ServiceNode::getKind() const
39 ServiceNode::ServiceNode(const std::string& name):ElementaryNode(name),_component(0)
43 ServiceNode::ServiceNode(const ServiceNode& other, ComposedNode *father)
44 :ElementaryNode(other,father),_method(other._method),_component(0)
48 void ServiceNode::performDuplicationOfPlacement(const Node& other)
50 const ServiceNode &otherC=*(dynamic_cast<const ServiceNode *>(&other));
51 //if other has no component don't clone: this will not have one
53 _component=otherC._component->clone();
56 ServiceNode::~ServiceNode()
59 _component->decrRef();
62 //! Load the component associated to the node
63 void ServiceNode::load()
67 if(!_component->isLoaded())
75 _errorDetails=e.what();
82 std::string what("ServiceNode::load : a load operation requested on ServiceNode called \"");
83 what+=_name; what+="\" with no component specified.";
85 throw Exception(what);
89 void ServiceNode::accept(Visitor *visitor)
91 visitor->visitServiceNode(this);
94 //! Return the associated component instance
95 ComponentInstance *ServiceNode::getComponent()
100 //! By definition of ServiceNode class.
101 bool ServiceNode::isDeployable() const
106 //! Associate an existing component instance to this service node \b AND check the consistency regarding the deployment from root node point of view.
107 void ServiceNode::setComponent(ComponentInstance* compo) throw(Exception)
110 if(compo->getKind() != this->getKind())
113 std::string what("ServiceNode::setComponent : component instance kind not allowed ");
114 throw Exception(what);
118 //The node is already associated with a component instance
119 _component->decrRef();
120 //Don't forget to unassociate
128 getRootNode()->checkDeploymentTree(false);
135 _component->incrRef();
137 //assert(_component);
140 //! Associate a new component instance to this service node
142 * A new component instance with type name ref is created (from runtime
143 * factory createComponentInstance) and associated to the node.
146 void ServiceNode::setRef(const std::string& ref)
151 //The node is already associated with a component instance
152 _component->decrRef();
153 //Don't forget to unassociate
155 _component= getRuntime()->createComponentInstance(ref,getKind());
159 std::string ServiceNode::getRef()