Version: 8.3.0
YACS::ENGINE::CppNode Class Reference

Class for C++ Nodes (in process component) More...

#include <CppNode.hxx>

Inheritance diagram for YACS::ENGINE::CppNode:
Collaboration diagram for YACS::ENGINE::CppNode:

Public Member Functions

 CppNode (const CppNode &other, ComposedNode *father)
 
 CppNode (const std::string &name)
 
virtual void load ()
 Load the component associated to the node. More...
 
virtual void execute ()
 
virtual ServiceNodecreateNode (const std::string &name)
 
CppNodecloneNode (const std::string &name)
 Create a new node of same type with a given name. More...
 
void setCode (const std::string &componentName, const std::string &service)
 
void setFunc (MYRUN fonc)
 
std::string getKind () const
 Return the service node kind. More...
 
- Public Member Functions inherited from YACS::ENGINE::ServiceNode
virtual bool isDeployable () const
 By definition of ServiceNode class. More...
 
virtual void setComponent (ComponentInstance *compo) throw (Exception)
 Associate an existing component instance to this service node AND check the consistency regarding the deployment from root node point of view. More...
 
virtual ComponentInstancegetComponent ()
 Return the associated component instance. More...
 
virtual const ComponentInstancegetComponent () const
 
virtual ContainergetContainer ()
 Return the associated container. More...
 
virtual void setRef (const std::string &ref)
 Associate a new component instance to this service node. More...
 
virtual std::string getRef ()
 
virtual void setMethod (const std::string &method)
 
virtual std::string getMethod ()
 
virtual ~ServiceNode ()
 
virtual void accept (Visitor *visitor)
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::ElementaryNode
virtual ~ElementaryNode ()
 
void exUpdateState ()
 Update the node state. More...
 
void init (bool start=true)
 
YACS::StatesForNode getState () const
 
void getReadyTasks (std::vector< Task * > &tasks)
 
void edRemovePort (Port *port) throw (Exception)
 
std::list< ElementaryNode * > getRecursiveConstituents () const
 
std::list< ProgressWeightgetProgressWeight () const
 Get the progress weight for all elementary nodes. More...
 
NodegetChildByName (const std::string &name) const throw (Exception)
 
virtual void checkBasicConsistency () const throw (Exception)
 
ComposedNodegetDynClonerIfExists (const ComposedNode *levelToStop) const
 
int getNumberOfInputPorts () const
 
int getNumberOfOutputPorts () const
 
std::string getInPortName (const InPort *) const throw (Exception)
 
std::string getOutPortName (const OutPort *) const throw (Exception)
 
InputPortgetInputPort (const std::string &name) const throw (Exception)
 
OutputPortgetOutputPort (const std::string &name) const throw (Exception)
 
std::list< InputPort * > getSetOfInputPort () const
 
std::list< OutputPort * > getSetOfOutputPort () const
 
std::list< InputPort * > getLocalInputPorts () const
 
std::list< OutputPort * > getLocalOutputPorts () const
 
std::set< OutPort * > getAllOutPortsLeavingCurrentScope () const
 
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope () const
 
virtual std::vector< std::pair
< OutPort *, InPort * > > 
getSetOfLinksLeavingCurrentScope () const
 
virtual std::vector< std::pair
< InPort *, OutPort * > > 
getSetOfLinksComingInCurrentScope () const
 
std::list< InputDataStreamPort * > getSetOfInputDataStreamPort () const
 
std::list< OutputDataStreamPort * > getSetOfOutputDataStreamPort () const
 
InputDataStreamPortgetInputDataStreamPort (const std::string &name) const throw (Exception)
 
OutputDataStreamPortgetOutputDataStreamPort (const std::string &name) const throw (Exception)
 
virtual InputPortcreateInputPort (const std::string &inputPortName, TypeCode *type)
 
virtual OutputPortcreateOutputPort (const std::string &outputPortName, TypeCode *type)
 
virtual InputDataStreamPortcreateInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type)
 
virtual OutputDataStreamPortcreateOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type)
 
virtual InputPortedAddInputPort (const std::string &inputPortName, TypeCode *type) throw (Exception)
 
virtual OutputPortedAddOutputPort (const std::string &outputPortName, TypeCode *type) throw (Exception)
 
