OMK::Output< T > Class Template Reference

An output of a certain type for a simulated object. More...

#include <OMKOutput.h>

Inheritance diagram for OMK::Output< T >:

Inheritance graph
[legend]
Collaboration diagram for OMK::Output< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Output (const Name &outputName, SimulatedObject &owner, const int historySize, OMK::Type::PolatorNT *polator=0)
 Constructor.
virtual ~Output ()
 Destructor.
virtual const T & get (int &distanceToExactValue, const int precisionLevel, const Date &deltaT, T &calculatedResult) const
 get a value for this output
virtual const T & getLastExactValue () const
 get the last exact value produced and stored in this output
virtual const DategetDateOfLastExactValue () const
 get the date of the last exact value produced and stored in this output
virtual void set (const T &newValue, bool alwaysUpdate=false)
 publish a new value through this output
virtual void suggest (const T &suggestedValue)
 used by an input to suggest an initial value if none has yet been produced
virtual T & getNextPlaceHolder ()
 get a reference to the next place that will be used to store a value.
virtual void setInPlace (const T &)
 zero copy set for values wich have been calculated using the reference obtained by getNextPlaceHolder
virtual void connectedMyself (InputNT *input)
 called by an input when it connects to this output
virtual void disconnectedMyself (InputNT *input)
 called by an input when it disconnects from this output
virtual void printDebuggingInformation (std::ostream &err) const
 print debugging info
void printHistory () const
 print all the stored values
virtual void empty ()
 empty all the stored values
coding and decoding the output values from and to streams
virtual void extract (std::istream &=std::cin)
 extract new values from a stream
virtual void insertInStream (std::ostream &=std::cout) const
 insert latest value in a stream
virtual void pack (OutgoingSynchronisationMessage &) const
 pack value in a PvmMessage ( should be delegated to a pvm output ) packs the name of the output, then any usefull update information
virtual void packAllValues (OutgoingSynchronisationMessage &) const
 pack value in a PvmMessage ( should be delegated to a pvm output ) packs the name of the output, then all initial information
virtual void unpack (IncomingSynchronisationMessage &)
 unpack value from a PvmMessage ( should be delegated to a pvm output ) shouldn't unpack the name, but all other usefull information packed
virtual void unpackAllValues (IncomingSynchronisationMessage &)
 unpack value from a PvmMessage ( should be delegated to a pvm output ) shouldn't unpack the name, but all other usefull information packed
alias management
virtual void setUsedOutput (Output< T > *output)
 change the output read by internal get
virtual void setAlias (OutputAlias< T > *output)
 set the direct alias of this output
virtual void unsetAlias ()
 cancel aliasing
virtual Output< T > * getUsedOutput () const
 get the output used by internal get
virtual OutputAlias< T > * getAlias () const
 get the direct alias of this output

Public Attributes

OMK::Type::Polator< T > * _polator
 the associated polator

Protected Member Functions

virtual void setValidity (bool)
 setValidity.
virtual const T & localGet (int &validiteRes, const int niveauInterpol, const Date &deltaT, T &resultPlaceHolder) const
 this is the get that accesses the local history fifo, whether the output is aliased or not
virtual void localInsert (std::ostream &=std::cout) const
 an insert that changes the local history fifo

Protected Attributes

OutputAlias< T > * _aliasOfOutput
 a pointer to the primary alias of this output
Output< T > * _usedOutput
 the output read by get
AbstractFifo< T > * _history
 the history storing fifo
const Date_date
 a reference to the current date
std::list< Input< T > * > _listOfConnectedUnsensitiveInputs
 the list of connected unsensitive inputs
bool _validity
 a boolean indicating presence of values in the fifo

Friends

class OutputAlias< T >
 friend declaration so thah aliases can notify the sensitive inputs connected to their aliased output

Detailed Description

template<typename T>
class OMK::Output< T >

An output of a certain type for a simulated object.

template parameter must be of a derived class of OMKType

See also:
OMKType
2001/03/07 (march 2001) : thread safety assessement of this class by David Margery : provided the owner of a Output doesn't use multithreaded access to an output (through set and insert for example), and that the owned OMKInterpolator can have concurrent access to the owned AbstractFifo (aka. AbstractFifo) (this should be ensured by the fifo which should enable concurrent reads and writes ), this class is thread safe. Beware, in a multithreaded context more UnInitialisedOutputException could be generated at initialisation time and after a clear()

