1 #include "ServiceNode.hxx"
3 #include "ComponentInstance.hxx"
4 #include "ComposedNode.hxx"
10 #include "YacsTrace.hxx"
12 using namespace YACS::ENGINE;
14 const char ServiceNode::KIND[]="";
16 std::string ServiceNode::getKind() const
21 ServiceNode::ServiceNode(const std::string& name):ElementaryNode(name),_component(0)
25 ServiceNode::ServiceNode(const ServiceNode& other, ComposedNode *father)
26 :ElementaryNode(other,father),_method(other._method),_component(0)
30 void ServiceNode::performDuplicationOfPlacement(const Node& other)
32 const ServiceNode &otherC=*(dynamic_cast<const ServiceNode *>(&other));
33 //if other has no component don't clone: this will not have one
35 _component=otherC._component->clone();
38 ServiceNode::~ServiceNode()
41 _component->decrRef();
44 //! Load the component associated to the node
45 void ServiceNode::load()
49 if(!_component->isLoaded())
57 _errorDetails=e.what();
64 std::string what("ServiceNode::load : a load operation requested on ServiceNode called \"");
65 what+=_name; what+="\" with no component specified.";
67 throw Exception(what);
71 void ServiceNode::accept(Visitor *visitor)
73 visitor->visitServiceNode(this);
76 //! Return the associated component instance
77 ComponentInstance *ServiceNode::getComponent()
82 //! By definition of ServiceNode class.
83 bool ServiceNode::isDeployable() const
88 //! Associate an existing component instance to this service node \b AND check the consistency regarding the deployment from root node point of view.
89 void ServiceNode::setComponent(ComponentInstance* compo) throw(Exception)
92 if(compo->getKind() != this->getKind())
95 std::string what("ServiceNode::setComponent : component instance kind not allowed ");
96 throw Exception(what);
100 //The node is already associated with a component instance
101 _component->decrRef();
102 //Don't forget to unassociate
110 getRootNode()->checkDeploymentTree(false);
117 _component->incrRef();
119 //assert(_component);
122 //! Associate a new component instance to this service node
124 * A new component instance with type name ref is created (from runtime
125 * factory createComponentInstance) and associated to the node.
128 void ServiceNode::setRef(const std::string& ref)
133 //The node is already associated with a component instance
134 _component->decrRef();
135 //Don't forget to unassociate
137 _component= getRuntime()->createComponentInstance(ref,getKind());
141 std::string ServiceNode::getRef()