module.cxx

Go to the documentation of this file.
00001 //    sampalib.org ESL library and tools
00002 //    Copyright (C) 2007  Thierry Grellier
00003 //
00004 //    This program is free software; you can redistribute it and/or modify
00005 //    it under the terms of the GNU General Public License version 2 as
00006 //    published by the Free Software Foundation.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //    You should have received a copy of the GNU General Public License along
00014 //    with this program; if not, write to the Free Software Foundation, Inc.,
00015 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 //
00017 //    contact: www.sampalib.org
00018 
00019 #include "sampa/core/module.h"
00020 #include "sampa/core/persistence.cxx"
00021 
00022 namespace Sampa {
00023 
00024 template<class UserModule>
00025 Process<UserModule>::Process(const Name& name, UserModule* module, Method method)
00026   : ProcessBase(name), m_module(module), m_method(method)
00027 {
00028 }
00029 
00030 template<class UserModule>
00031 EventListenerSingle* Process<UserModule>::execute() 
00032 { 
00033   (m_module->*m_method)(); 
00034   return m_trigger;
00035 }
00036 
00037 } // namespace Sampa
00038 
00039 #if SAMPA_CONFIG_COLD_RESTART == SAMPA_ENABLED
00040 # define SAMPA_MAKE_PROCESS(ModuleScope)            \
00041 namespace Sampa {\
00042   SAMPA_MAKE_TMPL_PERSISTENT(ModuleScope::Process, Process, REF(m_module) );  \
00043 }
00044 # define SAMPA_MAKE_MODULE(ModuleScope, ModuleClass, members)            \
00045 SAMPA_MAKE_PERSISTENT(ModuleScope, ModuleClass, members);  \
00046 Sampa::Process<ModuleScope>& ModuleScope::create_process(const std::string& name, Sampa::Process<ModuleScope>::Method method) \
00047 { return *pnew(Sampa::Process<ModuleScope>)(name, this, method); } \
00048 void ModuleScope::restart_process(const std::string& name, Sampa::Process<ModuleScope>::Method method) \
00049 { dynamic_cast<Sampa::Process<ModuleScope>*>(__get_process_by_name(name))->restart(method); }
00050 # define SAMPA_MAKE_TMPL_MODULE(ModuleScope, ModuleClass, members)            \
00051 SAMPA_MAKE_TMPL_PERSISTENT(ModuleScope, ModuleClass, members);  \
00052 template<> Sampa::Process<ModuleScope >& ModuleScope::create_process(const std::string& name, Sampa::Process<ModuleScope >::Method method) \
00053 { return *pnew(Sampa::Process<ModuleScope >)(name, this, method); } \
00054 template<> void ModuleScope::restart_process(const std::string& name, Sampa::Process<ModuleScope >::Method method) \
00055 { dynamic_cast<Sampa::Process<ModuleScope >*>(__get_process_by_name(name))->restart(method); }
00056 #else
00057 # define SAMPA_MAKE_PROCESS(ModuleScope)            
00058 # define SAMPA_MAKE_MODULE(ModuleScope, ModuleClass, members)            \
00059 Sampa::Process<ModuleScope>& ModuleScope::create_process(const std::string& name, Sampa::Process<ModuleScope>::Method method) \
00060 { return *new Process(name, this, method); }  \
00061 void ModuleScope::restart_process(const std::string& name, Sampa::Process<ModuleScope>::Method method) \
00062 { dynamic_cast<Process*>(__get_process_by_name(name))->restart(method); }
00063 # define SAMPA_MAKE_TMPL_MODULE(ModuleScope, ModuleClass, members)            \
00064 template<> Sampa::Process<ModuleScope >& ModuleScope::create_process(const std::string& name, Sampa::Process<ModuleScope >::Method method) \
00065 { return *new Sampa::Process<ModuleScope >(name, this, method); }  \
00066 template<> void ModuleScope::restart_process(const std::string& name, Sampa::Process<ModuleScope >::Method method) \
00067 { dynamic_cast<Sampa::Process<ModuleScope >*>(__get_process_by_name(name))->restart(method); }
00068 #endif
00069 

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3