Author:
Thierry Duval (version 2.0)
Version:
2.6 (revision $revision)

Definition at line 53 of file OMKOutput.h.


Constructor & Destructor Documentation

template<typename T>
OMK::Output< T >::Output ( const Name outputName,
SimulatedObject owner,
const int  historySize,
OMK::Type::PolatorNT polator = 0 
) [inline]

Constructor.

Parameters:
outputName the name of this output
owner the owner of this output
historySize size of the fifo associated
Polator a Polator, in case we want to replace the default one provided by T

Definition at line 263 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::Output< T >::_polator, OMK::Output< T >::_usedOutput, OMK::SimulatedObject::getName(), OMK::KernelAttribute::getName(), OMERROR, OMFATALERROR, OMK_DEBUG_OMK_POL, and OMTRACEID.

00267   : KernelAttribute( owner, outputName ),
00268     OutputNT( owner, outputName ),
00269      _aliasOfOutput( 0 ),
00270      _date( owner.getController().getSimulatedDate() ),
00271      _validity( false )
00272 {
00273    /* Thread safety assessement : 
00274     * thread safe because only on construction of the object
00275     */
00276 
00277   if( polator == 0 )
00278   {
00279     // any type has a static method that creates a default polator
00280     T aTypeInstance ; // because createPolator isn't static
00281     _polator = static_cast< OMK::Type::Polator< T > * >(
00282       aTypeInstance.createPolator() ) ;
00283 
00284     if( _polator != 0 )
00285     {
00286       OMTRACEID( OMK_DEBUG_OMK_POL,
00287                  "Created default polator for output \""
00288                  << getName() << "\" of object \""
00289                  << owner.getName() << "\", with type "
00290                  << typeid( _polator ).name() ) ;
00291     }
00292     else
00293     {
00294       OMERROR( "Created default polator for output \""
00295                << getName() <<  "\" of object \""
00296                << owner.getName() << " is not of type \""
00297                << " OMK::Type::Polator <"
00298                << typeid( T ).name() << "> *\"" ) ;
00299     }
00300   }
00301   else 
00302   {
00303     _polator = dynamic_cast< OMK::Type::Polator< T > * >( polator ) ;
00304     if( _polator != 0)
00305     {
00306       OMTRACEID( OMK_DEBUG_OMK_POL,
00307                  "Given polator for output \""
00308                  << getName() << "\" of object \""
00309                  << owner.getName() << "\", with type "
00310                  << typeid( _polator ).name()
00311                  << " has been associated with this output" ) ;
00312     }
00313     else
00314     {
00315       OMERROR( "Created polator for output \""
00316                << getName() <<  "\" of object \""
00317                << owner.getName() << " is not of type \""
00318                << " OMK::Type::Polator <"
00319                << typeid( T ).name() << "> *\"" ) ;
00320     }
00321   }
00322   if( _polator == 0 )
00323   {
00324     OMFATALERROR( "No polator has been made for output \""
00325                   << getName() << "\" of object \""
00326                   << owner.getName() << "\"" ) ;
00327   }
00328 
00329   // calculate the appropriate history fifo length
00330   int realSize =
00331     historyLength + _polator->getNumberOfNeededValuesForMaxPrecisionPolation() ;
00332   _history = new Fifo< T >( realSize ) ;
00333   _polator->setFifo( _history ) ;
00334 
00335   _usedOutput = this ;
00336 }

template<typename T>
OMK::Output< T >::~Output (  )  [inline, virtual]

Destructor.

Definition at line 341 of file OMKOutput.h.

References OMK::Output< T >::_aliasOfOutput, OMK::Output< T >::_history, and OMK::Output< T >::_listOfConnectedUnsensitiveInputs.

00342 {
00343   /* Thread safety assessement :
00344    * thread safe because only one destruction of the object
00345    */
00346 #ifdef _OMK_MUTEX_
00347   _myMutex.protect() ;
00348 #endif
00349 
00350   typename std::list< Input< T > * >::iterator j ;
00351   for( j = _listOfConnectedUnsensitiveInputs.begin() ;
00352        j != _listOfConnectedUnsensitiveInputs.end() ;
00353        j++ )
00354   {
00355     (*j)->outputDestroyed() ;
00356   }
00357 
00358 #ifdef _OMK_MUTEX_
00359   _myMutex.unprotect() ;
00360 #endif
00361 
00362   if( _aliasOfOutput != 0 )
00363   {
00364     _aliasOfOutput->aliasedOutputDeleted() ;
00365   }
00366   delete _history ;
00367 }


Member Function Documentation

template<typename T>
const T & OMK::Output< T >::get ( int distanceToExactValue,
const int  precisionLevel,
const Date deltaT,
T &  calculatedResult 
) const [inline, virtual]

get a value for this output

Parameters:
distanceToExactValue where to store the distance to the nearest exact value returned by get
precisionLevel the degre of precision of any polation operation
deltaT age of the desired value seeked for
calculatedResult placeholder for any calculated result
Returns:
a reference to the desired result

Definition at line 447 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::Output< T >::getUsedOutput(), and OMASSERT.

00451 {
00452   /* Thread safety assessement :
00453    * As thread safe as localGet   
00454    */
00455 #ifdef _DEBUGTYPEUTIL
00456   std::cerr << "Output< T >::get" << std::endl ;
00457   std::cerr << "used Output: "<< getUsedOutpute() << std::endl ;
00458   std::cerr << "file: " << _history << std::endl ;
00459   _history->printDebuggingInformation() ;
00460   informations() ;
00461 #endif
00462    OMASSERT( getUsedOutput() != 0 ) ;
00463    return getUsedOutput()->localGet(
00464      validiteRes, niveauInterpol, deltaT, resultPlaceHolder ) ;
00465 }

template<typename T>
const T & OMK::Output< T >::getLastExactValue (  )  const [inline, virtual]

get the last exact value produced and stored in this output

Definition at line 760 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::KernelAttribute::_owner, OMK::Name::getCString(), OMK::SimulatedObject::getName(), and OMK::KernelAttribute::touch().

00761 {
00762   touch() ;
00763   // this bypasses any Polator
00764   if( _history->getNumberOfPresentValues( 1 ) < 1 ) // if no value is stored
00765   {
00766     UnInitialisedOutputException exception(
00767       *this, "Output< T >::getLastExactValue\n" ) ;
00768     exception << "Impossible to get a value from an uninitialised output of "
00769               << _owner.getName().getCString() ;
00770     throw exception ;
00771   }
00772   return _history->getPreceedingValue( 0 ) ;
00773 }

template<typename T>
const Date & OMK::Output< T >::getDateOfLastExactValue (  )  const [inline, virtual]

get the date of the last exact value produced and stored in this output

Definition at line 778 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::KernelAttribute::_owner, OMK::Name::getCString(), OMK::SimulatedObject::getName(), and OMK::KernelAttribute::touch().

00779 {
00780    touch() ;
00781    // this bypasses any Polator
00782    if( _history->getNumberOfPresentValues( 1 ) < 1 ) // if no value is stored
00783    {
00784      UnInitialisedOutputException exception(
00785        *this, "Output< T >::getLastExactValue\n" ) ;
00786      exception << "Impossible to get a value from an uninitialised output of "
00787                << _owner.getName().getCString() ;
00788      throw exception ;
00789    }
00790    return _history->getPreceedingDate( 0 ) ;
00791 }

template<typename T>
void OMK::Output< T >::set ( const T &  newValue,
bool  alwaysUpdate = false 
) [inline, virtual]

publish a new value through this output

Parameters:
newValue the new value of this output
alwaysUpdate send a message to the sensitive input even if the value doesn't change anyway

make sure the object making the set is the owner of the output, or the controler

Definition at line 545 of file OMKOutput.h.

References OMK::Output< T >::_date, OMK::Output< T >::_history, OMK::KernelAttribute::_owner, OMK::SimulatedObject::getController(), OMK::CurrentActiveObject::getCurrentActiveObject(), OMK::SimulatedObject::getName(), OMK::KernelAttribute::getName(), OMK::Name::getString(), OMERROR, and OMK::Output< T >::setValidity().

Referenced by OMK::IAttributeAnimatorT< PrmType, ModelType, AccessorType >::setValueToOutput(), and OMK::IAttributeT< PrmType, ModelType, AccessorType >::setValueToOutput().