virtual InputDataStreamPortedAddInputDataStreamPort (const std::string &inputPortDSName, TypeCode *type) throw (Exception)
 
virtual OutputDataStreamPortedAddOutputDataStreamPort (const std::string &outputPortDSName, TypeCode *type) throw (Exception)
 
virtual void edOrderInputPorts (const std::list< InputPort * > &ports)
 
virtual void edOrderOutputPorts (const std::list< OutputPort * > &ports)
 
virtual void edUpdateState ()
 update the status of the node More...
 
virtual void ensureLoading ()
 Put this node into TOLOAD state when possible. More...
 
int getMaxLevelOfParallelism () const
 
void begin ()
 
bool isReady ()
 
void finished ()
 
void aborted ()
 
void loaded ()
 Notify this node that it is loaded. More...
 
void connected ()
 Notify this node that it is connected. More...
 
virtual std::string getErrorDetails ()
 Give a description of error when node status is ERROR. More...
 
virtual void initService ()
 
virtual void connectService ()
 
virtual void disconnectService ()
 
virtual void getCoupledTasks (std::set< Task * > &coupledSet)
 Calls getCoupledNodes for Task interface. More...
 
virtual void getCoupledNodes (std::set< Task * > &coupledSet)
 Put all nodes that are coupled to this node in coupledSet. More...
 
virtual void addDatastreamPortToInitMultiService (const std::string &port_name, int number)
 
template<class PORT >
void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts) throw (Exception)
 
template<class PORT >
bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Public Member Functions inherited from YACS::ENGINE::Node
virtual ~Node ()
 
virtual void shutdown (int level)
 Stop all pending activities of the node. More...
 
virtual void resetState (int level)
 Reset the node state depending on the parameter level. More...
 
Nodeclone (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
NodecloneWithoutCompAndContDeepCpy (ComposedNode *father, bool editionOnly=true) const
 This method MUST NEVER BE VIRTUAL More...
 
void setState (YACS::StatesForNode theState)
 Sets the given state for node. More...
 
virtual YACS::StatesForNode getEffectiveState () const
 Return the node state in the context of its father. More...
 
virtual YACS::StatesForNode getEffectiveState (const Node *) const
 Return the effective state of a node in the context of this one (its father) More...
 
std::string getColorState (YACS::StatesForNode state) const
 Return the color associated to a state. More...
 
InGategetInGate ()
 
OutGategetOutGate ()
 
const std::string & getName () const
 
void setName (const std::string &name)
 Change the name of the node. More...
 
ComposedNodegetFather () const
 
const std::string getId () const
 
bool exIsControlReady () const
 
std::list< Node * > getOutNodes () const
 
virtual void writeDot (std::ostream &os) const
 Dump to the input stream a dot representation of the node. More...
 
virtual void exFailedState ()
 Notify this node that its execution has failed. More...
 
virtual void exDisabledState ()
 Notify this node that it has been disabled. More...
 
std::list< InPort * > getSetOfInPort () const
 
std::list< OutPort * > getSetOfOutPort () const
 
virtual std::set< InputPort * > edGetSetOfUnitializedInputPort () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
virtual bool edAreAllInputPortInitialized () const
 Becomes deprecated soon. Replaced by ComposedNode::CheckConsistency. More...
 
InPortgetInPort (const std::string &name) const throw (Exception)
 
InPropertyPortgetInPropertyPort () const throw (Exception)
 
virtual OutPortgetOutPort (const std::string &name) const throw (Exception)
 
std::list< ComposedNode * > getAllAscendanceOf (ComposedNode *levelToStop=0) const
 
bool operator> (const Node &other) const
 
bool operator< (const Node &other) const
 
std::string getImplementation () const
 
virtual ComposedNodegetRootNode () const throw (Exception)
 
virtual void setProperty (const std::string &name, const std::string &value)
 
virtual std::string getProperty (const std::string &name)
 
std::map< std::string,
std::string > 
getProperties ()
 
std::map< std::string,
std::string > 
getPropertyMap ()
 
virtual void setProperties (std::map< std::string, std::string > properties)
 
virtual ProcgetProc ()
 
virtual const ProcgetProc () const
 
std::string getQualifiedName () const
 same as Node::getName() in most cases, but differs for children of switch More...
 
int getNumId ()
 return node instance identifiant, unique for each node instance More...
 
std::vector< std::pair
< std::string, int > > 
getDPLScopeInfo (ComposedNode *gfn)
 
virtual void applyDPLScope (ComposedNode *gfn)
 
virtual void sendEvent (const std::string &event)
 emit notification to all observers registered with the dispatcher More...
 
virtual void sendEvent2 (const std::string &event, void *something)
 emit notification to all observers registered with the dispatcher More...
 
virtual std::string getErrorDetails () const
 
virtual void setErrorDetails (const std::string &error)
 
virtual void modified ()
 Sets Node in modified state and its father if it exists. More...
 
virtual int isModified ()
 
virtual int isValid ()
 indicates if the node is valid (returns 1) or not (returns 0) More...
 
virtual std::string getErrorReport ()
 returns a string that contains an error report if the node is in error More...
 
virtual std::string getContainerLog ()
 returns a string that contains the name of the container log file if it exists More...
 
virtual void cleanNodes ()
 Clean the node in case of not clean exit. More...
 
- Public Member Functions inherited from YACS::ENGINE::Task
virtual ~Task ()
 

Static Public Attributes

static const char IMPL_NAME [] ="Cpp"
 
static const char KIND [] ="Cpp"
 
- Static Public Attributes inherited from YACS::ENGINE::ServiceNode
static const char KIND [] =""
 

Protected Member Functions

NodesimpleClone (ComposedNode *father, bool editionOnly) const
 Clone the node : must also clone the component instance ? More...
 
- Protected Member Functions inherited from YACS::ENGINE::ServiceNode
 ServiceNode (const std::string &name)
 
 ServiceNode (const ServiceNode &other, ComposedNode *father)
 
void performDuplicationOfPlacement (const Node &other)
 performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. More...
 
void performShallowDuplicationOfPlacement (const Node &other)
 performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. More...
 
- Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
 ElementaryNode (const std::string &name)
 
 ElementaryNode (const ElementaryNode &other, ComposedNode *father)
 
void initCommonPartWithoutStateManagement (bool start)
 
virtual void createMultiDatastreamPorts ()
 
void edDisconnectAllLinksWithMe ()
 
bool areAllInputPortsValid () const
 
template<class PORT >
PORT * getPort (const std::string &name, const std::list< PORT * > &setOfPorts) const throw (Exception)
 
template<class PORT , class ENUMTYPE >
PORT * edAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type) throw (Exception)
 
template<class PORT , class ENUMTYPE >
bool edCheckAddPort (const std::string &portName, std::list< PORT * > &setOfPorts, ENUMTYPE type) throw (Exception)
 
- Protected Member Functions inherited from YACS::ENGINE::Node
 Node (const std::string &name)
 
 Node (const Node &other, ComposedNode *father)
 
virtual void exForwardFailed ()
 
virtual void exForwardFinished ()
 

Protected Attributes

std::string _componentName
 
MYRUN _run
 
- Protected Attributes inherited from YACS::ENGINE::ServiceNode
ComponentInstance_component
 
std::string _method
 
std::string _ref
 
- Protected Attributes inherited from YACS::ENGINE::ElementaryNode
std::list< InputPort * > _setOfInputPort
 
std::list< OutputPort * > _setOfOutputPort
 
std::list< InputDataStreamPort * > _setOfInputDataStreamPort
 
std::list< OutputDataStreamPort * > _setOfOutputDataStreamPort
 
bool _createDatastreamPorts
 
bool _multi_port_node
 
- Protected Attributes inherited from YACS::ENGINE::Node
InGate _inGate
 
OutGate _outGate
 
InPropertyPort_inPropertyPort
 
std::string _name
 
ComposedNode_father
 
YACS::StatesForNode _state
 
int _modified
 
std::string _errorDetails
 
int _numId
 
std::string _implementation
 
std::map< std::string,
std::string > 
_propertyMap
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::Node
static std::string getStateName (YACS::StatesForNode state)
 Return the name of a state. More...
 
- Public Attributes inherited from YACS::ENGINE::Node
YACS::Colour _colour
 
- Static Protected Member Functions inherited from YACS::ENGINE::ElementaryNode
template<class PORT >
static void edRemovePortTypedFromSet (PORT *port, std::list< PORT * > &setOfPorts) throw (Exception)
 
template<class PORT >
static bool isPortNameAlreadyExist (const std::string &portName, const std::list< PORT * > &setOfPorts)
 
- Static Protected Attributes inherited from YACS::ENGINE::Node
static const char SEP_CHAR_IN_PORT [] ="."
 
static int _total = 0
 

Detailed Description

Class for C++ Nodes (in process component)

local C++ implementation - single process

Definition at line 46 of file CppNode.hxx.

Constructor & Destructor Documentation

CppNode::CppNode ( const CppNode other,
ComposedNode father 
)

Definition at line 41 of file CppNode.cxx.

References YACS::ENGINE::Node::_implementation, DEBTRACE, and IMPL_NAME.

Referenced by cloneNode(), createNode(), and simpleClone().

41  :ServiceNode(other,father),
42  _run(other._run),
44 {
45  DEBTRACE("CppNode::CppNode");
47 }
CppNode::CppNode ( const std::string &  name)

Definition at line 49 of file CppNode.cxx.

References YACS::ENGINE::Node::_implementation, and IMPL_NAME.

49  : ServiceNode(name), _run(NULL)
50 {
52 }

Member Function Documentation

CppNode * CppNode::cloneNode ( const std::string &  name)

Create a new node of same type with a given name.

Definition at line 149 of file CppNode.cxx.

References YACS::ENGINE::ServiceNode::_component, _componentName, YACS::ENGINE::ServiceNode::_method, _run, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, CppNode(), DEBTRACE, YACS::ENGINE::ElementaryNode::edAddInputPort(), YACS::ENGINE::ElementaryNode::edAddOutputPort(), YACS::ENGINE::DataPort::edGetType(), YACS::ENGINE::DataPort::getName(), YACS::ENGINE::TypeCode::kind(), gui.Appli::n, p, setCode(), and setFunc().

150 {
151  DEBTRACE("CppNode::cloneNode");
152  CppNode* n=new CppNode(name);
153 
154  if (_run)
155  n->setFunc(_run);
156 
157  if (_component)
159 
160  list<InputPort *>::iterator iter;
161  for(iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
162  {
163  InputCppPort *p=(InputCppPort *)*iter;
164  DEBTRACE("port name: " << p->getName());
165  DEBTRACE("port kind: " << p->edGetType()->kind());
166  n->edAddInputPort(p->getName(),p->edGetType());
167  }
168  list<OutputPort *>::iterator iter2;
169  for(iter2 = _setOfOutputPort.begin(); iter2 != _setOfOutputPort.end(); iter2++)
170  {
171  OutputCppPort *p=(OutputCppPort *)*iter2;
172  DEBTRACE("port name: " << p->getName());
173  DEBTRACE("port kind: " << p->edGetType()->kind());
174  n->edAddOutputPort(p->getName(),p->edGetType());
175  }
176  return n;
177 }
ServiceNode * CppNode::createNode ( const std::string &  name)
virtual

Implements YACS::ENGINE::ServiceNode.

Definition at line 135 of file CppNode.cxx.

References YACS::ENGINE::ServiceNode::_component, CppNode(), and YACS::ENGINE::ServiceNode::setComponent().

136 {
137  CppNode* node= new CppNode(name);
138  node->setComponent(_component);
139  return node;
140 }
void CppNode::execute ( )
virtual

Implements YACS::ENGINE::Task.

Definition at line 84 of file CppNode.cxx.

References YACS::ENGINE::ServiceNode::_component, YACS::ENGINE::ServiceNode::_method, _run, YACS::ENGINE::ElementaryNode::_setOfInputPort, YACS::ENGINE::ElementaryNode::_setOfOutputPort, DEBTRACE, YACS::ENGINE::RefCounter::decrRef(), YACS::ENGINE::InputCppPort::getCppObj(), p, YACS::ENGINE::OutputCppPort::put(), and YACS::ENGINE::CppComponent::run().

85 {
86  std::list<InputPort *>::iterator iter1;
87  int nIn, nOut, it;
88 
89  nIn = _setOfInputPort.size();
90  nOut = _setOfOutputPort.size();
91 
92  Any ** In = new Any * [nIn], ** Out = new Any * [nOut];
93 
94  try
95  {
96 
97  for(iter1 = _setOfInputPort.begin(), it = 0; iter1 != _setOfInputPort.end();
98  iter1++, it++)
99  {
100  InputCppPort *p = dynamic_cast<InputCppPort *> (*iter1);
101  In[it] = p->getCppObj();
102  }
103 
104  if (_component)
105  {
106  CppComponent * _componentC = dynamic_cast<CppComponent *>(_component);
107  if (!_componentC)
108  throw YACS::Exception("CppNode::execute : bad type of component");
109  _componentC->run(_method.c_str(), nIn, nOut, In, Out);
110  }
111  else if (_run)
112  _run(nIn, nOut, In, Out);
113 
114  //output parameters
115  std::list<OutputPort *>::iterator iter2;
116  for(iter2 = _setOfOutputPort.begin(), it=0; iter2 != _setOfOutputPort.end(); iter2++, it++)
117  {
118  OutputCppPort *p = dynamic_cast<OutputCppPort *> (*iter2);
119  p->put(Out[it]);
120  //decref it, we don't need it more
121  Out[it]->decrRef();
122  DEBTRACE("ref count: " << Out[it]->getRefCnt());
123  }
124  }
125  catch (YACS::Exception & e) {
126  delete [] In;
127  delete [] Out;
128  throw e;
129  }
130 
131  delete [] In;
132  delete [] Out;
133 }
std::string YACS::ENGINE::CppNode::getKind ( ) const
inlinevirtual

Return the service node kind.

A runtime can provide several implementations of a service node. Each implementation has a different kind. A ComponentInstance can be associated to a ServiceNode with the same kind.

Reimplemented from YACS::ENGINE::ServiceNode.

Definition at line 63 of file CppNode.hxx.

References KIND.

63 { return CppNode::KIND; }
void CppNode::load ( )
virtual

Load the component associated to the node.

Reimplemented from YACS::ENGINE::ServiceNode.

Definition at line 74 of file CppNode.cxx.

References YACS::ENGINE::ServiceNode::_component, _componentName, _run, YACS::ENGINE::ServiceNode::load(), and YACS::ENGINE::ServiceNode::setRef().

75 {
76  if (_run) return;
77 
78  if (!_component) {
80  }
82 }
void CppNode::setCode ( const std::string &  componentName,
const std::string &  service 
)

Definition at line 54 of file CppNode.cxx.

References _componentName, YACS::ENGINE::ServiceNode::_method, and _run.

Referenced by cloneNode().

55 {
56  _method = method;
57  _componentName = componentName;
58  _run = NULL;
59 }
void CppNode::setFunc ( MYRUN  fonc)

Definition at line 61 of file CppNode.cxx.

References YACS::ENGINE::ServiceNode::_component, _componentName, YACS::ENGINE::ServiceNode::_method, _run, and YACS::ENGINE::RefCounter::decrRef().

Referenced by cloneNode().

61  {
62 
63  if (_component)
64  {
66  _component = NULL;
67  _componentName = "";
68  _method = "";
69  _component = NULL;
70  }
71  _run = fonc;
72 }
Node * CppNode::simpleClone ( ComposedNode father,
bool  editionOnly 
) const
protectedvirtual

Clone the node : must also clone the component instance ?

Implements YACS::ENGINE::Node.

Definition at line 143 of file CppNode.cxx.

References CppNode().

144 {
145  return new CppNode(*this,father);
146 }

Member Data Documentation

std::string YACS::ENGINE::CppNode::_componentName
protected

Definition at line 65 of file CppNode.hxx.

Referenced by cloneNode(), load(), setCode(), and setFunc().

MYRUN YACS::ENGINE::CppNode::_run
protected

Definition at line 66 of file CppNode.hxx.

Referenced by cloneNode(), execute(), load(), setCode(), and setFunc().

const char CppNode::IMPL_NAME ="Cpp"
static

Definition at line 61 of file CppNode.hxx.

Referenced by CppNode().

const char CppNode::KIND ="Cpp"
static

The documentation for this class was generated from the following files: