Version: 9.15.0
YACS::ENGINE::AnyInputPort Class Reference

#include <AnyInputPort.hxx>

Inheritance diagram for YACS::ENGINE::AnyInputPort:
Collaboration diagram for YACS::ENGINE::AnyInputPort:

Public Member Functions

 AnyInputPort (const std::string &name, Node *node, TypeCode *type, bool canBeNull=false)
 
 AnyInputPort (const AnyInputPort &other, Node *newHelder)
 
virtual ~AnyInputPort ()
 
void exSaveInit ()
 Save the current data value for further reinitialization of the port. More...
 
void exRestoreInit ()
 Restore the saved data value to current data value. More...
 
AnygetValue () const
 
int getIntValue () const
 
void releaseData () override
 
void put (Any *data)
 
void * get () const
 
virtual std::string getAsString ()
 returns port value as a string that can be used in a GUI for example More...
 
virtual bool isEmpty ()
 
void put (const void *data)
 
InputPortclone (Node *newHelder) const
 
std::string dump ()
 
virtual std::string typeName ()
 
- Public Member Functions inherited from YACS::ENGINE::InputPort
virtual ~InputPort ()
 
std::string getNameOfTypeOfCurrentInstance () const
 
virtual InputPortgetPublicRepresentant ()
 returns the final physical port behind 'this'. More...
 
virtual bool isIntermediate () const
 
virtual bool edIsManuallyInitialized () const
 Specifies if this port has been manually set by the call of InputPort::edInit. More...
 
bool edIsInitialized () const
 soon deprecated More...
 
template<class T >
void edInit (T value)
 
void edInit (Any *value)
 
void edInit (const std::string &impl, const void *value)
 Initialize the port with an object (value) coming from a world with implementation impl. More...
 
virtual void edRemoveManInit ()
 Removes eventually previous manual initialisation. More...
 
virtual void checkBasicConsistency () const
 Check basically that this port has one chance to be specified on time. It's a necessary condition not sufficient at all. More...
 
virtual void exInit (bool start)
 
virtual std::string getHumanRepr ()
 
virtual void setStringRef (std::string strRef)
 
bool canBeNull () const
 
- Public Member Functions inherited from YACS::ENGINE::DataFlowPort
TypeOfChannel getTypeOfChannel () const
 returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM. More...
 
virtual ~DataFlowPort ()
 
virtual std::string valToStr ()
 Gives a string representation of the data, for user interfaces. More...
 
virtual void valFromStr (std::string valstr)
 Allows to set data from a string representation used in user interface. More...
 
- Public Member Functions inherited from YACS::ENGINE::DataPort
TypeCodeedGetType () const
 
void edSetType (TypeCode *type)
 
std::string getName () const
 
void setName (std::string theName)
 
bool isDifferentTypeOf (const DataPort *other) const
 
- Public Member Functions inherited from YACS::ENGINE::Port
virtual ~Port ()
 
NodegetNode () const
 
int getNumId () const
 
void modified ()
 
- Public Member Functions inherited from YACS::ENGINE::InPort
virtual int edGetNumberOfLinks () const
 Returns number of physical backlinks NOT number of user backlinks. More...
 
virtual std::set< OutPort * > edSetOutPort () const
 Returns physical backlinks NOT user backlinks. More...
 
bool canSafelySqueezeMemory () const
 
bool isBackLinked () const
 
virtual ~InPort ()
 

Protected Member Functions

void releaseDataUnsafe ()
 
- Protected Member Functions inherited from YACS::ENGINE::InputPort
 InputPort (const InputPort &other, Node *newHelder)
 
 InputPort (const std::string &name, Node *node, TypeCode *type, bool canBeNull=false)
 
void releaseDataUnsafe ()
 
- Protected Member Functions inherited from YACS::ENGINE::DataFlowPort
 DataFlowPort (const DataFlowPort &other, Node *newHelder)
 
 DataFlowPort (const std::string &name, Node *node, TypeCode *type)
 
- Protected Member Functions inherited from YACS::ENGINE::DataPort
virtual ~DataPort ()
 
 DataPort (const DataPort &other, Node *newHelder)
 
 DataPort (const std::string &name, Node *node, TypeCode *type)
 
- Protected Member Functions inherited from YACS::ENGINE::Port
 Port (Node *node)
 
 Port (const Port &other, Node *newHelder)
 
- Protected Member Functions inherited from YACS::ENGINE::InPort
 InPort (const InPort &other, Node *newHelder)
 
 InPort (const std::string &name, Node *node, TypeCode *type)
 
void edRemoveAllLinksLinkedWithMe ()
 
virtual void edNotifyReferencedBy (OutPort *fromPort, bool isLoopProof=true)
 
virtual void edNotifyDereferencedBy (OutPort *fromPort)
 
virtual void getAllRepresentants (std::set< InPort * > &repr) const
 

Protected Attributes

Any_value
 
- Protected Attributes inherited from YACS::ENGINE::InputPort
Any_initValue
 
std::string _stringRef
 
bool _canBeNull
 
- Protected Attributes inherited from YACS::ENGINE::DataPort
TypeCode_type
 
std::string _name
 
- Protected Attributes inherited from YACS::ENGINE::Port
Node_node
 
int _id
 
- Protected Attributes inherited from YACS::ENGINE::InPort
std::set< std::pair< OutPort *, bool > > _backLinks
 

Private Attributes

YACS::BASES::Mutex _mutex
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::ENGINE::DataPort
static DataPortisCrossingType (const std::vector< DataPort * > &historyOfLink)
 
- Static Public Attributes inherited from YACS::ENGINE::InputPort
static const char NAME [] ="InputPort"
 
- Static Public Attributes inherited from YACS::ENGINE::DataFlowPort
static const char NAME [] ="DataFlowPort"
 
- Static Public Attributes inherited from YACS::ENGINE::DataPort
static const char NAME [] ="DataPort"
 
- Static Protected Attributes inherited from YACS::ENGINE::Port
static int _total = 0
 
static const char NAME [] ="Port"
 

Detailed Description

Definition at line 33 of file AnyInputPort.hxx.

Constructor & Destructor Documentation

◆ AnyInputPort() [1/2]

AnyInputPort::AnyInputPort ( const std::string &  name,
Node node,
TypeCode type,
bool  canBeNull = false 
)

Definition at line 35 of file AnyInputPort.cxx.

36  : InputPort(name, node, type, canBeNull),
37  DataPort(name, node, type),
38  Port(node),
39  _value(0)
40 {
41 }
DataPort(const DataPort &other, Node *newHelder)
Definition: DataPort.cxx:41
bool canBeNull() const
Definition: InputPort.cxx:174
InputPort(const InputPort &other, Node *newHelder)
Definition: InputPort.cxx:36
Port(Node *node)
Definition: Port.cxx:34

Referenced by clone().

◆ AnyInputPort() [2/2]

AnyInputPort::AnyInputPort ( const AnyInputPort other,
Node newHelder 
)

Definition at line 43 of file AnyInputPort.cxx.

44  : InputPort(other, newHelder),
45  DataPort(other, newHelder),
46  Port(other, newHelder),
47  _value(0)
48 {
49  if(other._value)
50  _value=other._value->clone();
51 }
virtual Any * clone() const =0

References _value, and YACS::ENGINE::Any::clone().

◆ ~AnyInputPort()

AnyInputPort::~AnyInputPort ( )
virtual

Definition at line 53 of file AnyInputPort.cxx.

54 {
55  if(_value)
56  {
57  DEBTRACE("_value ref count: " << _value->getRefCnt());
58  _value->decrRef();
59  }
60 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
unsigned int getRefCnt() const
Definition: RefCounter.hxx:32

References _value, DEBTRACE, YACS::ENGINE::RefCounter::decrRef(), and YACS::ENGINE::RefCounter::getRefCnt().

Member Function Documentation

◆ clone()

InputPort * AnyInputPort::clone ( Node newHelder) const
virtual

Implements YACS::ENGINE::InputPort.

Reimplemented in YACS::ENGINE::SeqAnyInputPort, and YACS::ENGINE::InterceptorInputPort.

Definition at line 133 of file AnyInputPort.cxx.

134 {
135  return new AnyInputPort(*this,newHelder);
136 }
AnyInputPort(const std::string &name, Node *node, TypeCode *type, bool canBeNull=false)

References AnyInputPort().

Referenced by YACS::ENGINE::OptimizerLoop::initInterceptors().

◆ dump()

std::string AnyInputPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::InputPort.

Reimplemented in YACS::ENGINE::SeqAnyInputPort.

Definition at line 138 of file AnyInputPort.cxx.

139 {
140  if(!_value)
141  {
142  std::string what="AnyInputPort::get : no value currently in input port with name \""; what+=_name; what+="\"";
143  throw Exception(what);
144  }
145  stringstream xmldump;
146  switch (_value->getType()->kind())
147  {
148  case Double:
149  xmldump << "<value><double>" << setprecision(16) << _value->getDoubleValue() << "</double></value>" << endl;
150  break;
151  case Int:
152  xmldump << "<value><int>" << _value->getIntValue() << "</int></value>" << endl;
153  break;
154  case Bool:
155  xmldump << "<value><boolean>" << _value->getBoolValue() << "</boolean></value>" << endl;
156  break;
157  case String:
158  xmldump << "<value><string>" << _value->getStringValue() << "</string></value>" << endl;
159  break;
160  default:
161  xmldump << "<value><error> NO_SERIALISATION_AVAILABLE </error></value>" << endl;
162  break;
163  }
164  return xmldump.str();
165 }
virtual std::string getStringValue() const =0
virtual int getIntValue() const =0
virtual double getDoubleValue() const =0
virtual bool getBoolValue() const =0
const TypeCode * getType() const
Definition: Any.hxx:85
DynType kind() const
Definition: TypeCode.cxx:47

References YACS::ENGINE::DataPort::_name, _value, YACS::ENGINE::Bool, YACS::ENGINE::Double, YACS::ENGINE::Any::getBoolValue(), YACS::ENGINE::Any::getDoubleValue(), YACS::ENGINE::Any::getIntValue(), YACS::ENGINE::Any::getStringValue(), YACS::ENGINE::Any::getType(), YACS::ENGINE::Int, YACS::ENGINE::TypeCode::kind(), and YACS::ENGINE::String.

◆ exRestoreInit()

void AnyInputPort::exRestoreInit ( )
virtual

Restore the saved data value to current data value.

If no data has been saved (_initValue == 0) don't restore

Implements YACS::ENGINE::InputPort.

Definition at line 77 of file AnyInputPort.cxx.

78 {
79  if(!_initValue)
80  return;
81  if(_value)
82  _value->decrRef();
84  _value->incrRef();
85 }

References YACS::ENGINE::InputPort::_initValue, _value, YACS::ENGINE::RefCounter::decrRef(), and YACS::ENGINE::RefCounter::incrRef().

◆ exSaveInit()

void AnyInputPort::exSaveInit ( )
virtual

Save the current data value for further reinitialization of the port.

Implements YACS::ENGINE::InputPort.

Definition at line 66 of file AnyInputPort.cxx.

67 {
71 }

References YACS::ENGINE::InputPort::_initValue, _value, YACS::ENGINE::RefCounter::decrRef(), and YACS::ENGINE::RefCounter::incrRef().

◆ get()

void * AnyInputPort::get ( ) const
virtual

Implements YACS::ENGINE::InputPort.

Definition at line 117 of file AnyInputPort.cxx.

118 {
119  return (void *)_value;
120 }

References _value.

◆ getAsString()

std::string AnyInputPort::getAsString ( )
virtual

returns port value as a string that can be used in a GUI for example

Do nothing here. To subclass

Reimplemented from YACS::ENGINE::DataPort.

Definition at line 122 of file AnyInputPort.cxx.

123 {
126 }
YACS::BASES::Mutex _mutex
TypeCode * edGetType() const
Definition: DataPort.hxx:53
virtual std::string convertNeutralAsString(TypeCode *type, Any *data)
Convert a YACS::ENGINE::Any object to a string to be used in GUI for example.
Definition: Runtime.cxx:369
YACSLIBENGINE_EXPORT Runtime * getRuntime()
Definition: Runtime.cxx:61

References _mutex, _value, YACS::ENGINE::Runtime::convertNeutralAsString(), YACS::ENGINE::DataPort::edGetType(), and YACS::ENGINE::getRuntime().

◆ getIntValue()

◆ getValue()

Any* YACS::ENGINE::AnyInputPort::getValue ( ) const
inline

Definition at line 41 of file AnyInputPort.hxx.

41 { return _value; }

Referenced by YACS::ENGINE::OptimizerLoop::exUpdateState().

◆ isEmpty()

◆ put() [1/2]

void AnyInputPort::put ( Any data)

Definition at line 100 of file AnyInputPort.cxx.

101 {
104  _value=data;
105  if (_value)
106  {
107  _value->incrRef();
108  DEBTRACE("value ref count: " << _value->getRefCnt());
109  }
110 }

References _mutex, _value, DEBTRACE, YACS::ENGINE::RefCounter::getRefCnt(), YACS::ENGINE::RefCounter::incrRef(), and releaseDataUnsafe().

Referenced by put(), and YACS::ENGINE::OptimizerLoop::setAlgorithm().

◆ put() [2/2]

void AnyInputPort::put ( const void *  data)
virtual

Implements YACS::ENGINE::InputPort.

Definition at line 128 of file AnyInputPort.cxx.

129 {
130  put((Any *)data);
131 }
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79

References put().

◆ releaseData()

void AnyInputPort::releaseData ( )
overridevirtual

Implements YACS::ENGINE::InputPort.

Definition at line 94 of file AnyInputPort.cxx.

References _mutex, and releaseDataUnsafe().

◆ releaseDataUnsafe()

void AnyInputPort::releaseDataUnsafe ( )
protected

Definition at line 87 of file AnyInputPort.cxx.

88 {
89  if(_value)
90  _value->decrRef();
91  _value = nullptr;
92 }

References _value, and YACS::ENGINE::RefCounter::decrRef().

Referenced by put(), and releaseData().

◆ typeName()

virtual std::string YACS::ENGINE::AnyInputPort::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 51 of file AnyInputPort.hxx.

51 {return "YACS__ENGINE__AnyInputPort";}

Member Data Documentation

◆ _mutex

YACS::BASES::Mutex YACS::ENGINE::AnyInputPort::_mutex
private

Definition at line 57 of file AnyInputPort.hxx.

Referenced by getAsString(), put(), and releaseData().

◆ _value


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