00547 {
00550 #ifndef NDEBUG
00551   if( CurrentActiveObject::getCurrentActiveObject() != &_owner
00552    && CurrentActiveObject::getCurrentActiveObject() != &_owner.getController()
00553    && CurrentActiveObject::getCurrentActiveObject() )
00554   {
00555     OMERROR( ":-( Error in Output<" << typeid( T ).name() 
00556              << ">::set:  Unable to set the output \""
00557              << getName().getString() << "\""
00558              << std::endl
00559              << "The output owner [" << _owner.getName()
00560              << "] is not the active object ["
00561              << ( CurrentActiveObject::getCurrentActiveObject() ? 
00562                   CurrentActiveObject::getCurrentActiveObject()->getName().getString() :
00563                   std::string( "no active object" ) )
00564              << "]" ) ;
00565   }
00566 #endif
00567 
00568   /*OMASSERT( &_owner == CurrentActiveObject::getCurrentActiveObject() 
00569             || CurrentActiveObject::getCurrentActiveObject() == & _owner.getController()
00570             || CurrentActiveObject::getCurrentActiveObject() == 0 ) ;*/
00571   /* Thread safety assessement :
00572    * localGet and set could collide. Thread safety can only be assured if the
00573    * fifo and the interpolator are thread safe with respect to the value in the
00574    * fifo.
00575    * Only one set at a time.
00576    */
00577   _history->set( newValue, _date ) ;
00578   setValidity( true ) ;
00579 }

template<typename T>
void OMK::Output< T >::suggest ( const T &  suggestedValue  )  [inline, virtual]

used by an input to suggest an initial value if none has yet been produced

Parameters:
suggestedValue the suggested initial value for this output

Definition at line 813 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::KernelAttribute::_owner, OMK::Output< T >::_validity, OMK::SimulatedObject::getController(), OMK::Controller::getSimulatedDate(), and OMK::Output< T >::setValidity().

00814 {
00815   if( !_validity )
00816   {
00817     _history->set( newValue , _owner.getController().getSimulatedDate() ) ;
00818     setValidity( true ) ;
00819   }
00820 }

template<typename T>
T & OMK::Output< T >::getNextPlaceHolder (  )  [inline, virtual]

get a reference to the next place that will be used to store a value.

Using the obtained reference enables a zero copy set( using setInPlace) if the new value is directly calculated using that reference.

Definition at line 796 of file OMKOutput.h.

References OMK::Output< T >::_history.

00797 {
00798   return _history->getNextPlaceHolder() ;
00799 }

template<typename T>
void OMK::Output< T >::setInPlace ( const T &   )  [inline, virtual]

zero copy set for values wich have been calculated using the reference obtained by getNextPlaceHolder

Definition at line 804 of file OMKOutput.h.

References OMK::Output< T >::_date, OMK::Output< T >::_history, and OMK::Output< T >::setValidity().

00805 {
00806   _history->setInPlace( newValue, _date ) ;
00807   setValidity( true ) ;
00808 }

template<typename T>
void OMK::Output< T >::connectedMyself ( InputNT input  )  [virtual]

called by an input when it connects to this output

Implements OMK::OutputNT.

Definition at line 499 of file OMKOutput.h.

References OMK::Output< T >::_listOfConnectedUnsensitiveInputs, OMASSERT, and OMK::KernelAttribute::touch().

00500 {
00501   /* Thread safety assessement : 
00502    * Critical data is mutex protected  
00503    */
00504   touch() ;
00505 #ifdef _OMK_MUTEX_
00506   _myMutex.protect() ;
00507 #endif
00508 
00509   Input< T > * standardInput = dynamic_cast<Input< T > * >( input ) ;
00510   OMASSERT( standardInput != 0 ) ;
00511   _listOfConnectedUnsensitiveInputs.push_back( standardInput ) ;
00512 
00513 #ifdef _OMK_MUTEX_
00514   _myMutex.unprotect() ;
00515 #endif
00516 }

template<typename T>
void OMK::Output< T >::disconnectedMyself ( InputNT input  )  [virtual]

called by an input when it disconnects from this output

Implements OMK::OutputNT.

Definition at line 521 of file OMKOutput.h.

References OMK::Output< T >::_listOfConnectedUnsensitiveInputs.

00522 {
00523 #ifdef _DEBUGALIAS
00524   std::cerr << "Output< T >::disconnectedMyself" << std::endl ;
00525 #endif
00526 
00527   /* Thread safety assessement :
00528    * critical data is mutex protected  
00529    */
00530 #ifdef _OMK_MUTEX_
00531   _myMutex.protect() ;
00532 #endif
00533 
00534   Input < T > * unsensitiveInput = dynamic_cast< Input < T > * >( input ) ;
00535   _listOfConnectedUnsensitiveInputs.remove( unsensitiveInput ) ;
00536 
00537 #ifdef _OMK_MUTEX_
00538   _myMutex.unprotect() ;
00539 #endif
00540 }

template<typename T>
void OMK::Output< T >::extract ( std::istream &  = std::cin  )  [inline, virtual]

extract new values from a stream

Implements OMK::KernelAttribute.

Definition at line 584 of file OMKOutput.h.

References OMK::Output< T >::_history, and OMK::Output< T >::setValidity().

00585 {
00586   /* Thread safety assessement :
00587    * localGet and extract could collide. Thread safety can only be assured if
00588    * the fifo and the interpolator are thread safe with respect to the values
00589    * in the fifo.
00590    * Only one extract at a time.
00591    */
00592   in >> *_history ;
00593   setValidity( true ) ;
00594 }

template<typename T>
void OMK::Output< T >::insertInStream ( std::ostream &  = std::cout  )  const [inline, virtual]

insert latest value in a stream

Implements OMK::KernelAttribute.

Definition at line 678 of file OMKOutput.h.

References OMK::Output< T >::getUsedOutput().

00679 {
00680   /* Thread safety assessement :
00681    * As thread safe as localInsert 
00682    */
00683   getUsedOutput()->localInsert( out ) ; 
00684 }

template<typename T>
void OMK::Output< T >::pack ( OutgoingSynchronisationMessage  )  const [virtual]

pack value in a PvmMessage ( should be delegated to a pvm output ) packs the name of the output, then any usefull update information

Reimplemented from OMK::Flowable.

Definition at line 599 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::Output< T >::_validity, OMK::OutgoingSynchronisationMessage::getMessageDate(), OMK::KernelAttribute::getName(), and OMK::Name::pack().

00600 {
00601   //std::cerr << "Output< T >::pack" << std::endl ;
00602   //packs the name of the output, then any usefull information
00603   /* Thread safety assement :
00604    * Thread safe : collides with set and localInsert on the AbstractFifo. But
00605    * they should only be activated by the owner. So as long as the owner isn't
00606    * multithreaded...
00607    * Nota : in a multithreaded environment this member function could generate
00608    * more exceptions than expected
00609    */
00610   if( _validity && out.getMessageDate() == _history->getPreceedingDate( 0 ) )
00611   {
00612     getName().pack( out ) ;
00613     _history->pack( out ) ;
00614   }
00615   //else : do not pack anything, therefore mirror will remain uninitialised
00616   //std::cerr << "Output< T >:" << this << ":pack done" << std::endl ;
00617 }

template<typename T>
void OMK::Output< T >::packAllValues ( OutgoingSynchronisationMessage  )  const [virtual]

pack value in a PvmMessage ( should be delegated to a pvm output ) packs the name of the output, then all initial information

Implements OMK::OutputNT.

Definition at line 622 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::Output< T >::_validity, OMK::KernelAttribute::getName(), and OMK::Name::pack().

00623 {
00624   //std::cerr<<"packAllValues output \"" << getName() << "\"" ) ;
00625   //packs the name of the output, then all initial information
00626   /* Thread safety assement :
00627    * Thread safe : collides with set and localInsert on the AbstractFifo. But
00628    * they should only be activated by the owner. So as long as the owner isn't
00629    * multithreaded, or that the kernel doesn't call this member function during
00630    * activation of the owner...
00631    * Nota : in a multithreaded environment this member function could generate
00632    * more exceptions than expected
00633    */
00634   if( _validity )
00635   {
00636     getName().pack( out ) ;
00637     _history->packAllValues( out ) ;
00638   }
00639   //else : do not pack anything, therefore mirror will remain uninitialised
00640   //std::cerr<<"Output< T >:" << this << ":packAllValues done" << std::endl ;
00641 }

template<typename T>
void OMK::Output< T >::unpack ( IncomingSynchronisationMessage  )  [virtual]

unpack value from a PvmMessage ( should be delegated to a pvm output ) shouldn't unpack the name, but all other usefull information packed

Reimplemented from OMK::Flowable.

Definition at line 646 of file OMKOutput.h.

References OMK::Output< T >::_history, and OMK::Output< T >::setValidity().

00647 {
00648   // shouldn't unpack the name, but all other usefull information packed
00649   /* Thread safety assessement : 
00650    * localGet and extract could collide. Thread safety can only be assured if
00651    * the fifo and the interpolator are thread safe with respect to the values
00652    * in the fifo.
00653    * Only one extract at a time.
00654    */
00655   _history->unpack( in ) ;
00656   setValidity( true ) ;
00657 }

