protocol.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/component/protocol.h"
00020 #include "sampa/core/persistence.cxx"
00021   
00022 #define SAMPA_MAKE_ADAPTING_INITIATOR(Adapted)\
00023   template<> AdaptingInitiator<Adapted>::AdaptingInitiator(const Name& nm, RecieveResponseFunc callback) \
00024   : Initiator(nm, this),                                                                                 \
00025     m_module(dynamic_cast<Adapted*>(get_parent())),                                                      \
00026     m_callback(callback)                                                                                 \
00027   {                                                                                                      \
00028   }                                                                                                      \
00029   template<> void AdaptingInitiator<Adapted>::complete_restart(RecieveResponseFunc callback)             \
00030     { m_callback = callback; }                                                                           \
00031   template<> bool AdaptingInitiator<Adapted>::recieve_response(const Response& response)                 \
00032     { return (m_module->*m_callback)(response); }                                                        \
00033   SAMPA_MAKE_TMPL_PERSISTENT(AdaptingInitiator<Adapted>, AdaptingInitiator, REF(m_module))
00034 
00035 #define SAMPA_MAKE_ADAPTING_TARGET(Adapted)\
00036   template<> AdaptingTarget<Adapted>::AdaptingTarget(const Name& nm, RecieveRequestFunc callback)        \
00037   : Target(nm, this),                                                                                    \
00038     m_module(dynamic_cast<Adapted*>(get_parent())),                                                      \
00039     m_callback(callback)                                                                                 \
00040   {                                                                                                      \
00041   }                                                                                                      \
00042   template<> void AdaptingTarget<Adapted>::complete_restart(RecieveRequestFunc callback)                 \
00043     { m_callback = callback; }                                                                           \
00044   template<> bool AdaptingTarget<Adapted>::recieve_request(const Request& request)                       \
00045     { return (m_module->*m_callback)(request); }                                                         \
00046   SAMPA_MAKE_TMPL_PERSISTENT(AdaptingTarget<Adapted>, AdaptingTarget, REF(m_module))
00047 
00048 # define SAMPA_MAKE_FACTORY(factory_class) \
00049   Sampa::Transaction::FactoryBase* create_factory() { \
00050     return pnew(factory_class)(Sampa::DEFAULT_CTR); \
00051   } \
00052   SAMPA_MAKE_TMPL_PERSISTENT(factory_class, Factory, NO_REFS)
00053 
00054 #if SAMPA_CONFIG_COLD_RESTART == SAMPA_ENABLED
00055 #include <typeinfo>
00056 namespace Sampa {
00057   template<class Ext> class_descriptor Tx<Ext>::self_class(typeid(Tx()).name(), sizeof(Tx), &Tx::constructor);
00058 }
00059 #endif
00060 

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