|
From: <mor...@us...> - 2008-10-19 05:07:07
|
Revision: 3214
http://ecell.svn.sourceforge.net/ecell/?rev=3214&view=rev
Author: moriyoshi
Date: 2008-10-19 05:06:49 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
* API renewal for e-cell 3.2.
* Thoroughly overhauled buggy DM / PropertiedClass ABI:
BACKWARDS BINARY COMPATIBILITY IS LOST.
(source-level compatibility is maintained almost completely)
* Add DynamicModuleDescriptor class that is defined per one dynamic module,
and retains the information and a few set of function pointers that
are required in the instantiation of the dynamic module's class.
* Add DynamicModuleInfo interface by which the meta-information
regarding the dyamic module can be retrieved.
* DMObject::getClassInfo() now returns the pointer to the PropertyInterface
instead of synthesized Polymorph map.
* Make PropertyInterface a subclass of DynamicModuleInfo.
* PropertyInterface singleton objects are now initialized from within the
associated ModuleMaker's constructor, rather than by the static
initializers.
* Add PropertyAttributes class that provides the information about a
property in a type-safe way (used in place of Polymorph).
* Remove PropertyInterface::getPropertyList().
* Add PropertyInterface::getPropertyAttributes().
* DM search paths are now model specific. Remove libecs::setDMSearchPath()
and libecs::getDMSearchPath() and intruduce
libecs::Model::setDMSearchPath() and libecs::Model::getDMSearchPath()
respectively.
* Polymorph refactoring:
* "De-virtualate" Polymorph class and make it refcounted for the sake of
efficiency. Remove ConcretePolymorphValue and PolymorphNoneValue
accordingly.
* Make PolymorphValue hold the extrusive containers for
strings and tuples instead of std::string and std::vector.
* Move enum Polymorph::Type to PolymorphValue.
* Deprecate Polymorph::asTYPE() in favor of Polymorph::as<TYPE>().
* Obsolete features
* Remove CompartmentSystem
Modified Paths:
--------------
ecell3/branches/ecell-3.1/dmtool/DMObject.hpp
ecell3/branches/ecell-3.1/dmtool/DynamicModule.hpp
ecell3/branches/ecell-3.1/dmtool/Makefile.am
ecell3/branches/ecell-3.1/dmtool/ModuleMaker.hpp
ecell3/branches/ecell-3.1/ecell/dm/ExpressionProcessBase.hpp
ecell3/branches/ecell-3.1/ecell/dm/FluxDistributionStepper.cpp
ecell3/branches/ecell-3.1/ecell/dm/GMAProcess.cpp
ecell3/branches/ecell-3.1/ecell/dm/PythonProcessBase.hpp
ecell3/branches/ecell-3.1/ecell/dm/SSystemProcess.cpp
ecell3/branches/ecell-3.1/ecell/dm/TauLeapStepper.cpp
ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/Constants.py
ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/DMInfo.py
ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/ModelStore.py
ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/PropertyEditor.py
ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell3-model-editor
ecell3/branches/ecell-3.1/ecell/frontend/session-monitor/ecell/ui/osogo/opengui.py
ecell3/branches/ecell-3.1/ecell/frontend/session-monitor/ecell3-session-monitor
ecell3/branches/ecell-3.1/ecell/libecs/ContinuousProcess.hpp
ecell3/branches/ecell-3.1/ecell/libecs/DataPoint.hpp
ecell3/branches/ecell-3.1/ecell/libecs/DataPointVector.hpp
ecell3/branches/ecell-3.1/ecell/libecs/DifferentialStepper.hpp
ecell3/branches/ecell-3.1/ecell/libecs/DiscreteEventStepper.cpp
ecell3/branches/ecell-3.1/ecell/libecs/DiscreteEventStepper.hpp
ecell3/branches/ecell-3.1/ecell/libecs/DiscreteTimeStepper.cpp
ecell3/branches/ecell-3.1/ecell/libecs/DiscreteTimeStepper.hpp
ecell3/branches/ecell-3.1/ecell/libecs/DynamicPriorityQueue.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Entity.hpp
ecell3/branches/ecell-3.1/ecell/libecs/EntityType.hpp
ecell3/branches/ecell-3.1/ecell/libecs/EventScheduler.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Exceptions.hpp
ecell3/branches/ecell-3.1/ecell/libecs/FullID.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Interpolant.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Logger.cpp
ecell3/branches/ecell-3.1/ecell/libecs/Logger.hpp
ecell3/branches/ecell-3.1/ecell/libecs/LoggerAdapter.hpp
ecell3/branches/ecell-3.1/ecell/libecs/LoggerBroker.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Makefile.am
ecell3/branches/ecell-3.1/ecell/libecs/MethodProxy.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Model.cpp
ecell3/branches/ecell-3.1/ecell/libecs/Model.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PassiveStepper.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PhysicalLogger.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Polymorph.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Process.cpp
ecell3/branches/ecell-3.1/ecell/libecs/Process.hpp
ecell3/branches/ecell-3.1/ecell/libecs/ProcessEvent.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertiedClass.cpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertiedClass.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertiedObjectMaker.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertyInterface.cpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertyInterface.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertySlot.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertySlotProxy.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertySlotProxyLoggerAdapter.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Stepper.hpp
ecell3/branches/ecell-3.1/ecell/libecs/StepperEvent.hpp
ecell3/branches/ecell-3.1/ecell/libecs/System.hpp
ecell3/branches/ecell-3.1/ecell/libecs/SystemStepper.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Util.hpp
ecell3/branches/ecell-3.1/ecell/libecs/Variable.cpp
ecell3/branches/ecell-3.1/ecell/libecs/Variable.hpp
ecell3/branches/ecell-3.1/ecell/libecs/VariableReference.hpp
ecell3/branches/ecell-3.1/ecell/libecs/convertTo.hpp
ecell3/branches/ecell-3.1/ecell/libecs/libecs.cpp
ecell3/branches/ecell-3.1/ecell/libecs/libecs.hpp
ecell3/branches/ecell-3.1/ecell/libecs/tests/Makefile.am
ecell3/branches/ecell-3.1/ecell/libemc/LocalSimulatorImplementation.cpp
ecell3/branches/ecell-3.1/ecell/libemc/LocalSimulatorImplementation.hpp
ecell3/branches/ecell-3.1/ecell/libemc/Simulator.hpp
ecell3/branches/ecell-3.1/ecell/libemc/SimulatorImplementation.hpp
ecell3/branches/ecell-3.1/ecell/pyecell/ecell/Session.py
ecell3/branches/ecell-3.1/ecell/pyecell/ecell/_ecs.cpp
ecell3/branches/ecell-3.1/ecell/pyecell/ecell/ecs_constants.py
ecell3/branches/ecell-3.1/ecell/pyecell/ecell3-em2eml.in
ecell3/branches/ecell-3.1/ecell/pyecell/ecell3-eml2em.in
ecell3/branches/ecell-3.1/ecell/pyecell/ecell3-eml2sbml.in
ecell3/branches/ecell-3.1/ecell/pyecell/ecell3-sbml2eml.in
ecell3/branches/ecell-3.1/ecell/pyecell/ecell3-session-manager.in
ecell3/branches/ecell-3.1/ecell/pyecell/ecell3-session.in
Added Paths:
-----------
ecell3/branches/ecell-3.1/dmtool/DMException.hpp
ecell3/branches/ecell-3.1/dmtool/DynamicModuleDescriptor.hpp
ecell3/branches/ecell-3.1/dmtool/DynamicModuleInfo.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertyAttributes.hpp
ecell3/branches/ecell-3.1/ecell/libecs/tests/Polymorph_test.cpp
Removed Paths:
-------------
ecell3/branches/ecell-3.1/ecell/libecs/Polymorph.cpp
ecell3/branches/ecell-3.1/ecell/libecs/ProcessMaker.cpp
ecell3/branches/ecell-3.1/ecell/libecs/ProcessMaker.hpp
ecell3/branches/ecell-3.1/ecell/libecs/PropertiedObjectMaker.cpp
ecell3/branches/ecell-3.1/ecell/libecs/StepperMaker.cpp
ecell3/branches/ecell-3.1/ecell/libecs/StepperMaker.hpp
ecell3/branches/ecell-3.1/ecell/libecs/SystemMaker.cpp
ecell3/branches/ecell-3.1/ecell/libecs/SystemMaker.hpp
ecell3/branches/ecell-3.1/ecell/libecs/VariableMaker.cpp
ecell3/branches/ecell-3.1/ecell/libecs/VariableMaker.hpp
Added: ecell3/branches/ecell-3.1/dmtool/DMException.hpp
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/DMException.hpp (rev 0)
+++ ecell3/branches/ecell-3.1/dmtool/DMException.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -0,0 +1,67 @@
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+// This file is part of the E-Cell System
+//
+// Copyright (C) 1996-2008 Keio University
+// Copyright (C) 2005-2008 The Molecular Sciences Institute
+//
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+//
+// E-Cell System is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// E-Cell System is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with E-Cell System -- see the file COPYING.
+// If not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//END_HEADER
+
+#ifndef __DM_EXCEPTION_HPP
+#define __DM_EXCEPTION_HPP
+
+#include <exception>
+#include <string>
+
+/**
+ Exception class for dmtool.
+*/
+class DMException : public std::exception
+{
+public:
+
+ DMException( const std::string& message )
+ :
+ theMessage( message )
+ {
+ ; // do nothing
+ }
+
+ ~DMException() throw()
+ {
+ ; // do nothing
+ }
+
+ /**
+ Get dynamically created exception message.
+ */
+ virtual const char* what() const throw()
+ {
+ return theMessage.c_str();
+ }
+
+private:
+
+ const std::string theMessage;
+
+};
+
+#endif /* __DM_EXCEPTION_HPP */
Property changes on: ecell3/branches/ecell-3.1/dmtool/DMException.hpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: ecell3/branches/ecell-3.1/dmtool/DMObject.hpp
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/DMObject.hpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/dmtool/DMObject.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -28,37 +28,36 @@
#ifndef __DMOBJECT_HPP
#define __DMOBJECT_HPP
-
#ifdef WIN32
#define DM_IF __declspec(dllexport)
#else
#define DM_IF
#endif /* WIN32 */
-/// an allocator function template
+#include "dmtool/DynamicModuleDescriptor.hpp"
-template< class Base, class Derived >
-Base* ObjectAllocator()
-{
- return new Derived;
-}
+#define DM_DESCRIPTOR_ENTRY( CLASSNAME ) \
+ { \
+ #CLASSNAME, \
+ &CLASSNAME::createInstance, \
+ &CLASSNAME::getClassInfoPtr, \
+ &CLASSNAME::initializeModule, \
+ }
-
-
-#define DM_INIT( CLASSNAME, TYPE )\
+#define DM_INIT( CLASSNAME )\
extern "C"\
{\
- DM_IF TYPE::AllocatorFuncPtr CreateObject =\
- &ObjectAllocator<TYPE,CLASSNAME>;\
- DM_IF const char* __DM_CLASSNAME = #CLASSNAME;\
- DM_IF const char* __DM_TYPE = #TYPE;\
- DM_IF const void *(*GetClassInfo)() = &CLASSNAME::getClassInfoPtr;\
+ DM_IF DynamicModuleDescriptor __dm_descriptor = DM_DESCRIPTOR_ENTRY( CLASSNAME ); \
} //
+#define DM_NEW_STATIC( MAKER, BASE, CLASSNAME )\
+ { \
+ static DynamicModuleDescriptor desc = DM_DESCRIPTOR_ENTRY( CLASSNAME ); \
+ ( MAKER )->addClass( new StaticDynamicModule< BASE >( desc ) ); \
+ } //
-#define DM_OBJECT( CLASSNAME, TYPE )\
- static TYPE* createInstance() { return new CLASSNAME ; }\
- static const char *getTypeName() { return #TYPE; }
+#define DM_OBJECT( CLASSNAME )\
+ static void* createInstance() { return new CLASSNAME ; }\
#define DM_BASECLASS( CLASSNAME )\
Modified: ecell3/branches/ecell-3.1/dmtool/DynamicModule.hpp
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/DynamicModule.hpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/dmtool/DynamicModule.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -28,235 +28,175 @@
#ifndef __DYNAMICMODULE_HPP
#define __DYNAMICMODULE_HPP
-#include <exception>
-#include <string>
-#include "ltdl.h"
+#include "dmtool/DMException.hpp"
+#include "dmtool/DynamicModuleDescriptor.hpp"
+#include <ltdl.h>
-#if defined(WIN32) || defined(_WIN32)
-#undef GetClassInfo
-#endif /* _WIN32 */
-
/// doc needed
-#define SimpleAllocator( BASE ) BASE* (*)()
-typedef const void*(*InfoLoaderType)();
-
-/**
- Exception class for dmtool.
-*/
-
-class DMException : public std::exception
+template< typename T >
+struct SimpleAllocatorDef
{
-public:
+ typedef T* (*type)();
+};
- DMException( const std::string& message )
- :
- theMessage( message )
- {
- ; // do nothing
- }
-
- ~DMException() throw()
- {
- ; // do nothing
- }
-
- /**
- Get dynamically created exception message.
- */
-
- const char* what() const throw()
- {
- return theMessage.c_str();
- }
-
-private:
-
- const std::string theMessage;
-
+enum DynamicModuleType
+{
+ DM_TYPE_STATIC,
+ DM_TYPE_SHARED
};
+class DynamicModuleInfo;
+
/**
Common base class of DynamicModule and SharedDynamicModule
*/
-template <class Base,class _TAllocator = SimpleAllocator( Base )>
-class DynamicModuleBase
+template < class T, class _TAllocator = typename SimpleAllocatorDef< T >::type >
+class DynamicModule
{
public:
- typedef _TAllocator DMAllocator;
+ typedef _TAllocator DMAllocator;
+ typedef const char* (DynamicModule::*FileNameGetterType)() const;
+ typedef void (DynamicModule::*FinalizerType)();
-public:
+public:
- DynamicModuleBase( const std::string& moduleName,
- DMAllocator allocator,
- InfoLoaderType infoLoader,
- const std::string& typeName = "" );
- virtual ~DynamicModuleBase(){}
-
- const std::string& getModuleName() const
- {
- return this->theModuleName;
- }
+ DynamicModule( DynamicModuleDescriptor const& desc,
+ enum DynamicModuleType aType,
+ FileNameGetterType aFileNameGetter = 0,
+ FinalizerType aFinalizer = 0 )
+ : theDescriptor( desc ), theFileNameGetter( aFileNameGetter ),
+ theFinalizer( aFinalizer )
+ {
+ desc.moduleInitializer();
+ }
- virtual const std::string getFileName() const
- {
- return "";
- }
+ ~DynamicModule()
+ {
+ if ( theFinalizer )
+ (this->*theFinalizer)();
+ }
- const DMAllocator& getAllocator() const
- {
- return this->theAllocator;
- }
+ const DynamicModuleDescriptor& getDescriptor()
+ {
+ return theDescriptor;
+ }
+
+ const char* getModuleName() const
+ {
+ return theDescriptor.moduleName;
+ }
- const InfoLoaderType& getInfoLoader() const
- {
- return this->theInfoLoader;
- }
+ const char* getFileName() const
+ {
+ return theFileNameGetter ? (this->*theFileNameGetter)(): 0;
+ }
- const std::string getTypeName() const
- {
- return this->theTypeName;
- }
+ DMAllocator getAllocator() const
+ {
+ return reinterpret_cast< DMAllocator >( theDescriptor.allocator );
+ }
+ const DynamicModuleInfo* getInfo() const
+ {
+ return theDescriptor.infoLoader ? (*theDescriptor.infoLoader)(): 0;
+ }
+
+ enum DynamicModuleType getType() const
+ {
+ return theType;
+ }
+
protected:
- const std::string theModuleName;
- DMAllocator theAllocator;
- InfoLoaderType theInfoLoader;
- const std::string theTypeName;
+ DynamicModuleDescriptor const& theDescriptor;
+
+ FileNameGetterType theFileNameGetter;
+
+ FinalizerType theFinalizer;
+
+ enum DynamicModuleType theType;
};
/**
- DynamicModule instantiates objects of a single class.
-*/
-
-template <class Base,class Derived,class DMAllocator = SimpleAllocator( Base )>
-class DynamicModule
- :
- public DynamicModuleBase< Base, DMAllocator >
+ StaticDynamicModule is a class statically linked to the binary
+ that utilizes ModuleMaker
+ */
+template < class T, class DMAllocator = typename SimpleAllocatorDef< T >::type >
+class StaticDynamicModule : public DynamicModule< T, DMAllocator >
{
+public:
+ typedef DynamicModule< T, DMAllocator > Base;
+
public:
- DynamicModule( const std::string& moduleName,
- const std::string& typeName = "" );
- virtual ~DynamicModule(){}
+ StaticDynamicModule( DynamicModuleDescriptor const& desc )
+ : DynamicModule< T, DMAllocator >( desc, DM_TYPE_STATIC )
+ {
+ ; // do nothing
+ }
};
-
-
/**
SharedDynamicModule loads a class from a shared object file
and instantiate objects of the loaded class.
It opens and loads a shared object(.so) file into memory
when constructed. It closes the file when deleted.
- The shared object must have followings:
- - T* CreateObject() - which returns a new object.
- and
- - void* GetClassInfo() - which must be reinterpreted to PolymorphMap in libecs, sorry,
- maybe later a pure string version should be implemented
- - a full set of symbols needed to instantiate and use the class.
-*/
+ The shared object must have the following (in "C" signature):
+ - __dm_info - a DynamicModuleDescriptor
+ which holds the module information.
+ */
-template <class Base,class DMAllocator = SimpleAllocator( Base )>
-class SharedDynamicModule : public DynamicModuleBase< Base >
+template < class T, class DMAllocator = typename SimpleAllocatorDef< T >::type >
+class SharedDynamicModule : public DynamicModule< T, DMAllocator >
{
+public:
+ typedef DynamicModule< T, DMAllocator > Base;
+
public:
- SharedDynamicModule( const std::string& classname, DMAllocator allocator,
- InfoLoaderType infoLoader, const std::string& typeName,
- const std::string& fileName, lt_dlhandle handle );
- virtual ~SharedDynamicModule();
- const std::string getFileName() const;
+ SharedDynamicModule( DynamicModuleDescriptor const& desc,
+ const std::string& fileName,
+ lt_dlhandle handle )
+ : DynamicModule< T, DMAllocator >(
+ desc, DM_TYPE_SHARED,
+ reinterpret_cast< typename Base::FileNameGetterType >(
+ &SharedDynamicModule::getFileName ),
+ reinterpret_cast< typename Base::FinalizerType >(
+ &SharedDynamicModule::finalize ) )
+ {
+ ; // do nothing
+ }
private:
- lt_dlhandle theHandle;
- std::string theFileName;
- std::string theTypeName;
-};
+ void finalize()
+ {
+ if( this->theHandle )
+ {
+ lt_dlclose( this->theHandle );
+ this->theHandle = 0;
+ }
+ }
-/**
- comments needed
-*/
-#define NewDynamicModule( BASE, DERIVED )\
-addClass( new DynamicModule< BASE, DERIVED >( #DERIVED, DERIVED::getTypeName() ) )
-
-/**
- comments needed
-*/
-
-#define NewDynamicModuleWithAllocator( BASE, DERIVED, ALLOC )\
-addClass( new DynamicModule< BASE, DERIVED, ALLOC >( #DERIVED ) )
-
-
-//////////////////////////// begin implementation
-
-template < class Base, class DMAllocator >
-DynamicModuleBase< Base, DMAllocator >::
-DynamicModuleBase( const std::string& moduleName,
- DMAllocator allocator, InfoLoaderType infoLoader,
- const std::string& typeName )
- :
- theModuleName( moduleName ),
- theAllocator( allocator ),
- theInfoLoader( infoLoader ),
- theTypeName( typeName )
-{
- ; // do nothing
-}
-
-template < class Base, class Derived, class DMAllocator >
-DynamicModule< Base, Derived, DMAllocator >::
-DynamicModule( const std::string& moduleName, const std::string& typeName )
- :
- DynamicModuleBase<Base,DMAllocator>( moduleName,
- reinterpret_cast< DMAllocator >(
- &Derived::createInstance ),
- &Derived::getClassInfoPtr,
- typeName )
-{
- ; // do nothing
-}
-
-template < class Base, class DMAllocator >
-SharedDynamicModule< Base, DMAllocator >::
-SharedDynamicModule( const std::string& classname, DMAllocator allocator,
- InfoLoaderType infoLoader, const std::string& typeName,
- const std::string& fileName, lt_dlhandle handle )
- :
- DynamicModuleBase<Base,DMAllocator>( classname, allocator, infoLoader,
- typeName ),
- theFileName( fileName ),
- theHandle( handle )
-{
-}
-
-template < class Base, class DMAllocator >
-SharedDynamicModule<Base,DMAllocator>::~SharedDynamicModule()
-{
-
- if( this->theHandle )
+ const char* getFileName() const
{
- lt_dlclose( this->theHandle );
- this->theHandle = 0;
+ return theFileName.c_str();
}
-}
+private:
+ lt_dlhandle theHandle;
+ std::string theFileName;
+};
-template < class Base, class DMAllocator >
-const std::string SharedDynamicModule<Base,DMAllocator>::getFileName() const
-{
- return this->theFileName;
-}
-
#endif /* __DYNAMICMODULE_HPP */
/*
Added: ecell3/branches/ecell-3.1/dmtool/DynamicModuleDescriptor.hpp
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/DynamicModuleDescriptor.hpp (rev 0)
+++ ecell3/branches/ecell-3.1/dmtool/DynamicModuleDescriptor.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -0,0 +1,49 @@
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+// This file is part of the E-Cell System
+//
+// Copyright (C) 1996-2008 Keio University
+// Copyright (C) 2005-2008 The Molecular Sciences Institute
+//
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+//
+// E-Cell System is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// E-Cell System is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with E-Cell System -- see the file COPYING.
+// If not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//END_HEADER
+
+#ifndef __DYNAMIC_MODULE_DESCRIPTOR_HPP
+#define __DYNAMIC_MODULE_DESCRIPTOR_HPP
+
+#include "dmtool/DynamicModuleInfo.hpp"
+
+/**
+ DynamicModuleDescriptor is a POD class that holds the information about
+ the module.
+ */
+struct DynamicModuleDescriptor
+{
+ typedef void* (*AllocatorType)();
+ typedef const DynamicModuleInfo* (*InfoLoaderType)();
+ typedef void (*ModuleInitializerType)();
+
+ const char* moduleName;
+ AllocatorType allocator;
+ InfoLoaderType infoLoader;
+ ModuleInitializerType moduleInitializer;
+};
+
+#endif /* __DYNAMIC_MODULE_DESCRIPTOR_HPP */
Property changes on: ecell3/branches/ecell-3.1/dmtool/DynamicModuleDescriptor.hpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Added: ecell3/branches/ecell-3.1/dmtool/DynamicModuleInfo.hpp
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/DynamicModuleInfo.hpp (rev 0)
+++ ecell3/branches/ecell-3.1/dmtool/DynamicModuleInfo.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -0,0 +1,57 @@
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+// This file is part of the E-Cell System
+//
+// Copyright (C) 1996-2008 Keio University
+// Copyright (C) 2005-2008 The Molecular Sciences Institute
+//
+//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+//
+//
+// E-Cell System is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// E-Cell System is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with E-Cell System -- see the file COPYING.
+// If not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+//END_HEADER
+
+#ifndef __DYNAMIC_MODULE_INFO_HPP
+#define __DYNAMIC_MODULE_INFO_HPP
+
+#include <string>
+#include <utility>
+
+/**
+ DynamicModuleInfo defines an interface that provides the meta-information
+ that can be used to annotate the module.
+ */
+class DynamicModuleInfo
+{
+public:
+ class EntryIterator
+ {
+ public:
+ virtual ~EntryIterator() {}
+
+ virtual bool next() = 0;
+
+ virtual std::pair< std::string, const void* > current() = 0;
+ };
+
+public:
+ virtual ~DynamicModuleInfo() {}
+ virtual const void* getInfoField( std::string const& aFieldName ) const = 0;
+ virtual EntryIterator* getInfoFields() const = 0;
+};
+
+#endif /* __DYNAMIC_MODULE_INFO_HPP */
Property changes on: ecell3/branches/ecell-3.1/dmtool/DynamicModuleInfo.hpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
Modified: ecell3/branches/ecell-3.1/dmtool/Makefile.am
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/Makefile.am 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/dmtool/Makefile.am 2008-10-19 05:06:49 UTC (rev 3214)
@@ -1,6 +1,12 @@
-AUTOMAKE_OPTIONS=foreign
+AUTOMAKE_OPTIONS = foreign
-pkginclude_HEADERS=DynamicModule.hpp ModuleMaker.hpp DMObject.hpp
+pkginclude_HEADERS = \
+ DynamicModule.hpp\
+ DynamicModuleInfo.hpp\
+ DynamicModuleDescriptor.hpp\
+ DMException.hpp\
+ ModuleMaker.hpp\
+ DMObject.hpp
bin_SCRIPTS = dmcompile
Modified: ecell3/branches/ecell-3.1/dmtool/ModuleMaker.hpp
===================================================================
--- ecell3/branches/ecell-3.1/dmtool/ModuleMaker.hpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/dmtool/ModuleMaker.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -1,9 +1,9 @@
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
-// This file is part of the E-Cell System
+// This file is part of the E-Cell System
//
-// Copyright (C) 1996-2008 Keio University
-// Copyright (C) 2005-2008 The Molecular Sciences Institute
+// Copyright (C) 1996-2008 Keio University
+// Copyright (C) 2005-2008 The Molecular Sciences Institute
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
@@ -31,18 +31,14 @@
#include <iostream>
#include <map>
+#include <set>
#include <string>
-#include <assert.h>
+#include <cassert>
#include "ltdl.h"
#include "DynamicModule.hpp"
-/// doc needed
-
-#define DynamicModuleEntry( T )\
-addClass( new Module( std::string( #T ), &T::createInstance, &T::getClassInfoPtr ) );
-
/**
- A base class for ModuleMakers
+ A base class for ModuleMakers
*/
class ModuleMaker
@@ -50,377 +46,256 @@
public:
- ModuleMaker()
- :
- theNumberOfInstances( 0 )
- {
- ; // do nothing
- }
+ ModuleMaker()
+ {
+ ; // do nothing
+ }
- virtual ~ModuleMaker()
- {
- ; // do nothing
- }
+ virtual ~ModuleMaker()
+ {
+ ; // do nothing
+ }
- static void setSearchPath( const std::string& path )
- {
- int error = lt_dlsetsearchpath( path.c_str() );
- if( error != 0 )
- {
- throw DMException( lt_dlerror() );
- }
- }
+ void setSearchPath( const std::string& path )
+ {
+ theSearchPath.clear();
+ for ( std::string::size_type i( 0 ), end( path.size() ), next( 0 );
+ i < end; i = next + 1 )
+ {
+ next = path.find( PATH_SEPARATOR, i );
+ next = next == std::string::npos ? end: next;
+ if ( next > i )
+ {
+ theSearchPath.insert( path.substr( i, next - i ) );
+ }
+ }
+ }
- static const std::string getSearchPath()
- {
- const char* aSearchPath( lt_dlgetsearchpath() );
- if( aSearchPath == 0 )
- {
- return "";
- }
- else
- {
- return aSearchPath;
- }
- }
+ const std::string getSearchPath() const
+ {
+ typedef std::set< std::string > StringSet;
+ std::string retval;
- /**
- Initializes the dynamic module facility.
- Applications that use this library must call this function
- prior to any operation involved with the facility.
- @return true on error, false otherwise.
- */
- static bool initialize()
- {
- return lt_dlinit() > 0 ? true: false;
- }
+ for ( StringSet::const_iterator i( theSearchPath.begin() );
+ i != theSearchPath.end(); ++i )
+ {
+ retval += (*i);
+ retval += PATH_SEPARATOR;
+ }
+ if ( !retval.empty() )
+ retval.resize( retval.size() - 1 );
+ return retval;
+ }
- /**
- Finalizes the dynamic module facility.
- Applications that use this library must call this function when
- the facility is no longer necessary so that allocated resources
- can be reclaimed.
- @return true on error, false otherwise.
- */
- static void finalize()
- {
- lt_dlexit();
- }
+ /**
+ Initializes the dynamic module facility.
+ Applications that use this library must call this function
+ prior to any operation involved with the facility.
+ @return true on error, false otherwise.
+ */
+ static bool initialize()
+ {
+ if ( lt_dlinit() > 0 )
+ return true;
- /**
- @return the number of instance this have ever created
- */
+ if ( lt_dlsetsearchpath("") > 0 )
+ {
+ lt_dlexit();
+ return true;
+ }
- int getNumberOfInstances() const
- {
- return theNumberOfInstances;
- }
+ return false;
+ }
-protected:
+ /**
+ Finalizes the dynamic module facility.
+ Applications that use this library must call this function when
+ the facility is no longer necessary so that allocated resources
+ can be reclaimed.
+ @return true on error, false otherwise.
+ */
+ static void finalize()
+ {
+ lt_dlexit();
+ }
- int theNumberOfInstances;
+public:
+ static const char PATH_SEPARATOR = LT_PATHSEP_CHAR;
+protected:
+
+ std::set< std::string > theSearchPath;
};
/**
- StaticModuleMaker is used to instantiate
- various subclasses of certain template parameter class T.
+ StaticModuleMaker is used to instantiate
+ various subclasses of certain template parameter class T.
*/
-template<class T, class DMAllocator = SimpleAllocator( T )>
-class StaticModuleMaker
- :
- public ModuleMaker
+template<class T, class DMAllocator = typename SimpleAllocatorDef< T >::type >
+class StaticModuleMaker : public ModuleMaker
{
public:
- typedef DynamicModuleBase<T,DMAllocator> Module;
- typedef std::map<const std::string, Module*> ModuleMap;
- typedef typename ModuleMap::iterator ModuleMapIterator;
+ typedef DynamicModule<T, DMAllocator> Module;
+ typedef std::map<const std::string, Module*> ModuleMap;
+ typedef typename ModuleMap::iterator ModuleMapIterator;
public:
- StaticModuleMaker();
- virtual ~StaticModuleMaker();
+ StaticModuleMaker()
+ {
+ ; // do nothing
+ }
- /**
- Instantiates given class of an object.
-
- @param classname name of class to be instantiated.
- @return pointer to a new instance.
- */
+ virtual ~StaticModuleMaker()
+ {
+ for( ModuleMapIterator i = this->theModuleMap.begin();
+ i != this->theModuleMap.end(); ++i )
+ {
+ delete i->second;
+ }
+ }
- virtual T* make( const std::string& aClassname );
+ virtual const Module& getModule( const std::string& aClassName, bool forceReload = false )
+ {
+ if ( this->theModuleMap.find( aClassName ) == this->theModuleMap.end() )
+ {
+ throw DMException( "Can't find module [" + aClassName + "]." );
+ }
+ return *this->theModuleMap[ aClassName ];
+ }
- virtual const Module& getModule( const std::string& aClassName, bool forceReload )
- {
- if( this->theModuleMap.find( aClassName ) == this->theModuleMap.end() )
- {
- throw DMException( "Can't find static module [" + aClassName + "]." );
- }
-
- return (*this->theModuleMap[ aClassName ]);
+ /**
+ Add a class to the subclass list.
+ @param dm a pointer to a DynamicModule to be added
+ */
+ void addClass( Module* dm )
+ {
+ assert( dm != NULL && dm->getModuleName() != NULL );
+ this->theModuleMap[ dm->getModuleName() ] = dm;
+ }
- }
+ const ModuleMap& getModuleMap() const
+ {
+ return theModuleMap;
+ }
-
- /**
- Add a class to the subclass list.
- @param dm a pointer to a DynamicModule to be added
- */
-
- void addClass( Module* dm );
-
- const ModuleMap& getModuleMap() const
- {
- return theModuleMap;
- }
-
protected:
- /*!
- This is only for internal use. Use public make() method.
-
- \param classname name of the class to be instantiated.
- \return pointer to a new instance.
- */
+ ModuleMap theModuleMap;
- virtual DMAllocator getAllocator( const std::string& aClassname );
-
-
-protected:
-
- ModuleMap theModuleMap;
-
};
/**
- SharedModuleMaker dynamically instantiates various classes of
- objects encapsulated in shared object(.so) file.
- @sa StaticClassModuleMaker, SharedDynamicModule
+ SharedModuleMaker dynamically instantiates various classes of
+ objects encapsulated in shared object(.so) file.
+ @sa StaticClassModuleMaker, SharedDynamicModule
*/
-template<class T,class DMAllocator=SimpleAllocator( T )>
-class SharedModuleMaker
- :
- public StaticModuleMaker<T,DMAllocator>
+template<class T, class DMAllocator = typename SimpleAllocatorDef< T >::type >
+class SharedModuleMaker : public StaticModuleMaker< T, DMAllocator >
{
-
public:
+ typedef StaticModuleMaker< T, DMAllocator > Base;
+ typedef DynamicModule< T, DMAllocator > Module;
+ typedef SharedDynamicModule< T, DMAllocator > SharedModule;
- typedef SharedDynamicModule<T> SharedModule;
-
- SharedModuleMaker();
- virtual ~SharedModuleMaker();
-
- virtual const SharedModule& getModule( const std::string& aClassName, bool forceReload )
- {
-
- if ( forceReload )
- {
- typename StaticModuleMaker<T,DMAllocator>::ModuleMapIterator i ( this->theModuleMap.find( aClassName) );
- if( i != this->theModuleMap.end() )
- {
- delete i->second;
- this->theModuleMap.erase( i );
- }
+ SharedModuleMaker()
+ {
+ ; // do nothing
}
- if( this->theModuleMap.find( aClassName ) == this->theModuleMap.end() )
- {
- loadModule( aClassName );
- }
- return *((SharedModule*) this->theModuleMap[ aClassName ]);
-
- }
-
-
-protected:
-
-
- virtual DMAllocator getAllocator( const std::string& aClassname );
-
- void loadModule( const std::string& aClassname );
-
-
-};
-
-
-///////////////////////////// begin implementation
-
-
-
-
-////////////////////// StaticModuleMaker
-
-template<class T,class DMAllocator>
-StaticModuleMaker<T,DMAllocator>::StaticModuleMaker()
-{
- ; // do nothing
-}
-
-template<class T,class DMAllocator>
-StaticModuleMaker<T,DMAllocator>::~StaticModuleMaker()
-{
- for( ModuleMapIterator i = this->theModuleMap.begin();
- i != this->theModuleMap.end(); ++i )
+ virtual ~SharedModuleMaker()
{
- delete i->second;
+ ; // do nothing
}
-}
-template<class T, class DMAllocator>
-T* StaticModuleMaker<T,DMAllocator>::make( const std::string& aClassname )
-{
-
- DMAllocator anAllocator( getAllocator( aClassname ) );
- if( !anAllocator )
+ virtual const Module& getModule( const std::string& aClassName, bool forceReload = false )
{
- throw DMException( std::string( "unexpected error in " ) +
- __PRETTY_FUNCTION__ );
- }
+ if ( forceReload )
+ {
+ typename Base::ModuleMap::iterator i( this->theModuleMap.find( aClassName ) );
+ if ( i != this->theModuleMap.end() &&
+ (*i).second->getType() == DM_TYPE_SHARED )
+ {
+ this->theModuleMap.erase( i );
+ delete i->second;
+ }
+ }
- T* anInstance( 0 );
- anInstance = anAllocator();
+ if ( this->theModuleMap.find( aClassName ) == this->theModuleMap.end() )
+ {
+ loadModule( aClassName );
+ }
- if( !anInstance )
- {
- throw DMException( "Can't instantiate [" + aClassname + "]." );
+ return *this->theModuleMap[ aClassName ];
}
- ++(this->theNumberOfInstances);
- return anInstance;
-}
-
-
-template<class T,class DMAllocator>
-void StaticModuleMaker<T,DMAllocator>::addClass( Module* dm )
-{
- assert( dm );
-
- this->theModuleMap[ dm->getModuleName() ] = dm;
-}
-
-
-
-
-template<class T,class DMAllocator>
-DMAllocator StaticModuleMaker<T,DMAllocator>::
-getAllocator( const std::string& aClassname )
-{
- if( this->theModuleMap.find( aClassname ) == this->theModuleMap.end() )
+protected:
+ void loadModule( const std::string& aClassname )
{
- throw DMException( "Class [" + aClassname + "] not found." );
- }
+ typedef std::set< std::string > StringSet;
- return this->theModuleMap[ aClassname ]->getAllocator();
-}
+ std::string filename;
+ lt_dlhandle handle( 0 );
+ {
+ std::string error;
-////////////////////// SharedModuleMaker
+ for ( StringSet::const_iterator i( this->theSearchPath.begin() );
+ i != this->theSearchPath.end(); ++i )
+ {
+ filename = (*i) + '/' + aClassname;
+ handle = lt_dlopenext( filename.c_str() );
+ if ( handle )
+ {
+ break;
+ }
+ if ( error.empty() )
+ {
+ error = lt_dlerror();
+ }
+ else
+ {
+ if ( error != lt_dlerror() )
+ {
+ error = "various reasons";
+ }
+ }
+ }
-template<class T,class DMAllocator>
-SharedModuleMaker<T,DMAllocator>::SharedModuleMaker()
-{
-}
+ if ( !handle )
+ {
+ throw DMException( "Failed to find or load a DM ["
+ + aClassname + "]: " + error );
+ }
+ }
-template<class T,class DMAllocator>
-SharedModuleMaker<T,DMAllocator>::~SharedModuleMaker()
-{
-}
+ DynamicModuleDescriptor* desc(
+ reinterpret_cast< DynamicModuleDescriptor* >(
+ lt_dlsym( handle, "__dm_descriptor" ) ) );
+ if ( !desc )
+ {
+ throw DMException( "[" + filename + "] is not a valid DM file." );
+ }
-
-template<class T,class DMAllocator>
-DMAllocator SharedModuleMaker<T,DMAllocator>::
-getAllocator( const std::string& aClassname )
-{
- DMAllocator anAllocator( 0 );
-
- try
- {
- anAllocator =
- StaticModuleMaker<T,DMAllocator>::getAllocator( aClassname );
+ addClass( new SharedModule( *desc, filename, handle ) );
}
- catch( DMException& )
- {
- // load module file and try again
- loadModule( aClassname );
- anAllocator =
- StaticModuleMaker<T,DMAllocator>::getAllocator( aClassname );
- }
+};
- if( !anAllocator )
- {
- // getAllocator() returned NULL! why?
- throw DMException( std::string( "unexpected error in " )
- + __PRETTY_FUNCTION__ );
- }
-
- return anAllocator;
-}
-
-template<class T,class DMAllocator>
-void
-SharedModuleMaker<T,DMAllocator>::loadModule( const std::string& aClassname )
-{
- // return immediately if already loaded
- if( this->theModuleMap.find( aClassname ) != this->theModuleMap.end() )
- {
- return;
- }
-
- SharedModule* aSharedModule( 0 );
- std::string filename( aClassname );
- lt_dlhandle handle( lt_dlopenext( filename.c_str() ) );
- if ( !handle )
- {
- throw DMException( "Failed to find or load a DM [" + aClassname +
- "]: " + lt_dlerror() );
- }
- typename SharedModule::DMAllocator* anAllocatorPtr( 0 );
- InfoLoaderType* anInfoLoaderPtr( 0 );
- const char** typeStringPtr = 0;
-
- anAllocatorPtr = reinterpret_cast< DMAllocator* >(
- lt_dlsym( handle, "CreateObject" ) );
- if (!anAllocatorPtr)
- goto fail_dlsym;
-
- anInfoLoaderPtr = reinterpret_cast< InfoLoaderType* >(
- lt_dlsym( handle, "GetClassInfo" ) );
- if ( !anInfoLoaderPtr )
- goto fail_dlsym;
-
- typeStringPtr = reinterpret_cast< const char ** >(
- lt_dlsym( handle, "__DM_TYPE" ) );
- if ( !typeStringPtr )
- goto fail_dlsym;
-
- if ( !*anAllocatorPtr || !*anInfoLoaderPtr || !*typeStringPtr )
- {
- throw DMException( "[" + filename + "] is not a valid DM file." );
- }
-
- addClass( new SharedModule( aClassname, *anAllocatorPtr, *anInfoLoaderPtr,
- *typeStringPtr, filename, handle ) );
- return;
-fail_dlsym:
- throw DMException( "[" + filename + "] is not a valid DM file ("
- + lt_dlerror() + ")" );
-}
-
#endif /* __MODULEMAKER_HPP */
/*
- Do not modify
- $Author$
- $Revision$
- $Date$
- $Locker$
+ Do not modify
+ $Author$
+ $Revision$
+ $Date$
+ $Locker$
*/
Modified: ecell3/branches/ecell-3.1/ecell/dm/ExpressionProcessBase.hpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/dm/ExpressionProcessBase.hpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/dm/ExpressionProcessBase.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -125,7 +125,16 @@
void defaultSetProperty( StringCref aPropertyName,
PolymorphCref aValue )
{
- thePropertyMap[ aPropertyName ] = aValue.asReal();
+ PropertyMapIterator i( thePropertyMap.find( aPropertyName ) );
+ if ( i == thePropertyMap.end() )
+ {
+ thePropertyList.push_back( aPropertyName );
+ thePropertyMap.insert( std::make_pair( aPropertyName, aValue.asReal() ) );
+ }
+ else
+ {
+ i->second = aValue.asReal();
+ }
}
const Polymorph defaultGetProperty( StringCref aPropertyName ) const
@@ -139,40 +148,22 @@
}
else
{
- THROW_EXCEPTION( NoSlot, getClassNameString() +
+ THROW_EXCEPTION( NoSlot, getClassName() +
" : Property [" + aPropertyName +
"] is not defined " );
}
}
- const Polymorph defaultGetPropertyList() const
+ const StringVector& defaultGetPropertyList() const
{
- PolymorphVector aVector;
-
- for( PropertyMapConstIterator
- aPropertyMapIterator( thePropertyMap.begin() );
- aPropertyMapIterator != thePropertyMap.end();
- ++aPropertyMapIterator )
- {
- aVector.push_back( aPropertyMapIterator->first );
- }
-
- return aVector;
+ return thePropertyList;
}
- const Polymorph
+ const PropertyAttributes
defaultGetPropertyAttributes( StringCref aPropertyName ) const
{
- PolymorphVector aVector;
-
- Integer aPropertyFlag( 1 );
-
- aVector.push_back( aPropertyFlag ); // isSetable
- aVector.push_back( aPropertyFlag ); // isGetable
- aVector.push_back( aPropertyFlag ); // isLoadable
- aVector.push_back( aPropertyFlag ); // isSavable
-
- return aVector;
+ return PropertyAttributes( PropertySlotBase::REAL,
+ true, true, true, true, true );
}
@@ -220,6 +211,8 @@
bool theRecompileFlag;
PropertyMap thePropertyMap;
+
+ StringVector thePropertyList;
};
Modified: ecell3/branches/ecell-3.1/ecell/dm/FluxDistributionStepper.cpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/dm/FluxDistributionStepper.cpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/dm/FluxDistributionStepper.cpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -108,7 +108,7 @@
catch( const libecs::TypeError& )
{
THROW_EXCEPTION( InitializationFailed,
- getClassNameString() +
+ getClassName() +
": Only QuasiDynamicFluxProcesses are allowed to exist "
"in this Stepper." );
}
Modified: ecell3/branches/ecell-3.1/ecell/dm/GMAProcess.cpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/dm/GMAProcess.cpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/dm/GMAProcess.cpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -189,7 +189,7 @@
void GMAProcess::setGMASystemMatrix( PolymorphCref aValue )
{
GMASystemMatrix = aValue;
- PolymorphVector aValueVector( aValue.asPolymorphVector() );
+ PolymorphVector aValueVector( aValue.as<PolymorphVector>() );
theSystemSize = aValueVector.size();
theLawSize = theSystemSize + 1;
@@ -260,18 +260,18 @@
for( Integer j( 0 ); j < theSystemSize; j++ )
{
- theAlpha[i+1][j+1] = (aValueVector[i].asPolymorphVector())[j].asReal() ;
+ theAlpha[i+1][j+1] = (aValueVector[i].as<PolymorphVector>())[j].as<Real>() ;
//std::cout <<'A'<< theAlpha[i+1][j+1]<<std::endl;
for (Integer k( 0 ); k < theSystemSize; k++)
{
if( i == k )
{
- (theG[i+1])[j+1][k+1] = ((aValueVector[i].asPolymorphVector())[theSystemSize + j ].asPolymorphVector())[k].asReal() -1;
+ (theG[i+1])[j+1][k+1] = ((aValueVector[i].as<PolymorphVector>())[theSystemSize + j ].as<PolymorphVector>())[k].as<Real>() -1;
//std::cout <<" G"<<theG[i+1][j+1][k+1];
}else{
- (theG[i+1])[j+1][k+1] = ((aValueVector[i].asPolymorphVector())[theSystemSize + j ].asPolymorphVector())[k].asReal();
+ (theG[i+1])[j+1][k+1] = ((aValueVector[i].as<PolymorphVector>())[theSystemSize + j ].as<PolymorphVector>())[k].as<Real>();
//std::cout <<" G"<<theG[i+1][j+1][k+1];
}
// std::cout <<std::endl;
Modified: ecell3/branches/ecell-3.1/ecell/dm/PythonProcessBase.hpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/dm/PythonProcessBase.hpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/dm/PythonProcessBase.hpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -97,10 +97,18 @@
void defaultSetProperty( StringCref aPropertyName,
PolymorphCref aValue )
{
+ PropertyMapIterator i( thePropertyMap.find( aPropertyName ) );
+ if ( i == thePropertyMap.end() )
+ {
+ thePropertyList.push_back( aPropertyName );
+ thePropertyMap.insert( std::make_pair( aPropertyName, aValue ) );
+ }
+ else
+ {
+ i->second = aValue;
+ }
theLocalNamespace[ aPropertyName ] =
python::object( python::handle<>( PyFloat_FromDouble( aValue ) ) );
-
- thePropertyMap[ aPropertyName ] = aValue;
}
const Polymorph defaultGetProperty( StringCref aPropertyName ) const
@@ -114,39 +122,21 @@
}
else
{
- THROW_EXCEPTION( NoSlot, getClassNameString() + " : Property [" +
+ THROW_EXCEPTION( NoSlot, getClassName() + " : Property [" +
aPropertyName + "] is not defined" );
}
}
- const Polymorph defaultGetPropertyList() const
+ const StringVector& defaultGetPropertyList() const
{
- PolymorphVector aVector;
-
- for( PropertyMapConstIterator
- aPropertyMapIterator( thePropertyMap.begin() );
- aPropertyMapIterator != thePropertyMap.end();
- ++aPropertyMapIterator )
- {
- aVector.push_back( aPropertyMapIterator->first );
- }
-
- return aVector;
+ return thePropertyList;
}
- const Polymorph
+ const PropertyAttributes
defaultGetPropertyAttributes( StringCref aPropertyName ) const
{
- PolymorphVector aVector;
-
- Integer aPropertyFlag( 1 );
-
- aVector.push_back( aPropertyFlag ); //isSetable
- aVector.push_back( aPropertyFlag ); //isGetable
- aVector.push_back( aPropertyFlag ); //isLoadable
- aVector.push_back( aPropertyFlag ); //isSavable
-
- return Polymorph( aVector );
+ return PropertyAttributes( PropertySlotBase::POLYMORPH,
+ true, true, true, true, true );
}
virtual void initialize();
@@ -157,6 +147,8 @@
python::dict theLocalNamespace;
PropertyMap thePropertyMap;
+
+ StringVector thePropertyList;
};
Modified: ecell3/branches/ecell-3.1/ecell/dm/SSystemProcess.cpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/dm/SSystemProcess.cpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/dm/SSystemProcess.cpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -172,7 +172,7 @@
SET_METHOD_DEF( Polymorph, SSystemMatrix, SSystemProcess )
{
SSystemMatrix = value;
- PolymorphVector aValueVector( value.asPolymorphVector() );
+ PolymorphVector aValueVector( value.as<PolymorphVector>() );
theSystemSize = aValueVector.size();
// init Substance Vector
@@ -232,25 +232,25 @@
for( int i( 0 ); i < theSystemSize; i++ )
{
- theAlpha[i+1] = (aValueVector[i].asPolymorphVector())[0].asReal() ;
+ theAlpha[i+1] = (aValueVector[i].as<PolymorphVector>())[0].as<Real>() ;
for( int j( 0 ); j < theSystemSize; j++ )
{
if( i == j )
{
- (theG[i+1])[j+1] = (aValueVector[i].asPolymorphVector())[j+1].asReal() - 1 ;
+ (theG[i+1])[j+1] = (aValueVector[i].as<PolymorphVector>())[j+1].as<Real>() - 1 ;
}else{
- (theG[i+1])[j+1] = (aValueVector[i].asPolymorphVector())[j+1].asReal() ;
+ (theG[i+1])[j+1] = (aValueVector[i].as<PolymorphVector>())[j+1].as<Real>() ;
}
}
- theBeta[i+1] = (aValueVector[i].asPolymorphVector())[1+theSystemSize].asReal() ;
+ theBeta[i+1] = (aValueVector[i].as<PolymorphVector>())[1+theSystemSize].as<Real>() ;
for( int j( 0 ); j < theSystemSize; j++ )
{
if( i == j )
{
- (theH[i+1])[j+1] = (aValueVector[i].asPolymorphVector())[2+j+theSystemSize].asReal() -1 ;
+ (theH[i+1])[j+1] = (aValueVector[i].as<PolymorphVector>())[2+j+theSystemSize].as<Real>() -1 ;
}else{
- (theH[i+1])[j+1] = (aValueVector[i].asPolymorphVector())[2+j+theSystemSize].asReal() ;
+ (theH[i+1])[j+1] = (aValueVector[i].as<PolymorphVector>())[2+j+theSystemSize].as<Real>() ;
}
}
}
Modified: ecell3/branches/ecell-3.1/ecell/dm/TauLeapStepper.cpp
===================================================================
--- ecell3/branches/ecell-3.1/ecell/dm/TauLeapStepper.cpp 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/dm/TauLeapStepper.cpp 2008-10-19 05:06:49 UTC (rev 3214)
@@ -50,7 +50,7 @@
catch( const libecs::TypeError& )
{
THROW_EXCEPTION( InitializationFailed,
- getClassNameString() +
+ getClassName() +
": Only GillespieProcesses are allowed to exist "
"in this Stepper." );
}
Modified: ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/Constants.py
===================================================================
--- ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/Constants.py 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/Constants.py 2008-10-19 05:06:49 UTC (rev 3214)
@@ -140,13 +140,11 @@
DM_PROPERTY_STRING = "STRING"
DM_PROPERTY_MULTILINE = "MULTILINE"
-DM_PROPERTY_NESTEDLIST = "NESTED_LIST"
+DM_PROPERTY_POLYMORPH = "POLYMORPH"
DM_PROPERTY_INTEGER = "INTEGER"
DM_PROPERTY_FLOAT = "FLOAT"
-DM_SYSTEM_CLASS_OLD = 'CompartmentSystem'
DM_SYSTEM_CLASS = 'System'
-
DM_VARIABLE_CLASS = 'Variable'
Modified: ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/DMInfo.py
===================================================================
--- ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/DMInfo.py 2008-10-14 10:12:22 UTC (rev 3213)
+++ ecell3/branches/ecell-3.1/ecell/frontend/model-editor/ecell/ui/model_editor/DMInfo.py 2008-10-19 05:06:49 UTC (rev 3214)
@@ -29,7 +29,8 @@
import os.path
import sys
-import ecell.emc
+import ecell.ecs
+from ecell.ecs_constants import *
from ecell.ui.model_editor.Config import *
from ecell.ui.model_editor.Constants import *
@@ -42,23 +43,28 @@
MASTERLIST_FLAGS = 4
-DM_TRANSLATIONLIST={ "Real":DM_PROPERTY_FLOAT,
- "Integer":DM_PROPERTY_INTEGER,
- "String":DM_PROPERTY_STRING,
- "Polymorph":DM_PROPERTY_NESTEDLIST }
+DM_TRANSLATIONLIST = {
+ PROPERTY_TYPE_REAL: DM_PROPERTY_FLOAT,
+ PROPERTY_TYPE_INTEGER: DM_PROPERTY_INTEGER,
+ PROPERTY_TYPE_STRING: DM_PROPERTY_STRING,
+ PROPERTY_TYPE_POLYMORPH: DM_PROPERTY_POLYMORPH
+ }
-DM_DEFAULTVALUES = { DM_PROPERTY_FLOAT : 0.0,
- DM_PROPERTY_INTEGER: 0,
- DM_PROPERTY_STRING:"",
- DM_PROPERTY_NESTEDLIST: [] }
+DM_DEFAULTVALUES = {
+ PROPERTY_TYPE_REAL: 0.0,
+ PROPERTY_TYPE_INTEGER: 0,
+ PROPERTY_TYPE_STRING:"",
+ PROPERTY_TYPE_POLYMORPH: []
+ }
-INFO_TYPE = 0
-INFO_SETTABLE = 1
-INFO_GETTABLE = 2
-INFO_LOADABLE = 3
-INFO_SAVEABLE = 4
-INFO_DEFAULT_VALUE = 5
+INFO_SETTABLE = 0
+INFO_GETTABLE = 1
+INFO_LOADABLE = 2
+INFO_SAVEABLE = 3
+INFO_DYNAMIC = 4
+INFO_TYPE = 5
+INFO_DEFAULT_VALUE = 6
TESTCODE ='\
if mode == "instantiate":\n\
@@ -81,7 +87,7 @@
pass\n\
else:\n\
try:\n\
- theSimulator.getClassInfo( aType, aClass )\n\
+ theSimulator.getClassInfo( aClass )\n\
print "info loaded"\n\
except:\n\
pass\n'
@@ -107,7 +113,9 @@
class DMInfo:
# FIRST INITIATE HARDCODED CLASSES SUCH AS VARIABLE, SYSTEM, COMPARTMENT SYSTMEM FROM HERE
def __init__(self ):
- self.theSimulator = ecell.emc.Simulator()
+ self.theSimulator = ecell.ecs.Simulator()
+ self.theSimulator.setDMSearchPath(
+ self.theSimulator.DMSearchPathSeparator.join( dm_path ) )
self.__dummiesList = {}
self.__createDummies()
if os.name != "nt":
@@ -125,40 +133,57 @@
def __createDummies( self ):
# createdummy stepper
- infoList = { DM_DESCRIPTION : "Information cannot be obtained about this class.",
- DM_BASECLASS : "Unknown",
- DM_ACCEPTNEWPROPERTY : True }
+ infoList = {
+ DM_DESCRIPTION : "Information cannot be obtained about this class.",
+ DM_BASECLASS : "Unknown",
+ DM_ACCEPTNEWPROPERTY : True
+ }
flags = [ False, False, False ]
#stepper
- stepperPropertyList = { ME_STEPPER_PROCESSLIST : [ "Polymorph", 0,1,0,0, [] ] }
- stepperPropertyList [ ME_STEPPER_SYSTEMLIST ] = [ "Polymorph", 0,1,0,0, [] ]
+ stepperPropertyList = {
+ ME_STEPPER_PROCESSLIST: ( 0, 1, 0, 0, 0, PROPERTY_TYPE_POLYMORPH, [] ),
+ ME_STEPPER_SYSTEMLIST: ( 0, 1, 0, 0, 0, PROPERTY_TYPE_POLYMORPH, [] )
+ }
stepperInfo = dict( infoList )
- stepperInfo[DM_PROPERTYLIST] = stepperPropertyList.keys()
+ stepperInfo[ DM_PROPERTYLIST ] = stepperPropertyList.keys()
- self.__dummiesList[ME_STEPPER_TYPE] = [ ME_STEPPER_TYPE , True, stepperInfo, stepperPropertyList, flags ]
+ self.__dummiesList[ ME_STEPPER_TYPE ] = (
+ ME_STEPPER_TYPE, True, stepperInfo, stepperPropertyList, flags
+ )
#process
- processPropertyList = { ME_STEPPERID : [ "String", 1,1,1,1, "" ],
- ME_PROCESS_VARREFLIST : [ "Polymorph", 1, 1, 1, 1, [] ] }
- processInfo = dict(infoList )
- processInfo[ DM_PROPERTYLIST] = processPropertyList.keys()
+ processPropertyList = {
+ ME_STEPPERID : ( 1, 1, 1, 1, 0, PROPERTY_TYPE_STRING, "" ),
+ ME_PROCESS_VARREFLIST : ( 1, 1, 1, 1, 0, PROPERTY_TYPE_POLYMORPH, [] )
+ }
+ processInfo = dict( infoList )
+ processInfo[ DM_PROPERTYLIST ] = processPropertyList.keys()
- self.__dummiesList[ME_PROCESS_TYPE ] = [ME_PROCESS_TYPE, True, processInfo, processPropertyList, flags ]
+ self.__dummiesList[ ME_PROCESS_TYPE ] = (
+ ME_PROCESS_TYPE, True, processInfo, processPropertyList, flags
+ )
#system
- systemPropertyList = { ME_STEPPERID : [ "String", 1,1,1,1, "" ] }
- systemInfo = dict(infoList )
- systemInfo[ DM_PROPERTYLIST] = systemPropertyList.keys()
+ systemPropertyList = {
+ ME_STEPPERID : ( 1, 1, 1, 1, 0, PROPERTY_TYPE_STRING, "" )
+ }
+ systemInfo = dict( infoList )
+ systemInfo[ DM_PROPERTYLIST ] = systemPropertyList.keys()
- self.__dummiesList[ME_SYSTEM_TYPE ] = [ME_SYSTEM_TYPE, True, systemInfo, systemPropertyList, flags ]
+ self.__dummiesList[ ME_SYSTEM_TYPE ] = (
+ ME_SYSTEM_TYPE, True, systemInfo, systemPropertyList, flags
+ )
#variable
- variablePropertyList = { ME_VARIABLE_PROCESSLIST : [ "Polymorph", 0,1,0,0, [] ] }
+ variablePropertyList = {
+ ME_VARIABLE_PROCESSLIST : ( 0, 1, 0, 0, 0, PROPERTY_TYPE_POLYMORPH, [] )
+ }
variableInfo = dict( infoList )
- variableInfo[DM_PROPERTYLIST] = variablePropertyList.keys()
+ variableInfo[ DM_PROPERTYLIST ] = variablePropertyList.keys()
- self.__dummiesList[ME_VARIABLE_TYPE] = [ ME_VARIABLE_TYPE , True, variableInfo, variablePropertyList, flags ]
+ self.__dummiesList[ ME_VARIABLE_TYPE ] = (
+ ME_VARIABLE_TYPE , True, variableInfo, variablePropertyList, flags
+ )
-
def setWorkingDir(self, aPath):
# changes working dir, parses working dir so and dlls
self.workingPath = aPath
@@ -167,6 +192,7 @@
def refresh( self ):
# loads all so and dll files from DMPATH and curdir
+ self.theMasterList.clear()
self.__loadBuiltins()
self.__scanCurrentPath()
@@ -184,10 +210,11 @@
# system, variable
self.loadModule( ME_SYSTEM_TYPE, DM_SYSTEM_CLASS, True )
- self.loadModule( ME_SYSTEM_TYPE, DM_SYSTEM_CLASS_OLD, True )
self.loadModule( ME_VARIABLE_TYPE, DM_VARIABLE_CLASS,True )
variableDesc = self.__getClassDescriptor( DM_VARIABLE_CLASS )
- variableDesc[MASTERLIST_PROPERTYLIST][MS_VARIABLE_PROCESSLIST] = [ "Polymorph", 0,1,0,0 ]
+ variableDesc[MASTERLIST_PROPERTYLIST][MS_VARIABLE_PROCESSLIST] = (
+ 0, 1, 0, 0, 0, PROPERTY_TYPE_POLYMORPH, []
+ )
newList = list(variableDesc[MASTERLIST_INFOLIST][DM_PROPERTYLIST])
newList.append( MS_VARIABLE_PROCESSLIST )
variableDesc[MASTERLIST_INFOLIST][DM_PROPERTYLIST] = newList
@@ -313,35 +340,24 @@
if not aFlags[DM_CAN_LOADINFO] :
# not info can be obtained valid DM file
return
-
-# if not aFlags[DM_CAN_LOADINFO]: #it can be instantiated
-# anInfo = { DM_PROPERTYLIST : [], DM_ACCEPTNEWPROPERTY : aFlags[DM_CAN_ADDPROPERTY], DM_DESCRIPTION : "Information cannot be loaded from binary file" }
- ...
[truncated message content] |