template<typename T>
void OMK::Output< T >::unpackAllValues ( IncomingSynchronisationMessage  )  [virtual]

unpack value from a PvmMessage ( should be delegated to a pvm output ) shouldn't unpack the name, but all other usefull information packed

Implements OMK::OutputNT.

Definition at line 662 of file OMKOutput.h.

References OMK::Output< T >::_history, and OMK::Output< T >::setValidity().

00663 {
00664   // shouldn't unpack the name, but all other usefull information packed
00665   /* Thread safety assessement : 
00666    * localGet and extract could collide. Thread safety can only be assured if
00667    * the fifo and the interpolator are thread safe with respect to the values
00668    * in the fifo.
00669    * Only one extract at a time.
00670    */
00671   _history->unpackAllValues( in ) ;
00672   setValidity( true ) ;
00673 }

template<typename T>
void OMK::Output< T >::printDebuggingInformation ( std::ostream &  err  )  const [inline, virtual]

print debugging info

Parameters:
the output stream on which to print debugging information

Implements OMK::KernelAttribute.

Definition at line 726 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::KernelAttribute::_name, OMK::KernelAttribute::_owner, OMK::Output< T >::getAlias(), OMK::SimulatedObject::getName(), and OMK::Output< T >::getUsedOutput().

00727 {
00728    /* thread safety assessement :
00729     * const method : thread safe. shown value may not be a coherant image of
00730     * an Output
00731     */
00732   err << std::endl
00733       << "**********************************************************"
00734       << std::endl
00735       << "Class Output" << std::endl
00736       << "Owner : " << _owner.getName() << std::endl
00737       << "Output Name : "<< _name << std::endl
00738       << "T of output : "<< typeid( T ).name() << std::endl 
00739       << "Output primary alias : " << getAlias() << std::endl 
00740       << "Used Output : " << getUsedOutput() << std::endl 
00741       << "History Fifo: " << _history << std::endl ;
00742 }

template<typename T>
void OMK::Output< T >::printHistory (  )  const [inline]

print all the stored values

Definition at line 714 of file OMKOutput.h.

References OMK::Output< T >::_history.

00715 {
00716   /* thread safety assessement :
00717    * const method : should be thread safe if printDebuggingInformation of
00718    * AbstractFifo is thread safe
00719    */
00720   _history->printDebuggingInformation() ;
00721 }

template<typename T>
void OMK::Output< T >::empty (  )  [inline, virtual]

empty all the stored values

Definition at line 747 of file OMKOutput.h.

References OMK::Output< T >::_history, and OMK::Output< T >::setValidity().

00748 {
00749   /* Thread safety assessement :
00750    * as thread safe as clear of fifo. Only one simultaneous acces possible (in
00751    * theory).
00752    */
00753   _history->clear() ;
00754   setValidity( false ) ;
00755 }

template<class T>
void OMK::Output< T >::setUsedOutput ( Output< T > *  output  )  [inline, virtual]

change the output read by internal get

Reimplemented in OMK::OutputAlias< T >, OMK::OutputAlias< ModelType >, OMK::OutputAlias< OMK::Type::SimpleTypeT< bool > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< float > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< T > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< PrmType > >, OMK::OutputAlias< PrmType >, OMK::OutputAlias< OMK::Type::SimpleTypeT< OMK::Type::Transform > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< HBT::PostureData > >, and OMK::OutputAlias< OMK::Type::SimpleTypeT< Type > >.

Definition at line 372 of file OMKOutput.h.

References OMK::Output< T >::_usedOutput.

Referenced by OMK::OutputAlias< T >::alias(), OMK::OutputAlias< T >::OutputAlias(), and OMK::Output< T >::unsetAlias().

00373 {
00374    /* Thread safety assessement :
00375     * multiple simultaneous access possible, and doesn't compromise thread
00376     * safety : last one out wins
00377     */
00378   _usedOutput = output ;
00379 }

template<typename T>
void OMK::Output< T >::setAlias ( OutputAlias< T > *  output  )  [inline, virtual]

set the direct alias of this output

Definition at line 409 of file OMKOutput.h.

References OMK::Output< T >::_aliasOfOutput.

Referenced by OMK::OutputAlias< T >::alias(), and OMK::OutputAlias< T >::OutputAlias().

00410 {
00411    /* Thread safety assessement :
00412     * multiple simultaneous access possible, but they don't compromise thread
00413     * safety : last one out wins     
00414     */
00415   _aliasOfOutput = output ;
00416 }

template<typename T>
void OMK::Output< T >::unsetAlias (  )  [inline, virtual]

cancel aliasing

Reimplemented in OMK::OutputAlias< T >, OMK::OutputAlias< ModelType >, OMK::OutputAlias< OMK::Type::SimpleTypeT< bool > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< float > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< T > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< PrmType > >, OMK::OutputAlias< PrmType >, OMK::OutputAlias< OMK::Type::SimpleTypeT< OMK::Type::Transform > >, OMK::OutputAlias< OMK::Type::SimpleTypeT< HBT::PostureData > >, and OMK::OutputAlias< OMK::Type::SimpleTypeT< Type > >.

Definition at line 396 of file OMKOutput.h.

References OMK::Output< T >::_aliasOfOutput, and OMK::Output< T >::setUsedOutput().

00397 {
00398   /* Thread safety assessement :
00399    * multiple simultaneous access possible, but they don't compromise thread
00400    * safety : last one out wins     
00401    */
00402   _aliasOfOutput = 0 ;
00403   setUsedOutput( this ) ;
00404 }

template<typename T>
Output< T > * OMK::Output< T >::getUsedOutput (  )  const [inline, virtual]

get the output used by internal get

Definition at line 421 of file OMKOutput.h.

References OMK::Output< T >::_usedOutput.

Referenced by OMK::Output< T >::get(), OMK::Output< T >::insertInStream(), and OMK::Output< T >::printDebuggingInformation().

00422 {
00423    /* Thread safety assessement :
00424     * protected method
00425     * multiple simultaneous access possible, but as long as this method is only
00426     * used onced by each access patern, the OMKOutput stays coherant   
00427     */
00428   return _usedOutput ;
00429 }

template<typename T>
OutputAlias< T > * OMK::Output< T >::getAlias (  )  const [inline, virtual]

get the direct alias of this output

Definition at line 434 of file OMKOutput.h.

References OMK::Output< T >::_aliasOfOutput.

Referenced by OMK::Output< T >::printDebuggingInformation().

00435 {
00436   /* Thread safety assessement :
00437    * protected method
00438    * multiple simultaneous access possible, but as long as this method is only
00439    * used onced by each access patern, the OMKOuptut stays coherant   
00440    */
00441   return _aliasOfOutput ;
00442 }

template<typename T>
void OMK::Output< T >::setValidity ( bool   )  [inline, protected, virtual]

setValidity.

change the validity of the output

Definition at line 384 of file OMKOutput.h.

References OMK::Output< T >::_validity.

Referenced by OMK::Output< T >::empty(), OMK::Output< T >::extract(), OMK::Output< T >::set(), OMK::Output< T >::setInPlace(), OMK::Output< T >::suggest(), OMK::Output< T >::unpack(), and OMK::Output< T >::unpackAllValues().

00385 {
00386   /* Thread safety assessement :
00387    * protected method, used to change protected member : thread safety should
00388    * be insured by callers 
00389    */
00390   _validity = b ;
00391 }

template<typename T>
const T & OMK::Output< T >::localGet ( int validiteRes,
const int  niveauInterpol,
const Date deltaT,
T &  resultPlaceHolder 
) const [protected, virtual]

this is the get that accesses the local history fifo, whether the output is aliased or not

Definition at line 470 of file OMKOutput.h.

References OMK::KernelAttribute::_owner, OMK::Output< T >::_polator, OMK::Output< T >::_validity, OMK::SimulatedObject::getController(), OMK::Controller::getSimulatedDate(), and OMK::KernelAttribute::touch().

00474 {   
00475   /* Thread safety assessement :
00476    * As thread safe as polate from OMKInterplateur. But be careful : in a
00477    * multithreaded environment this member function can generate more
00478    * exceptions than expected 
00479    */
00480   touch() ;
00481   if( !_validity )
00482   {
00483     throw UnInitialisedOutputException( *this, "Output< T >::localGet \n" ) ;
00484   }
00485 
00486 #ifdef _DEBUGTYPEUTIL
00487   std::cerr << "Output< T >::localGet" << std::endl ;
00488   std::cerr << owner.getController().getSimulatedDate() << std::endl ;
00489   std::cerr << "Interpolateur : "<< _polator << std::endl ;
00490 #endif
00491   Date date = _owner.getController().getSimulatedDate() - deltaT ;
00492   return _polator->polate(
00493     niveauInterpol, date, validiteRes, resultPlaceHolder ) ;
00494 }

template<typename T>
void OMK::Output< T >::localInsert ( std::ostream &  = std::cout  )  const [inline, protected, virtual]

an insert that changes the local history fifo

Definition at line 689 of file OMKOutput.h.

References OMK::Output< T >::_history, OMK::KernelAttribute::_owner, OMK::Output< T >::_validity, OMK::Name::getCString(), and OMK::SimulatedObject::getName().

00690 {
00691   /* Thread safety assement
00692    * Thread safe : collides with set on the AbstractFifo. But they should only
00693    * be activated by the owner. So as lmong as the owner isn't multithreaded...
00694    * Nota : in a multithreaded environment this member function could generate
00695    * more exceptions than expected
00696    */
00697   if( !_validity )
00698   {
00699     UnInitialisedOutputException exception( *this,
00700                                             "Output< T >::localInsert\n" ) ;
00701     exception << "Cannot read uninitailised output of "
00702               << _owner.getName().getCString() ;
00703     throw exception ;
00704   }
00705   else 
00706   {
00707     out << *_history << " " ;
00708   }
00709 }


Friends And Related Function Documentation

template<typename T>
friend class OutputAlias< T > [friend]

friend declaration so thah aliases can notify the sensitive inputs connected to their aliased output

Definition at line 205 of file OMKOutput.h.


Member Data Documentation

template<typename T>
OutputAlias< T >* OMK::Output< T >::_aliasOfOutput [protected]

a pointer to the primary alias of this output

Definition at line 218 of file OMKOutput.h.

Referenced by OMK::Output< T >::getAlias(), OMK::Output< T >::setAlias(), OMK::Output< T >::unsetAlias(), and OMK::Output< T >::~Output().

template<typename T>
Output< T >* OMK::Output< T >::_usedOutput [protected]

the output read by get

Definition at line 221 of file OMKOutput.h.

Referenced by OMK::Output< T >::getUsedOutput(), OMK::Output< T >::Output(), and OMK::Output< T >::setUsedOutput().

template<typename T>
AbstractFifo< T >* OMK::Output< T >::_history [protected]

the history storing fifo

Definition at line 224 of file OMKOutput.h.

Referenced by OMK::Output< T >::empty(), OMK::Output< T >::extract(), OMK::Output< T >::get(), OMK::Output< T >::getDateOfLastExactValue(), OMK::Output< T >::getLastExactValue(), OMK::Output< T >::getNextPlaceHolder(), OMK::Output< T >::localInsert(), OMK::Output< T >::Output(), OMK::Output< T >::pack(), OMK::Output< T >::packAllValues(), OMK::Output< T >::printDebuggingInformation(), OMK::Output< T >::printHistory(), OMK::Output< T >::set(), OMK::Output< T >::setInPlace(), OMK::Output< T >::suggest(), OMK::Output< T >::unpack(), OMK::Output< T >::unpackAllValues(), and OMK::Output< T >::~Output().

template<typename T>
const Date& OMK::Output< T >::_date [protected]

a reference to the current date

Definition at line 227 of file OMKOutput.h.

Referenced by OMK::Output< T >::set(), and OMK::Output< T >::setInPlace().

template<typename T>
OMK::Type::Polator< T >* OMK::Output< T >::_polator

the associated polator

Definition at line 231 of file OMKOutput.h.

Referenced by OMK::Output< T >::localGet(), and OMK::Output< T >::Output().

template<typename T>
std::list<Input < T > *> OMK::Output< T >::_listOfConnectedUnsensitiveInputs [protected]

the list of connected unsensitive inputs

Definition at line 235 of file OMKOutput.h.

Referenced by OMK::Output< T >::connectedMyself(), OMK::Output< T >::disconnectedMyself(), and OMK::Output< T >::~Output().

template<typename T>
bool OMK::Output< T >::_validity [protected]

a boolean indicating presence of values in the fifo

Definition at line 245 of file OMKOutput.h.

Referenced by OMK::Output< T >::localGet(), OMK::Output< T >::localInsert(), OMK::Output< T >::pack(), OMK::Output< T >::packAllValues(), OMK::Output< T >::setValidity(), and OMK::Output< T >::suggest().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:02 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007