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 PsInputSensitiveHEADER 00019 #define PsInputSensitiveHEADER 00020 00021 #include <PsInput.h> 00022 #include <PsSensitiveInputAlias.h> 00023 00024 00025 //----------------------------------------------------------------- 00026 00034 template <typename Type> 00035 class PsSensitiveInput : public PsInput <Type>, public PsnSensitiveInputNT 00036 { 00037 public: 00038 00044 PsSensitiveInput (const PsName & inputName, 00045 PsSimulatedObject & owner, 00046 bool makeConnectable, 00047 const int precisionLevel=PsPolatorNT::defaultPrecisionLevel) ; 00048 00049 00052 virtual ~PsSensitiveInput (void) ; 00053 00054 00057 virtual void disconnect () ; 00058 00059 00065 virtual bool valueChanged( bool keepChanged = false ) ; 00066 00067 00070 virtual void signalChange() ; 00071 00072 00073 protected: 00078 virtual bool internalConnect (PsOutputNT * output) ; 00079 00080 00081 } ; // PsSensitiveInput 00082 00083 00084 //----------------------------------------------------------------- 00085 00086 template <typename Type> 00087 PsSensitiveInput<Type>::PsSensitiveInput (const PsName & nom, 00088 PsSimulatedObject & prop, 00089 bool makeConnectable, 00090 const int requestedPrecisionLevel) 00091 : PsInput<Type>(nom, prop, makeConnectable, requestedPrecisionLevel) 00092 { 00093 _changed = true ; 00094 00095 } 00096 00097 00098 00099 template <typename Type> 00100 PsSensitiveInput<Type>::~PsSensitiveInput () 00101 { 00102 #ifdef _DEBUGALIAS 00103 cerr<<"destruction"<<endl; 00104 #endif 00105 disconnect (); 00106 } 00107 00108 template <typename Type> 00109 bool PsSensitiveInput<Type>::valueChanged (bool keepChanged) 00110 { 00111 if (_changed) { 00112 _changed = keepChanged ; 00113 return true; 00114 } 00115 else return false; 00116 } 00117 00119 template <typename Type> 00120 inline void PsSensitiveInput<Type>::signalChange() 00121 { 00122 #ifdef _DEBUGALIAS 00123 cerr<<"PsSensitiveInput<Type>::signalChange()"<<endl; 00124 #endif 00125 _changed = true ; 00126 #ifdef _TYPENAMENOTIMPLICIT 00127 typename 00128 #endif 00129 list<PsInputAlias<Type> *>::iterator i; 00130 for (i = _listOfAliases.begin(); 00131 i != _listOfAliases.end(); 00132 i++) 00133 { 00134 #ifdef _DEBUGALIAS 00135 cerr<<"PsSensitiveInput<Type>::signalChange() : alias going to be notified of change "<<(*i)<<endl; 00136 #endif 00137 PsnSensitiveInputNT * sensitiveInput = dynamic_cast<PsnSensitiveInputNT *>(*i) ; 00138 if ( sensitiveInput != NULL ) 00139 { 00140 sensitiveInput->signalChange(); 00141 } 00142 #ifdef _DEBUGALIAS 00143 cerr<<"PsSensitiveInput<Type>::signalChange() : alias notified of change "<<endl; 00144 #endif 00145 } 00146 } 00147 00148 00149 00150 template <typename Type> 00151 inline void PsSensitiveInput<Type>::disconnect() { 00152 #ifdef _DEBUGALIAS 00153 cerr<<"disconnected output "<<_connectedOutput<<endl; 00154 #endif 00155 if (_connectedOutput!=NULL) { 00156 _connectedOutput->disconnectedMyself(this); 00157 } 00158 #ifdef _DEBUGALIAS 00159 cerr<<"output disconnected"<<endl; 00160 #endif 00161 PsInput<Type>::disconnect (); 00162 } 00163 00164 //----------------------------------------------------------------- 00165 00166 00167 template <typename Type> 00168 inline bool PsSensitiveInput<Type>::internalConnect (PsOutputNT * output) { 00169 if ( PsInput<Type>::realConnect( output ) ) 00170 { 00171 output->connectedMyself (this) ; 00172 return true ; 00173 } 00174 else 00175 { 00176 return false ; 00177 } 00178 } 00179 00180 00181 00182 #endif 00183 00184
| Documentation generated on Mon Nov 25 15:25:02 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |