System.hpp

Go to the documentation of this file.
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 #ifndef __SYSTEM_HPP
00032 #define __SYSTEM_HPP
00033 
00034 #include "libecs.hpp"
00035 
00036 #include "Entity.hpp"
00037 
00038 namespace libecs
00039 {
00040 
00041   /** @addtogroup entities
00042    *@{
00043    */
00044 
00045   /** @file */
00046 
00047 
00048   // Maps used for entry lists
00049   DECLARE_MAP( const String, VariablePtr, 
00050                std::less<const String>, VariableMap );
00051   DECLARE_MAP( const String, ProcessPtr,   
00052                std::less<const String>, ProcessMap );
00053   DECLARE_MAP( const String, SystemPtr,    
00054                std::less<const String>, SystemMap );
00055 
00056 
00057   LIBECS_DM_CLASS( System, Entity )
00058   {
00059     
00060   public:
00061 
00062     LIBECS_DM_BASECLASS( System );
00063 
00064     LIBECS_DM_OBJECT( System, System )
00065     {
00066       INHERIT_PROPERTIES( Entity );
00067       
00068       //    PROPERTYSLOT_SET_GET( Real,      Dimension );
00069       PROPERTYSLOT_SET_GET( String,    StepperID );
00070       
00071       PROPERTYSLOT_GET_NO_LOAD_SAVE( Real,      Size );
00072 
00073     }
00074 
00075     System();
00076     virtual ~System();
00077 
00078     virtual const EntityType getEntityType() const
00079     {
00080       return EntityType( EntityType::SYSTEM );
00081     }
00082 
00083     virtual void initialize();
00084 
00085     /**
00086        Get a pointer to a Stepper object that this System belongs.
00087 
00088        @return A pointer to a Stepper object that this System belongs or
00089        NULL pointer if it is not set.
00090     */
00091 
00092     StepperPtr getStepper() const 
00093     { 
00094       return theStepper; 
00095     }
00096 
00097     /**
00098        Set a StepperID.
00099 
00100        This provides a default Stepper to Processes holded by this System.
00101 
00102        @param anID Stepper ID.
00103     */
00104 
00105     SET_METHOD( String, StepperID );
00106 
00107 
00108     /**
00109        Get the default StepperID in this System.
00110 
00111        @return an ID of the Stepper as a String.
00112     */
00113 
00114     GET_METHOD( String, StepperID );
00115 
00116     /**
00117        Get the size of this System in [L] (liter).
00118 
00119        @return Size of this System.
00120     */
00121 
00122     ECELL_API GET_METHOD( Real, Size );
00123 
00124     GET_METHOD( Real, SizeN_A )
00125     {
00126       return getSize() * N_A;
00127     }
00128 
00129     template <class C>
00130       const std::map<const String,C*,std::less<const String> >& getMap() const;
00131     //    {
00132     //      DEFAULT_SPECIALIZATION_INHIBITED();
00133     //    }
00134 
00135     VariableMapCref getVariableMap() const
00136     {
00137       return theVariableMap;
00138     }
00139 
00140     ProcessMapCref  getProcessMap() const
00141     {
00142       return theProcessMap;
00143     }
00144 
00145     SystemMapCref    getSystemMap() const
00146     {
00147       return theSystemMap;
00148     }
00149 
00150 
00151     /**
00152        Find a Process with given id in this System.  
00153        
00154        This method throws NotFound exception if it is not found.
00155 
00156        @return a borrowed pointer to a Process object in this System named @a id.
00157     */
00158 
00159     ProcessPtr getProcess( StringCref anID ) const;
00160 
00161 
00162     /**
00163        Find a Variable with given id in this System. 
00164        
00165        This method throws NotFound exception if it is not found.
00166 
00167        @return a borrowed pointer to a Variable object in this System named @a id.
00168     */
00169 
00170     VariablePtr getVariable( StringCref anID ) const;
00171 
00172     /**
00173        Find a System pointed by the given SystemPath relative to
00174        this System.
00175        
00176        If aSystemPath is empty, this method returns this System.
00177 
00178        If aSystemPath is absolute ( starts with '/' ), this method
00179        calls getSystem() of the Model object, and returns the result.
00180 
00181        This method throws NotFound exception if it is not found.
00182 
00183        @param aSystemPath A SystemPath object.
00184        @return a borrowed pointer to a System object pointed by aSystemPath.
00185     */
00186 
00187     SystemPtr getSystem( SystemPathCref anID ) const;
00188 
00189 
00190     /**
00191        Find a System with a given id in this System. 
00192        
00193        This method throws NotFound exception if it is not found.
00194 
00195        Unlike getSystem( SystemPath ) method, this method searches only
00196        within this System.  In the other words this method doesn't 
00197        conduct a recursive search.
00198 
00199        @param anID An ID string of a System.
00200 
00201        @return a borrowed pointer to a System object in this System
00202        whose ID is anID.
00203     */
00204 
00205     SystemPtr getSystem( StringCref id ) const;
00206 
00207 
00208     /**
00209        Register a Process object in this System.
00210 
00211        This method steals ownership of the given pointer, and deletes
00212        it if there is an error.
00213     */
00214 
00215     void registerProcess( ProcessPtr aProcess );
00216   
00217 
00218     /**
00219        Register a Variable object in this System.
00220 
00221        This method steals ownership of the given pointer, and deletes
00222        it if there is an error.
00223     */
00224 
00225     void registerVariable( VariablePtr aVariable );
00226   
00227 
00228     /**
00229        Register a System object in this System.
00230 
00231        This method steals ownership of the given pointer, and deletes
00232        it if there is an error.
00233     */
00234 
00235     void registerSystem( SystemPtr aSystem );
00236 
00237     /**
00238        Check if this is a root System.
00239 
00240 
00241        @return true if this is a Root System, false otherwise.
00242     */
00243 
00244     bool isRootSystem() const
00245     {
00246       return ( getSuperSystem() == this );
00247     }
00248 
00249     /**
00250        @see Entity::getSystePath()
00251     */
00252 
00253     virtual const SystemPath getSystemPath() const;
00254 
00255 
00256     /**
00257        Get a Model object to which this System belongs.
00258 
00259        @return a borrowed pointer to the Model.
00260     */
00261 
00262     ModelPtr getModel() const
00263     {
00264       return theModel;
00265     }
00266 
00267     void setModel( ModelPtr const aModel )
00268     {
00269       theModel = aModel;
00270     }
00271 
00272     VariableCptr const getSizeVariable() const
00273     {
00274       return theSizeVariable;
00275     }
00276 
00277     void notifyChangeOfEntityList();
00278 
00279     VariableCptr const findSizeVariable() const;
00280 
00281     void configureSizeVariable();
00282 
00283   public: // property slots
00284 
00285     ECELL_API GET_METHOD( Polymorph, SystemList );
00286     ECELL_API GET_METHOD( Polymorph, VariableList );
00287     ECELL_API GET_METHOD( Polymorph, ProcessList );
00288 
00289   protected:
00290 
00291     StepperPtr   theStepper;
00292 
00293   private:
00294 
00295     ModelPtr     theModel;
00296 
00297     VariableMap  theVariableMap;
00298     ProcessMap   theProcessMap;
00299     SystemMap    theSystemMap;
00300 
00301     VariableCptr  theSizeVariable;
00302 
00303     bool         theEntityListChanged;
00304 
00305   };
00306 
00307 
00308 
00309   template <>
00310   inline VariableMapCref System::getMap() const
00311   {
00312     return getVariableMap();
00313   }
00314 
00315   template <>
00316   inline ProcessMapCref   System::getMap() const
00317   {
00318     return getProcessMap();
00319   }
00320 
00321   template <>
00322   inline SystemMapCref    System::getMap() const
00323   {
00324     return getSystemMap();
00325   }
00326 
00327 
00328 
00329   /*@}*/
00330 
00331 } // namespace libecs
00332 
00333 
00334 #endif /* __SYSTEM_HPP */
00335 
00336 
00337 /*
00338   Do not modify
00339   $Author: sachiboo $
00340   $Revision: 2627 $
00341   $Date: 2006-11-24 13:44:30 +0100 (Fri, 24 Nov 2006) $
00342   $Locker$
00343 */

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