Version: 8.3.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 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) throw (ConversionException)
 
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 throw (Exception)
 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...
 
virtual ~InPort ()
 

Protected Attributes

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

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"
 
- 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)
 
- 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::AnyInputPort ( const std::string &  name,
Node node,
TypeCode type,
bool  canBeNull = false 
)

Definition at line 35 of file AnyInputPort.cxx.

Referenced by clone().

36  : InputPort(name, node, type, canBeNull),
37  DataPort(name, node, type),
38  Port(node),
39  _value(0)
40 {
41 }
AnyInputPort::AnyInputPort ( const AnyInputPort other,
Node newHelder 
)

Definition at line 43 of file AnyInputPort.cxx.

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

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 }
AnyInputPort::~AnyInputPort ( )
virtual

Definition at line 53 of file AnyInputPort.cxx.

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

54 {
55  if(_value)
56  {
57  DEBTRACE("_value ref count: " << _value->getRefCnt());
58  _value->decrRef();
59  }
60 }

Member Function Documentation

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

Implements YACS::ENGINE::InputPort.

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

Definition at line 120 of file AnyInputPort.cxx.

References AnyInputPort().

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

121 {
122  return new AnyInputPort(*this,newHelder);
123 }
std::string AnyInputPort::dump ( )
virtual

Reimplemented from YACS::ENGINE::InputPort.

Reimplemented in YACS::ENGINE::SeqAnyInputPort.

Definition at line 125 of file AnyInputPort.cxx.

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.

126 {
127  if(!_value)
128  {
129  std::string what="AnyInputPort::get : no value currently in input port with name \""; what+=_name; what+="\"";
130  throw Exception(what);
131  }
132  stringstream xmldump;
133  switch (_value->getType()->kind())
134  {
135  case Double:
136  xmldump << "<value><double>" << setprecision(16) << _value->getDoubleValue() << "</double></value>" << endl;
137  break;
138  case Int:
139  xmldump << "<value><int>" << _value->getIntValue() << "</int></value>" << endl;
140  break;
141  case Bool:
142  xmldump << "<value><boolean>" << _value->getBoolValue() << "</boolean></value>" << endl;
143  break;
144  case String:
145  xmldump << "<value><string>" << _value->getStringValue() << "</string></value>" << endl;
146  break;
147  default:
148  xmldump << "<value><error> NO_SERIALISATION_AVAILABLE </error></value>" << endl;
149  break;
150  }
151  return xmldump.str();
152 }
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.

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

78 {
79  if(!_initValue)
80  return;
81  if(_value)
82  _value->decrRef();
84  _value->incrRef();
85 }
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.

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

67 {
71 }
void * AnyInputPort::get ( ) const
virtual

Implements YACS::ENGINE::InputPort.

Definition at line 104 of file AnyInputPort.cxx.

References _value.

105 {
106  return (void *)_value;
107 }
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 109 of file AnyInputPort.cxx.

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

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

Definition at line 41 of file AnyInputPort.hxx.

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

41 { return _value; }
void AnyInputPort::put ( Any data)
void AnyInputPort::put ( const void *  data) throw (ConversionException)
virtual

Implements YACS::ENGINE::InputPort.

Definition at line 115 of file AnyInputPort.cxx.

116 {
117  put((Any *)data);
118 }
virtual std::string YACS::ENGINE::AnyInputPort::typeName ( )
inlinevirtual

Reimplemented from YACS::ENGINE::InputPort.

Definition at line 50 of file AnyInputPort.hxx.

50 {return "YACS__ENGINE__AnyInputPort";}

Member Data Documentation

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

Definition at line 54 of file AnyInputPort.hxx.

Referenced by getAsString(), and put().


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