OMKInputAlias.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software
00003  * 
00004  * The Software has been developped within the Siames Project. 
00005  * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights
00006  * 
00007  * The Software has been registered with the Agence pour la Protection des
00008  * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200
00009  *
00010  * This file may be distributed under the terms of the Q Public License
00011  * version 1.0 as defined by Trolltech AS of Norway and appearing in the file
00012  * LICENSE.QPL included in the packaging of this file.
00013  *
00014  * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 
00015  * for the software may use this file in accordance with that specific license 
00016  *
00017  */
00018 
00019 #ifndef InputAliasHEADER
00020 #define InputAliasHEADER
00021 
00022 #include "OMKSimulatedObject.h"
00023 #include "OMKController.h"
00024 #include "OMKInput.h"
00025 #include <iostream>
00026 
00027 namespace OMK
00028 {
00035 template< typename T >
00036 class InputAlias : public AbstractInput< T >
00037 {                            
00038  protected:
00039   using AbstractInput < T >::_owner ;
00040   using AbstractInput < T >::_precisionLevel ;
00041 
00042  public:
00043 
00050    InputAlias( const Name & inputName,
00051                SimulatedObject & owner,
00052                AbstractInput< T > * aliasedInput,
00053                const int requestedPrecisionLevel = OMK::Type::PolatorNT::defaultPrecisionLevel )
00054      : AbstractInput< T >( inputName,
00055                            owner,
00056                            aliasedInput->isConnectable(),
00057                            requestedPrecisionLevel ),
00058        _aliasedInput(  aliasedInput )
00059    {
00060      if( _aliasedInput != 0 )
00061      {
00062        _aliasedInput->notifyAliasing( this ) ;
00063      }
00064      else 
00065      {
00066        OMERROR( "WARNING: InputAlias::InputAlias : aliased input is null " ) ;
00067      }
00068    }
00069 
00071    virtual ~InputAlias()
00072    {
00073      if( _aliasedInput != 0 )
00074      {
00075        _aliasedInput->notifyUnaliasing( this ) ;
00076      }
00077    }
00078 
00082    virtual const T & get( int deltaT = 0 ) ; 
00083    
00087    virtual int getDistanceToExactValue() const ;
00088    
00092    virtual const T & getLastExactValue() const ;
00093 
00094 
00098    virtual const Date & getDateOfLastExactValue() const ;
00099 
00100 
00106    virtual bool connect( const Name & objectName, const Name & outputName ) ;
00107 
00108 
00114    virtual bool connect( SimulatedObject & object, const Name & outputName ) ;
00115 
00116 
00122    virtual bool connect( SimulatedObject * pointerToObject, const Name & outputName ) ;
00123 
00124 
00131    virtual bool connect( const Name & objectName, const Name & outputName, const T & initialValue ) ;
00132 
00133 
00140    virtual bool connect( SimulatedObject & object, const Name & outputName, const T & initialValue ) ;
00141 
00142 
00149    virtual bool connect( SimulatedObject * pointerToObject, const Name & outputName, const T & initialValue ) ;
00150 
00151 
00157    virtual bool connectToControlParameter( const Name & objectName, const Name & controlParameterName ) ;
00158 
00159 
00165    virtual bool connectToControlParameter( SimulatedObject & object, const Name & controlParameterName )  ;
00166 
00167 
00173    virtual bool connectToControlParameter( SimulatedObject * pointerToObject, const Name & controlParameterName ) ;
00174 
00175 
00182    virtual bool connectToControlParameter( const Name & objectName, const Name & controlParameterName, const T & initialValue )  ;
00183 
00184 
00191    virtual bool connectToControlParameter( SimulatedObject & object, const Name & controlParameterName, const T & initialValue )  ;
00192 
00193 
00200    virtual bool connectToControlParameter( SimulatedObject * pointerToObject, const Name & controlParameterName, const T & initialValue ) ;
00201 
00202 
00204    virtual const OutputNT * getConnectedOutput() const ;
00205 
00206 
00209    virtual void disconnect() ;
00210 
00211 
00215    virtual void extract( std::istream & = std::cin ) ;
00216 
00220    virtual void insertInStream( std::ostream & = std::cout ) const ;
00221 
00225    virtual void printDebuggingInformation( std::ostream & err ) const ;
00226   
00231    virtual bool realConnect( OutputNT * output )
00232    {
00233      return _aliasedInput->realConnect( output ) ;
00234    }
00235 
00237    virtual void inputAliasedDeleted() ;
00238 protected:
00239 
00241   AbstractInput< T > * _aliasedInput ;
00242   
00243 } ; // InputAlias
00244 
00245 
00246 //-----------------------------------------------------------------------------
00247 //-----------------------------------------------------------------------------
00248 
00249 
00250 template< typename T >
00251 inline void InputAlias< T >::inputAliasedDeleted()
00252 {
00253   _aliasedInput = 0 ;
00254 }
00255 
00256 //-----------------------------------------------------------------------------
00257 
00258 template< typename T >
00259 inline const T & InputAlias< T >::get( int deltaT )
00260 {
00261 #ifdef _DEBUGTYPEUTIL
00262   std::cout << "InputAlias< T >::localGet calling get of _aliasedInput "
00263             << std::endl ;
00264 #endif
00265   return _aliasedInput->get( deltaT ) ;
00266 }
00267 
00268 //-----------------------------------------------------------------------------
00269 
00270 template< typename T >
00271 inline int InputAlias< T >::getDistanceToExactValue() const
00272 {
00273   return _aliasedInput->getDistanceToExactValue() ;
00274 }
00275 
00276 //-----------------------------------------------------------------------------
00277 
00278 template< typename T >
00279 inline void InputAlias< T >::extract( std::istream & in )
00280 {
00281   _aliasedInput->extract( in ) ;
00282 }
00283 
00284 //-----------------------------------------------------------------------------
00285 
00286 template< typename T >
00287 inline void InputAlias< T >::insertInStream( std::ostream & out ) const
00288 {
00289   _aliasedInput->insertInStream( out ) ;
00290 }
00291 
00292 //-----------------------------------------------------------------------------
00293 
00294 template< typename T >
00295 inline void InputAlias< T >::printDebuggingInformation(
00296   std::ostream & err ) const
00297 {
00298   OMMESSAGE( std::endl
00299              << "**********************************************************"
00300              << std::endl
00301              << "Class InputAlias" << std::endl
00302              << "Owner : " << _owner.getName() << std::endl
00303              << "polation precision level : " << _precisionLevel ) ;
00304 }
00305 
00306 //-----------------------------------------------------------------------------
00307 
00308 template< typename T >
00309 const T & InputAlias< T >::getLastExactValue() const
00310 {
00311   return _aliasedInput->getLastExactValue() ;
00312 }
00313 
00314 //-----------------------------------------------------------------------------
00315 
00316 template< typename T >
00317 const Date & InputAlias< T >::getDateOfLastExactValue() const
00318 {
00319   return _aliasedInput->getDateOfLastExactValue() ;
00320 }
00321 
00322 //-----------------------------------------------------------------------------
00323 
00324 template< typename T >
00325 bool InputAlias< T >::connect( const Name & objectName,
00326                                const Name & outputName )
00327 {
00328   return _aliasedInput->connect( objectName, outputName ) ;
00329 }
00330 
00331 //-----------------------------------------------------------------------------
00332 
00333 template< typename T >
00334 bool InputAlias< T >::connect( SimulatedObject & object,
00335                                const Name & outputName )
00336 {
00337   return _aliasedInput->connect( object, outputName ) ;
00338 }
00339 
00340 //-----------------------------------------------------------------------------
00341 
00342 template< typename T >
00343 bool InputAlias< T >::connect( SimulatedObject * object,
00344                                const Name & outputName )
00345 {
00346   return AbstractInput< T >::connect( object, outputName ) ;
00347 }
00348 
00349 //-----------------------------------------------------------------------------
00350 
00351 template< typename T >
00352 bool InputAlias< T >::connect( const Name & objectName,
00353                                const Name & outputName,
00354                                const T & initialValue )
00355 {
00356   return _aliasedInput->connect( objectName, outputName, initialValue ) ;
00357 }
00358 
00359 //-----------------------------------------------------------------------------
00360 
00361 template< typename T >
00362 bool InputAlias< T >::connect( SimulatedObject & object,
00363                                const Name & outputName,
00364                                const T & initialValue )
00365 {
00366   return _aliasedInput->connect( object, outputName, initialValue ) ;
00367 }
00368 
00369 //-----------------------------------------------------------------------------
00370 
00371 template< typename T >
00372 bool InputAlias< T >::connect( SimulatedObject * object,
00373                                const Name & outputName,
00374                                const T & initialValue )
00375 {
00376   return AbstractInput< T >::connect( object, outputName, initialValue ) ;
00377 }
00378 
00379 //-----------------------------------------------------------------------------
00380 
00381 template< typename T >
00382 bool InputAlias< T >::connectToControlParameter(
00383   const Name & objectName,
00384   const Name & controlParameterName )
00385 {
00386   return _aliasedInput->connectToControlParameter(
00387     objectName, controlParameterName ) ;
00388 }
00389 
00390 //-----------------------------------------------------------------------------
00391 
00392 template< typename T >
00393 bool InputAlias< T >::connectToControlParameter(
00394   SimulatedObject & object,
00395   const Name & controlParameterName )
00396 {
00397   return _aliasedInput->connectToControlParameter(
00398     object, controlParameterName ) ;
00399 }
00400 
00401 //-----------------------------------------------------------------------------
00402 
00403 template< typename T >
00404 bool InputAlias< T >::connectToControlParameter(
00405   SimulatedObject * object,
00406   const Name & controlParameterName )
00407 {
00408   return AbstractInput< T >::connectToControlParameter(
00409     object, controlParameterName ) ;
00410 }
00411 
00412 //-----------------------------------------------------------------------------
00413 
00414 template< typename T >
00415 bool InputAlias< T >::connectToControlParameter(
00416   const Name & objectName,
00417   const Name & controlParameterName,
00418   const T & initialValue )
00419 {
00420   return _aliasedInput->connectToControlParameter(
00421     objectName, controlParameterName, initialValue ) ;
00422 }
00423 
00424 //-----------------------------------------------------------------------------
00425 
00426 template< typename T >
00427 bool InputAlias< T >::connectToControlParameter(
00428   SimulatedObject & object,
00429   const Name & controlParameterName,
00430   const T & initialValue )
00431 {
00432   return _aliasedInput->connectToControlParameter(
00433     object, controlParameterName, initialValue ) ;
00434 }
00435 
00436 //-----------------------------------------------------------------------------
00437 
00438 template< typename T >
00439 bool InputAlias< T >::connectToControlParameter(
00440   SimulatedObject * object,
00441   const Name & controlParameterName,
00442   const T & initialValue )
00443 {
00444   return AbstractInput< T >::connectToControlParameter(
00445     object, controlParameterName, initialValue ) ;
00446 }
00447 
00448 //-----------------------------------------------------------------------------
00449 
00450 template< typename T >
00451 void InputAlias< T >::disconnect()
00452 {
00453   _aliasedInput->disconnect() ;
00454 }
00455 
00456 //-----------------------------------------------------------------------------
00457 
00458 template< typename T >
00459 const OutputNT * InputAlias< T >::getConnectedOutput() const
00460 {
00461   return _aliasedInput->getConnectedOutput() ;
00462 }
00463 
00464 //-----------------------------------------------------------------------------
00465 
00466 } // namespace OMK
00467 
00468 #endif

logo OpenMask

Documentation generated on Mon Jun 9 11:45:56 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007