#include <PsInput.h>
Inheritance diagram for PsInput< Type >:


Public Methods | |
| PsInput (const PsName &inputName, PsSimulatedObject &owner, bool makeConnectable, const int precisionLevel=PsPolatorNT::defaultPrecisionLevel) | |
| Constructor. | |
| virtual | ~PsInput (void) |
| virtual bool | connect (const PsName &objectName, const PsName &outputName) |
| connect this input to the output of an other simulated object. | |
| virtual bool | connect (PsSimulatedObject &object, const PsName &outputName) |
| connect this input to the output of an other simulated object. | |
| virtual bool | connect (PsSimulatedObject *pointerToObject, const PsName &outputName) |
| connect this input to the output of an other simulated object. | |
| virtual bool | connect (const PsName &objectName, const PsName &outputName, const Type &initialValue) |
| connect this input to the output of an other object, and propose an initial value in case the output hasn't been initialised yet. | |
| virtual bool | connect (PsSimulatedObject &object, const PsName &outputName, const Type &initialValue) |
| connect this input to the output of an other object, and propose an initial value in case the output hasn't been initialised yet. | |
| virtual bool | connect (PsSimulatedObject *pointerToObject, const PsName &outputName, const Type &initialValue) |
| connect this input to the output of an other object, and propose an initial value in case the output hasn't been initialised yet. | |
| virtual bool | connectToControlParameter (const PsName &objectName, const PsName &controlParameterName) |
| connect this input to a control parameter of an other simulated object. | |
| virtual bool | connectToControlParameter (PsSimulatedObject &object, const PsName &controlParameterName) |
| connect this input to the controlParameter of an other simulated object. | |
| virtual bool | connectToControlParameter (PsSimulatedObject *pointerToObject, const PsName &controlParameterName) |
| connect this input to the controlParameter of an other simulated object. | |
| virtual bool | connectToControlParameter (const PsName &objectName, const PsName &controlParameterName, const Type &initialValue) |
| connect this input to a control parameter of an other object, and propose an initial value in case the controlParameter hasn't been initialised yet. | |
| virtual bool | connectToControlParameter (PsSimulatedObject &object, const PsName &controlParameterName, const Type &initialValue) |
| connect this input to a control parameter of an other object, and propose an initial value in case the controlParameter hasn't been initialised yet. | |
| virtual bool | connectToControlParameter (PsSimulatedObject *pointerToObject, const PsName &controlParameterName, const Type &initialValue) |
| connect this input to a control parameter of an other object, and propose an initial value in case the controlParameter hasn't been initialised yet. | |
| virtual const PsOutputNT * | getConnectedOutput () const |
| get a pointer to output this input is connected to | |
| virtual void | disconnect () |
| disconnect the input from the connected output | |
| virtual const Type & | get (int deltaT=0) |
| get the value of the connected output a certain date. | |
| virtual int | getDistanceToExactValue () const |
| get distance to exact value. | |
| virtual const Type & | getLastExactValue () const |
| get the last exact value. | |
| virtual const PsDate & | getDateOfLastExactValue () const |
| get the date of the last exact value. | |
| virtual void | printDebuggingInformation (ostream &err) const |
| print any usefull debugging information for this input | |
| virtual void | extract (istream &=cin) |
| extraction from an input stream (input stream) no real semantic has yet been defined for this operation | |
| virtual void | insertInStream (ostream &=cout) const |
| insert in anoutput stream no real semantic has yet been defined for this operation | |
| virtual void | outputDestroyed () |
| called by the destructor of an connected output | |
| virtual bool | realConnect (PsOutputNT *output) |
| the real connecting member function | |
Protected Attributes | |
| int | _distanceToExactValueOfLastGet |
| distance To Exact Value Of Last Get the distance in milli seconds between the last value returned by get and the nearest exact value from which it was calculated. | |
| PsOutput< Type > * | _connectedOutput |
| reference to the connected output | |
| Type | _calculatedResult |
| cache for computations of approximated values using this cache enables get to return a reference to a value, which enables implementing get whithout unnecessary copy operations | |
| PsInputConnectionEventListener< Type > * | _associatedEventListener |
| the event listener implementing default policy for connection by other objects | |
template parameter must be of a derived class of PsType
Definition at line 40 of file PsInput.h.
|
||||||||||||||||||||||||
|
Constructor.
Definition at line 255 of file PsInput.h. References PsInput< Type >::_associatedEventListener, and PsSimulatedObject::addEventListener().
00257 : PsAbstractInput<Type>( inputName, owner, makeConnectable, precisionLevel ), 00258 _connectedOutput ( PsNullOutputCreator::template getNullOutput <Type> () ) 00259 { 00260 // the event listener has to be created even is makeConnectable is false to enable dynamic change in the connectable state without side effects on event listener order. This is important to ensure consistent behaviour in way that doesn't depend on creation and making public order. 00261 _associatedEventListener = new PsInputConnectionEventListener<Type> ( owner, this ) ; 00262 owner.addEventListener( *_associatedEventListener ) ; |
|
||||||||||
|
Definition at line 266 of file PsInput.h. References PsInput< Type >::_associatedEventListener, and PsInput< Type >::_connectedOutput.
00268 {
00269 if ( _associatedEventListener != NULL ) delete _associatedEventListener ;
00270 _connectedOutput -> disconnectedMyself (this) ;
|
|
||||||||||||||||||||
|
connect this input to the output of an other object, and propose an initial value in case the output hasn't been initialised yet.
Implements PsAbstractInput< Type >. Definition at line 347 of file PsInput.h. References PsAbstractInput< Type >::connect().
00351 {
00352 return PsAbstractInput<Type>::connect (object, outputName, initialValue );
|
|
||||||||||||||||||||
|
connect this input to the output of an other object, and propose an initial value in case the output hasn't been initialised yet.
Implements PsAbstractInput< Type >. Definition at line 331 of file PsInput.h. References PsInput< Type >::_connectedOutput, and PsInput< Type >::connect().
00335 {
00336 if ( connect (object, outputName) )
00337 {
00338 _connectedOutput->suggest (initialValue) ;
00339 return true ;
00340 }
00341 else
00342 {
00343 return false ;
00344 }
|
|
||||||||||||||||||||
|
connect this input to the output of an other object, and propose an initial value in case the output hasn't been initialised yet.
Implements PsAbstractInput< Type >. Definition at line 313 of file PsInput.h. References PsInput< Type >::_connectedOutput, and PsInput< Type >::connect().
00317 {
00318 if ( connect (objectName, outputName) )
00319 {
00320 _connectedOutput->suggest (initialValue) ;
00321 return true ;
00322 }
00323 else
00324 {
00325 return false ;
00326 }
|
|
||||||||||||||||
|
connect this input to the output of an other simulated object.
Implements PsAbstractInput< Type >. Definition at line 368 of file PsInput.h. References PsAbstractInput< Type >::connect().
00371 {
00372 return PsAbstractInput<Type>::connect(object, outputName) ;
|
|
||||||||||||||||
|
connect this input to the output of an other simulated object.
Implements PsAbstractInput< Type >. Definition at line 356 of file PsInput.h. References PsSimulatedObject::getPointerToOutputNamed(), and PsInput< Type >::realConnect().
00359 {
00360
00361 #ifdef _DEBUGTYPEUTIL
00362 cout << "PsInput<Type>::connect" << endl;
00363 #endif
00364 return realConnect (object.getPointerToOutputNamed (outputName)) ;
|
|
||||||||||||||||
|
connect this input to the output of an other simulated object.
Implements PsAbstractInput< Type >. Definition at line 288 of file PsInput.h. References PsAttribute::_owner, PsSimulatedObject::getController(), PsSimulatedObject::getPointerToOutputNamed(), PsController::getPointerToSimulatedObjectNamed(), PsInput< Type >::printDebuggingInformation(), and PsInput< Type >::realConnect(). Referenced by PsInput< Type >::connect(), and PsInput< Type >::connectToControlParameter().
00290 {
00291 #ifdef _DEBUGTYPEUTIL
00292 cout << "PsInput<Type>::connect" << endl;
00293 #endif
00294 PsSimulatedObject * object = _owner.getController ().getPointerToSimulatedObjectNamed (objectName) ;
00295 if (object != NULL)
00296 {
00297 #ifdef DEBUG
00298 cerr << "PsInput<Type>::connect, objet : " << objectName
00299 << ", sur sortie : " << outputName << endl
00300 << "pointeur de la sortie de l'objet : " << object->getPointerToOutputNamed ( outputName ) << endl ;
00301 #endif
00302 return realConnect ( object->getPointerToOutputNamed ( outputName ) ) ;
00303 }
00304 else
00305 {
00306 printDebuggingInformation ( cerr ) ;
00307 cerr<< "PsInput<Type>::connect " <<objectName<<" unknown"<< endl ;
00308 return false ;
00309 }
|
|
||||||||||||||||||||
|
connect this input to a control parameter of an other object, and propose an initial value in case the controlParameter hasn't been initialised yet.
Implements PsAbstractInput< Type >. Definition at line 433 of file PsInput.h. References PsAbstractInput< Type >::connectToControlParameter().
00437 {
00438 return PsAbstractInput<Type>::connectToControlParameter ( pointerToObject, controlParameterName, initialValue ) ;
|
|
||||||||||||||||||||
|
connect this input to a control parameter of an other object, and propose an initial value in case the controlParameter hasn't been initialised yet.
Implements PsAbstractInput< Type >. Definition at line 417 of file PsInput.h. References PsInput< Type >::_connectedOutput, and PsInput< Type >::connect().
00421 {
00422 if ( connect (object, controlParameterName) )
00423 {
00424 _connectedOutput->suggest (initialValue) ;
00425 return true ;
00426 }
00427 else
00428 {
00429 return false ;
00430 }
|
|
||||||||||||||||||||
|
connect this input to a control parameter of an other object, and propose an initial value in case the controlParameter hasn't been initialised yet.
Implements PsAbstractInput< Type >. Definition at line 399 of file PsInput.h. References PsInput< Type >::_connectedOutput, and PsInput< Type >::connect().
00403 {
00404 if ( connect (objectName, controlParameterName) )
00405 {
00406 _connectedOutput->suggest (initialValue) ;
00407 return true ;
00408 }
00409 else
00410 {
00411 return false ;
00412 }
|
|
||||||||||||||||
|
connect this input to the controlParameter of an other simulated object.
Implements PsAbstractInput< Type >. Definition at line 456 of file PsInput.h. References PsAbstractInput< Type >::connectToControlParameter().
00459 {
00460 #ifdef _DEBUGTYPEUTIL
00461 cerr << "PsInput<Type>::connect" << endl;
00462 #endif
00463 return PsAbstractInput<Type>::connectToControlParameter (object, controlParameterName) ;
|
|
||||||||||||||||
|
connect this input to the controlParameter of an other simulated object.
Implements PsAbstractInput< Type >. Definition at line 444 of file PsInput.h. References PsSimulatedObject::getPointerToControlParameterNamed(), and PsInput< Type >::realConnect().
00447 {
00448 #ifdef _DEBUGTYPEUTIL
00449 cerr << "PsInput<Type>::connect" << endl;
00450 #endif
00451 return realConnect (object.getPointerToControlParameterNamed (controlParameterName)) ;
|
|
||||||||||||||||
|
connect this input to a control parameter of an other simulated object.
Implements PsAbstractInput< Type >. Definition at line 379 of file PsInput.h. References PsAttribute::_owner, PsSimulatedObject::getController(), PsSimulatedObject::getPointerToControlParameterNamed(), PsController::getPointerToSimulatedObjectNamed(), PsInput< Type >::printDebuggingInformation(), and PsInput< Type >::realConnect().
00381 {
00382 #ifdef _DEBUGTYPEUTIL
00383 cout << "PsInput<Type>::connectToControlParameter" << endl;
00384 #endif
00385 PsSimulatedObject * object = _owner.getController ().getPointerToSimulatedObjectNamed (objectName) ;
00386 if (object != NULL)
00387 {
00388 return realConnect ( object->getPointerToControlParameterNamed ( controlParameterName ) ) ;
00389 }
00390 else
00391 {
00392 printDebuggingInformation ( cerr ) ;
00393 cerr<< "PsInput<Type>::connectToControlParameter " <<objectName<<" unknown"<< endl ;
00394 return false ;
00395 }
|
|
|||||||||
|
disconnect the input from the connected output
Implements PsInputNT. Reimplemented in PsSensitiveInput< Type >. Definition at line 277 of file PsInput.h. References PsInput< Type >::_connectedOutput. Referenced by PsSensitiveInput< Type >::disconnect(), and PsInput< Type >::realConnect().
00279 {
00280 _connectedOutput -> disconnectedMyself (this) ;
00281 _connectedOutput = PsNullOutputCreator::template getNullOutput<Type> () ;
|
|
||||||||||
|
extraction from an input stream (input stream) no real semantic has yet been defined for this operation
Implements PsAttribute. Definition at line 569 of file PsInput.h. References PsInput< Type >::_connectedOutput.
00571 {
00572 assert ( false ) ; //shouldn't be called
00573 in >> *_connectedOutput ;
|
|
||||||||||
|
get the value of the connected output a certain date.
Implements PsAbstractInput< Type >. Definition at line 528 of file PsInput.h. References PsInput< Type >::_calculatedResult, PsInput< Type >::_connectedOutput, PsInput< Type >::_distanceToExactValueOfLastGet, PsAttribute::_name, PsAttribute::_owner, PsAbstractInput< Type >::_precisionLevel, and PsSimulatedObject::getName().
00530 {
00531 #ifdef _DEBUGTYPEUTIL
00532 cout << "PsInput<Type>::localGet calling get of _connectedOutput " <<refOutput<< endl;
00533 #endif
00534 try {
00535 return _connectedOutput->get (_distanceToExactValueOfLastGet,
00536 _precisionLevel,
00537 deltaT,
00538 _calculatedResult);
00539 }
00540 catch (PsUnInitialisedOutputException & s ) {
00541 s<<"PsInput<"<<typeid(Type).name()<<">::get \n";
00542 s<<"Owner "<< _owner.getName() <<"de nom "<<_name<<"\n";
00543 throw ;
00544 }
|
|
|||||||||
|
get a pointer to output this input is connected to
Implements PsAbstractInput< Type >. Definition at line 520 of file PsInput.h. References PsInput< Type >::_connectedOutput.
00522 {
00523 return _connectedOutput ;
|
|
|||||||||
|
get the date of the last exact value.
Implements PsAbstractInput< Type >. Definition at line 554 of file PsInput.h. References PsInput< Type >::_connectedOutput, and PsDate.
00555 {
00556 return _connectedOutput->getDateOfLastExactValue () ;
|
|
|||||||||
|
get distance to exact value.
Implements PsAbstractInput< Type >. Definition at line 561 of file PsInput.h. References PsInput< Type >::_distanceToExactValueOfLastGet.
00563 {
00564 return _distanceToExactValueOfLastGet ;
|
|
|||||||||
|
get the last exact value. Using this member function garanties that a value produced is returned, but it should only be used for specific needs, as it prevents any optimisation by the kernel, and the date of production of the value isn't accessible
Implements PsAbstractInput< Type >. Definition at line 548 of file PsInput.h. References PsInput< Type >::_connectedOutput.
00549 {
00550 return _connectedOutput->getLastExactValue () ;
|
|
||||||||||
|
insert in anoutput stream no real semantic has yet been defined for this operation
Implements PsAttribute. Definition at line 578 of file PsInput.h. References PsInput< Type >::_connectedOutput.
00580 {
00581 assert ( false ) ; //shouldn't be called
00582 out << *_connectedOutput << " " ;
|
|
|||||||||
|
called by the destructor of an connected output
Definition at line 597 of file PsInput.h. References PsInput< Type >::_connectedOutput.
00599 {
00600 _connectedOutput = PsNullOutputCreator::template getNullOutput<Type> () ;
|
|
||||||||||
|
print any usefull debugging information for this input
Implements PsAbstractInput< Type >. Definition at line 587 of file PsInput.h. References PsAttribute::_owner, PsAbstractInput< Type >::_precisionLevel, and PsSimulatedObject::getName(). Referenced by PsInput< Type >::connect(), PsInput< Type >::connectToControlParameter(), and PsInput< Type >::realConnect().
00589 {
00590 err << "**********************************************************" << endl;
00591 err << "Class PsInput" << endl;
00592 err << "owner : " << _owner.getName() << endl;
00593 err << "polation precision level : " << _precisionLevel << endl;
00594 err << "element type : " << typeid(Type).name() << endl;
|
|
||||||||||
|
the real connecting member function
Implements PsInputNT. Definition at line 469 of file PsInput.h. References PsInput< Type >::_connectedOutput, PsAttribute::_owner, PsInput< Type >::disconnect(), PsAbstractInput< Type >::getConnectionEventId(), PsAbstractInput< Type >::getConnectionToControlParameterEventId(), PsSimulatedObject::getController(), PsnCurrentActiveObject::getCurrentActiveObject(), PsSimulatedObject::getName(), PsAttribute::getName(), PsAbstractInput< Type >::isConnectable(), PsInput< Type >::printDebuggingInformation(), and PsSimulatedObject::sendValuedEvent(). Referenced by PsInput< Type >::connect(), PsInput< Type >::connectToControlParameter(), and PsSensitiveInput< Type >::internalConnect().
00471 {
00472 /* if the current active object isn't initialised or is the owner of the input, proceed with connection*/
00473 if ( PsnCurrentActiveObject::getCurrentActiveObject() == &_owner ||
00474 PsnCurrentActiveObject::getCurrentActiveObject() == &_owner.getController() ||
00475 PsnCurrentActiveObject::getCurrentActiveObject() == NULL )
00476 {
00477 disconnect() ;
00478 _connectedOutput = dynamic_cast <PsOutput<Type> *> (output) ;
00479
00480 if ( _connectedOutput == NULL )
00481 {
00482 printDebuggingInformation ( cerr ) ;
00483 cerr<<"PsInput::realConnect outpout is of wrong type"<<endl;
00484 return false ;
00485 }
00486 else
00487 {
00488 _connectedOutput->connectedMyself(this) ;
00489 return true ;
00490 }
00491 }
00492 else if ( isConnectable() )
00493 {
00494 PsControlParameter<Type> * controlParameter = dynamic_cast<PsControlParameter<Type> *> (output) ;
00495 if ( controlParameter == NULL )
00496 {
00497 PsnCurrentActiveObject::getCurrentActiveObject()->sendValuedEvent(_owner,
00498 getConnectionEventId(),
00499 output->getName() ) ;
00500 }
00501 else
00502 {
00503 PsnCurrentActiveObject::getCurrentActiveObject()->sendValuedEvent(_owner,
00504 getConnectionToControlParameterEventId(),
00505 output->getName() ) ;
00506 }
00507 return true ;
00508 }
00509 else
00510 {
00511 cerr<<"Warning: "
00512 <<_owner.getName()<<"::"<<getName()<<" "
00513 <<"is not connectable"<<endl;
00514 return false ;
00515 }
|
|
|||||
|
the event listener implementing default policy for connection by other objects
Definition at line 239 of file PsInput.h. Referenced by PsInput< Type >::PsInput(), and PsInput< Type >::~PsInput(). |
|
|||||
|
cache for computations of approximated values using this cache enables get to return a reference to a value, which enables implementing get whithout unnecessary copy operations
Definition at line 236 of file PsInput.h. Referenced by PsInput< Type >::get(). |
|
|||||
|
|||||
|
distance To Exact Value Of Last Get the distance in milli seconds between the last value returned by get and the nearest exact value from which it was calculated. Distance is positive if the returned value is after the last exact value. Definition at line 225 of file PsInput.h. Referenced by PsInput< Type >::get(), and PsInput< Type >::getDistanceToExactValue(). |
| Documentation generated on Mon Nov 25 15:26:03 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |