LocalSimulatorImplementation.hpp

00001 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00002 //
00003 //        This file is part of E-Cell Simulation Environment package
00004 //
00005 //                Copyright (C) 1996-2002 Keio University
00006 //
00007 //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
00008 //
00009 //
00010 // E-Cell is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2 of the License, or (at your option) any later version.
00014 // 
00015 // E-Cell is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 // See the GNU General Public License for more details.
00019 // 
00020 // You should have received a copy of the GNU General Public
00021 // License along with E-Cell -- see the file COPYING.
00022 // If not, write to the Free Software Foundation, Inc.,
00023 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 // 
00025 //END_HEADER
00026 //
00027 // written by Koichi Takahashi <shafi@e-cell.org>,
00028 // E-Cell Project.
00029 //
00030 
00031 
00032 #ifndef __LOCALSIMULATORIMPLEMENTATION_HPP
00033 #define __LOCALSIMULATORIMPLEMENTATION_HPP
00034 
00035 #include "libecs/libecs.hpp"
00036 #include "libecs/Model.hpp"
00037 
00038 #include "libemc.hpp"
00039 #include "SimulatorImplementation.hpp"
00040 
00041 
00042 namespace libemc
00043 {
00044 
00045   /** @defgroup libemc_module The Libemc Module 
00046    * This is the libemc module 
00047    * @{ 
00048    */ 
00049   
00050   class LocalSimulatorImplementation
00051     :
00052     public SimulatorImplementation
00053   {
00054 
00055   public:
00056 
00057     LocalSimulatorImplementation();
00058     virtual ~LocalSimulatorImplementation();
00059 
00060     virtual void createStepper( libecs::StringCref         aClassname,
00061                                 libecs::StringCref         anId );
00062 
00063     virtual void deleteStepper( libecs::StringCref anID );
00064 
00065     virtual const libecs::Polymorph getStepperList() const;
00066 
00067     virtual const libecs::Polymorph 
00068     getStepperPropertyList( libecs::StringCref aStepperID ) const;
00069 
00070     virtual const libecs::Polymorph 
00071     getStepperPropertyAttributes( libecs::StringCref aStepperID, 
00072                                   libecs::StringCref aPropertyName ) const;
00073 
00074     virtual void setStepperProperty( libecs::StringCref    aStepperID,
00075                                      libecs::StringCref    aPropertyName,
00076                                      libecs::PolymorphCref aValue );
00077 
00078     virtual const libecs::Polymorph
00079     getStepperProperty( libecs::StringCref aStepperID,
00080                         libecs::StringCref aPropertyName ) const;
00081 
00082     virtual void loadStepperProperty( libecs::StringCref    aStepperID,
00083                                       libecs::StringCref    aPropertyName,
00084                                       libecs::PolymorphCref aValue );
00085 
00086     virtual const libecs::Polymorph
00087     saveStepperProperty( libecs::StringCref aStepperID,
00088                          libecs::StringCref aPropertyName ) const;
00089 
00090     virtual const libecs::String
00091     getStepperClassName( libecs::StringCref aStepperID ) const;
00092 
00093 
00094     virtual const libecs::PolymorphMap
00095                  getClassInfo( libecs::StringCref aClasstype,
00096                                libecs::StringCref aClassname,
00097                                const libecs::Integer forceReload );
00098 
00099     
00100     virtual void createEntity( libecs::StringCref aClassname, 
00101                                libecs::StringCref aFullIDString );
00102 
00103     virtual void deleteEntity( libecs::StringCref aFullIDString );
00104 
00105     virtual const libecs::Polymorph 
00106     getEntityList( libecs::StringCref anEntityTypeString,
00107                    libecs::StringCref aSystemPathString ) const;
00108 
00109     virtual const libecs::Polymorph 
00110     getEntityPropertyList( libecs::StringCref aFullID ) const;
00111 
00112     virtual const bool isEntityExist( libecs::StringCref aFullIDString ) const;
00113 
00114     virtual void setEntityProperty( libecs::StringCref    aFullPNString,
00115                                     libecs::PolymorphCref aValue );
00116 
00117     virtual const libecs::Polymorph
00118     getEntityProperty( libecs::StringCref aFullPNString ) const;
00119 
00120     virtual void loadEntityProperty( libecs::StringCref    aFullPNString,
00121                                      libecs::PolymorphCref aValue );
00122 
00123     virtual const libecs::Polymorph
00124     saveEntityProperty( libecs::StringCref aFullPNString ) const;
00125 
00126     virtual const libecs::Polymorph
00127     getEntityPropertyAttributes( libecs::StringCref aFullPNString ) const;
00128 
00129     virtual const libecs::String
00130     getEntityClassName( libecs::StringCref aFullIDString ) const;
00131 
00132     virtual void createLogger( libecs::StringCref aFullPNString );
00133 
00134     virtual void createLogger( libecs::StringCref aFullPNString, libecs::Polymorph aParamList  );
00135 
00136     virtual const libecs::Polymorph getLoggerList() const;
00137 
00138     virtual const libecs::DataPointVectorSharedPtr 
00139     getLoggerData( libecs::StringCref aFullPNString ) const;
00140 
00141     virtual const libecs::DataPointVectorSharedPtr
00142     getLoggerData( libecs::StringCref aFullPNString, 
00143                    libecs::RealCref start, libecs::RealCref end ) const;
00144 
00145     virtual const libecs::DataPointVectorSharedPtr
00146     getLoggerData( libecs::StringCref aFullPNString,
00147                    libecs::RealCref start, libecs::RealCref end, 
00148                    libecs::RealCref interval ) const;
00149 
00150     virtual const libecs::Real 
00151     getLoggerStartTime( libecs::StringCref aFullPNString ) const;
00152 
00153     virtual const libecs::Real 
00154     getLoggerEndTime( libecs::StringCref aFullPNString ) const;
00155 
00156     virtual void setLoggerMinimumInterval( libecs::StringCref aFullPNString, 
00157                                            libecs::RealCref anInterval );
00158 
00159     virtual const libecs::Real 
00160     getLoggerMinimumInterval( libecs::StringCref aFullPNString ) const;
00161 
00162 
00163     virtual void 
00164     setLoggerPolicy( libecs::StringCref aFullPNString, 
00165                               libecs::Polymorph aParamList ) ;
00166 
00167     virtual const libecs::Polymorph
00168     getLoggerPolicy( libecs::StringCref aFullPNString ) const;
00169 
00170 
00171     virtual const libecs::Integer 
00172     getLoggerSize( libecs::StringCref aFullPNString ) const;
00173 
00174     virtual const libecs::Polymorph getNextEvent() const;
00175 
00176     virtual void step( const libecs::Integer aNumSteps );
00177 
00178     virtual const libecs::Real getCurrentTime() const;
00179 
00180     virtual void run();
00181 
00182     virtual void run( const libecs::Real aDuration );
00183 
00184     virtual void stop();
00185 
00186     void clearEventChecker();
00187 
00188     virtual void setEventChecker( EventCheckerSharedPtrCref anEventChecker );
00189 
00190     virtual void setEventHandler( EventHandlerSharedPtrCref anEventHandler );
00191 
00192     virtual const libecs::Polymorph getDMInfo();
00193 
00194   protected:
00195 
00196     libecs::ModelRef getModel() 
00197     { 
00198       return theModel; 
00199     }
00200 
00201     libecs::ModelCref getModel() const 
00202     { 
00203       return theModel; 
00204     }
00205 
00206     void initialize() const;
00207 
00208     libecs::LoggerPtr getLogger( libecs::StringCref aFullPNString ) const;
00209 
00210 
00211     void setDirty()
00212     {
00213       theDirtyFlag = true;
00214     }
00215 
00216     const bool isDirty() const
00217     {
00218       return theDirtyFlag;
00219     }
00220 
00221     inline void handleEvent()
00222     {
00223       if( (*theEventChecker)() )
00224         {
00225           do
00226             {
00227               (*theEventHandler)();
00228             }   while( (*theEventChecker)() );
00229           
00230           clearDirty();
00231         }
00232     }
00233 
00234     void clearDirty() const
00235     {
00236       if( isDirty() )
00237         {
00238           initialize();
00239           // interruptAll();
00240           
00241           theDirtyFlag = false;
00242         }
00243     }
00244 
00245     void start()
00246     {
00247       clearDirty();
00248       theRunningFlag = true;
00249     }
00250 
00251     void runWithEvent();
00252     void runWithoutEvent();
00253 
00254   private:
00255 
00256     bool                       theRunningFlag;
00257 
00258     mutable bool               theDirtyFlag;
00259 
00260     libecs::Integer            theEventCheckInterval;
00261 
00262     libecs::Model              theModel;
00263 
00264     EventCheckerSharedPtr      theEventChecker;
00265     EventHandlerSharedPtr      theEventHandler;
00266 
00267   };  
00268 
00269   /** @} */ //end of libemc_module 
00270 
00271 } // namespace libemc
00272 
00273 
00274 #endif   /* __LOCALSIMULATORIMPLEMENTATION_HPP */

Generated on Fri Aug 31 18:32:07 2007 for E-CELL C++ libraries (libecs and libemc) 3.1.105 by  doxygen 1.5.3