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 #ifndef PsAbstractInputHEADER 00019 #define PsAbstractInputHEADER 00020 00021 #include <PsSimulatedObject.h> 00022 #include <PsController.h> 00023 #include <PsInputNT.h> 00024 00035 template <class Type> 00036 class PsAbstractInput : public PsInputNT 00037 { 00038 public: 00039 00046 PsAbstractInput (const PsName & inputName, PsSimulatedObject & owner, bool makeConnectable, const int precisionLevel=PsPolatorNT::defaultPrecisionLevel); 00047 00048 00051 virtual ~PsAbstractInput (void) ; 00052 00053 00059 virtual bool connect (const PsName & objectName, const PsName & outputName ) = 0 ; 00060 00061 00067 virtual bool connect (PsSimulatedObject & object, const PsName & outputName ) = 0 ; 00068 00069 00075 virtual bool connect (PsSimulatedObject * pointerToObject, const PsName & outputName ) = 0 ; 00076 00077 00084 virtual bool connect (const PsName & objectName, const PsName & outputName, const Type & initialValue) = 0 ; 00085 00086 00093 virtual bool connect (PsSimulatedObject & object, const PsName & outputName, const Type & initialValue) = 0 ; 00094 00095 00102 virtual bool connect (PsSimulatedObject * pointerToObject, const PsName & outputName, const Type & initialValue) = 0 ; 00103 00104 00110 virtual bool connectToControlParameter (const PsName & objectName, const PsName & controlParameterName ) = 0 ; 00111 00112 00118 virtual bool connectToControlParameter (PsSimulatedObject & object, const PsName & controlParameterName ) = 0 ; 00119 00120 00126 virtual bool connectToControlParameter (PsSimulatedObject * pointerToObject, const PsName & controlParameterName ) = 0 ; 00127 00128 00135 virtual bool connectToControlParameter (const PsName & objectName, const PsName & controlParameterName, const Type & initialValue) = 0 ; 00136 00137 00144 virtual bool connectToControlParameter (PsSimulatedObject & object, const PsName & controlParameterName, const Type & initialValue) = 0 ; 00145 00146 00153 virtual bool connectToControlParameter (PsSimulatedObject * pointerToObject, const PsName & controlParameterName, const Type & initialValue) = 0 ; 00154 00155 00159 virtual bool isConnectable () const ; 00160 00161 00164 virtual void setConnectable (bool nextConnectableState ) ; 00165 00166 00168 virtual const PsOutputNT * getConnectedOutput () const = 0 ; 00169 00170 00172 const PsEventIdentifier & getConnectionEventId () const ; 00173 00174 00176 const PsEventIdentifier & getConnectionToControlParameterEventId () const ; 00177 00178 00183 virtual const Type & get (int deltaT = 0) = 0 ; 00184 00185 00189 virtual int getDistanceToExactValue() const = 0; 00190 00191 00195 virtual const Type & getLastExactValue() const = 0 ; 00196 00197 00201 virtual const PsDate & getDateOfLastExactValue() const = 0 ; 00202 00203 00206 virtual void printDebuggingInformation (ostream & err) const = 0; 00207 00208 00211 virtual int getPrecisionLevel() const ; 00212 00213 00218 virtual int setPrecisionLevel (const int newValue) ; 00219 00220 00224 virtual void notifyAliasing(PsInputAlias<Type> * aliasingInputAlias) ; 00225 00226 00230 virtual void notifyUnaliasing (PsInputAlias<Type> *aliasingInputAlias) ; 00231 00232 00233 protected: 00235 list<PsInputAlias<Type> *> _listOfAliases ; 00236 00238 int _precisionLevel ; 00239 00241 bool _connectable ; 00242 00244 const PsEventIdentifier _connectionEventId ; 00245 00247 const PsEventIdentifier _connectionToControlParameterEventId ; 00248 00249 } ; // PsAbstractInput 00250 00251 00252 //----------------------------------------------------------------- 00253 00254 #include "PsnCurrentActiveObject.h" 00255 00256 00257 template <typename Type> 00258 inline PsAbstractInput<Type>::PsAbstractInput (const PsName & inputName, 00259 PsSimulatedObject & owner, 00260 bool makeConnectable, 00261 const int precisionLevel) 00262 : PsInputNT ( owner, inputName ), 00263 _precisionLevel ( precisionLevel ), 00264 _connectable ( makeConnectable ), 00265 _connectionEventId ( PsString("newConnection ") + inputName ), 00266 _connectionToControlParameterEventId ( PsString("newConnectionToControlParameter ") + inputName ) 00267 { 00268 #ifdef _DEBUGTYPEUTIL 00269 cout << "PsAbstractInput<Type>::PsAbstractInput --> constructeur " << endl; 00270 #endif 00271 registerMe () ; 00272 } 00273 00274 //----------------------------------------------------------------- 00275 00276 template <typename Type> 00277 inline PsAbstractInput<Type>::~PsAbstractInput (void) 00278 { 00279 #ifdef _TYPENAMENOTIMPLICIT 00280 typename 00281 #endif 00282 list<PsInputAlias<Type> *>::iterator i; 00283 for (i=_listOfAliases.begin();i!=_listOfAliases.end();i++) 00284 { 00285 (*i)->inputAliasedDeleted(); 00286 } 00287 } 00288 00289 //----------------------------------------------------------------- 00290 00291 template <typename Type> 00292 inline int PsAbstractInput<Type>::getPrecisionLevel (void) const 00293 { 00294 return _precisionLevel ; 00295 } 00296 00297 //----------------------------------------------------------------- 00298 00299 template <typename Type> 00300 inline int PsAbstractInput<Type>::setPrecisionLevel (const int newValue ) 00301 { 00302 int oldValue = _precisionLevel ; 00303 _precisionLevel = newValue ; 00304 return oldValue ; 00305 } 00306 00307 template <typename Type> 00308 inline void PsAbstractInput<Type>::notifyAliasing (PsInputAlias <Type> * aliasingInputAlias ) 00309 { 00310 if ( aliasingInputAlias != NULL ) 00311 { 00312 _listOfAliases.push_back( aliasingInputAlias ); 00313 } 00314 } 00315 00316 00317 00318 template <typename Type> 00319 inline void PsAbstractInput<Type>::notifyUnaliasing (PsInputAlias <Type> * aliasingInputAlias ) 00320 { 00321 if ( aliasingInputAlias != NULL ) 00322 { 00323 _listOfAliases.push_back( aliasingInputAlias ); 00324 } 00325 } 00326 00327 00328 00329 template <typename Type> 00330 inline bool PsAbstractInput<Type>::isConnectable () const 00331 { 00332 return _connectable ; 00333 } 00334 00335 00336 00337 template <typename Type> 00338 void PsAbstractInput<Type>::setConnectable ( bool newConnectableState ) 00339 { 00340 if ( PsnCurrentActiveObject::getCurrentActiveObject() == & _owner || 00341 PsnCurrentActiveObject::getCurrentActiveObject() == & _owner.getController() || 00342 PsnCurrentActiveObject::getCurrentActiveObject() == NULL ) 00343 { 00344 _connectable = newConnectableState ; 00345 } 00346 else 00347 { 00348 cerr<<"Warning: " 00349 <<_owner.getName() 00350 <<"::" 00351 <<getName() 00352 <<"only the owner can change the the connectable state of an input"<<endl; 00353 } 00354 } 00355 00356 00357 template <typename Type> 00358 inline const PsEventIdentifier & PsAbstractInput<Type>::getConnectionEventId () const 00359 { 00360 return _connectionEventId ; 00361 } 00362 00363 00364 template <typename Type> 00365 inline const PsEventIdentifier & PsAbstractInput<Type>::getConnectionToControlParameterEventId () const 00366 { 00367 return _connectionToControlParameterEventId ; 00368 } 00369 00370 00371 template <typename Type> 00372 inline bool PsAbstractInput<Type>::connect (PsSimulatedObject * pointerToObject, 00373 const PsName & outputName) 00374 { 00375 if ( pointerToObject != NULL ) 00376 { 00377 return connect (*pointerToObject, outputName) ; 00378 } 00379 else 00380 { 00381 cerr<<"PsAbstractInput<Type>::connect : got NULL pointer"<<endl; 00382 printDebuggingInformation ( cerr ) ; 00383 return false ; 00384 } 00385 } 00386 00387 00388 00389 template <typename Type> 00390 inline bool PsAbstractInput<Type>::connect (PsSimulatedObject * pointerToObject, 00391 const PsName & outputName, 00392 const Type & initialValue) 00393 { 00394 if ( pointerToObject != NULL ) 00395 { 00396 return connect (*pointerToObject, outputName, initialValue) ; 00397 } 00398 else 00399 { 00400 cerr<<"PsAbstractInput<Type>::connect : got NULL pointer"<<endl; 00401 printDebuggingInformation ( cerr ) ; 00402 return false ; 00403 } 00404 } 00405 00406 00407 00408 template <typename Type> 00409 inline bool PsAbstractInput<Type>::connectToControlParameter (PsSimulatedObject * pointerToObject, 00410 const PsName & outputName) 00411 { 00412 if ( pointerToObject != NULL ) 00413 { 00414 return connectToControlParameter (*pointerToObject, outputName) ; 00415 } 00416 else 00417 { 00418 cerr<<"PsAbstractInput<Type>::connect : got NULL pointer"<<endl; 00419 printDebuggingInformation ( cerr ) ; 00420 return false ; 00421 } 00422 } 00423 00424 00425 00426 template <typename Type> 00427 inline bool PsAbstractInput<Type>::connectToControlParameter (PsSimulatedObject * pointerToObject, 00428 const PsName & outputName, 00429 const Type & initialValue) 00430 { 00431 if ( pointerToObject != NULL ) 00432 { 00433 return connectToControlParameter (*pointerToObject, outputName, initialValue) ; 00434 } 00435 else 00436 { 00437 cerr<<"PsAbstractInput<Type>::connect : got NULL pointer"<<endl; 00438 printDebuggingInformation ( cerr ) ; 00439 return false ; 00440 } 00441 } 00442 #endif
| Documentation generated on Mon Nov 25 15:24:59 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |