platform/include/pion/platform/PlatformPlugin.hpp

00001 // ------------------------------------------------------------------------
00002 // Pion is a development platform for building Reactors that process Events
00003 // ------------------------------------------------------------------------
00004 // Copyright (C) 2007-2008 Atomic Labs, Inc.  (http://www.atomiclabs.com)
00005 //
00006 // Pion is free software: you can redistribute it and/or modify it under the
00007 // terms of the GNU Affero General Public License as published by the Free
00008 // Software Foundation, either version 3 of the License, or (at your option)
00009 // any later version.
00010 //
00011 // Pion is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for
00014 // more details.
00015 //
00016 // You should have received a copy of the GNU Affero General Public License
00017 // along with Pion.  If not, see <http://www.gnu.org/licenses/>.
00018 //
00019 
00020 #ifndef __PION_PLATFORMPLUGIN_HEADER__
00021 #define __PION_PLATFORMPLUGIN_HEADER__
00022 
00023 #include <string>
00024 #include <libxml/tree.h>
00025 #include <boost/noncopyable.hpp>
00026 #include <pion/PionConfig.hpp>
00027 
00028 namespace pion {        // begin namespace pion
00029 namespace server {      // begin namespace server (Pion Server)
00030 
00031 // forward declarations
00032 class ServiceManager;
00033 
00034 }   // end namespace server
00035 }   // end namespace pion
00036 
00037 namespace pion {        // begin namespace pion
00038 namespace platform {    // begin namespace platform (Pion Platform Library)
00039 
00040 // forward declarations
00041 class Vocabulary;
00042 class CodecFactory;
00043 class DatabaseManager;
00044 class ReactionEngine;   
00045 class ProtocolFactory;
00046 
00050 class PION_PLATFORM_API PlatformPlugin
00051     : private boost::noncopyable
00052 {
00053 public:
00054 
00056     PlatformPlugin(void) :
00057         m_codec_factory_ptr(NULL), m_database_mgr_ptr(NULL),
00058         m_reaction_engine_ptr(NULL), m_protocol_factory_ptr(NULL), m_service_mgr_ptr(NULL)
00059     {}
00060     
00062     virtual ~PlatformPlugin() {}
00063     
00071     virtual void setConfig(const Vocabulary& v, const xmlNodePtr config_ptr);
00072 
00079     virtual void updateVocabulary(const Vocabulary& v);
00080 
00081     
00083     inline void setId(const std::string& plugin_id) { m_plugin_id = plugin_id; }
00084     
00086     inline const std::string& getId(void) const { return m_plugin_id; }
00087     
00089     inline void setName(const std::string& plugin_name) { m_plugin_name = plugin_name; }
00090     
00092     inline const std::string& getName(void) const { return m_plugin_name; }
00093     
00095     inline void setComment(const std::string& plugin_comment) { m_plugin_comment = plugin_comment; }
00096     
00098     inline const std::string& getComment(void) const { return m_plugin_comment; }
00099 
00101     inline void setCodecFactory(CodecFactory& factory) { m_codec_factory_ptr = & factory; }
00102     
00104     inline void setDatabaseManager(DatabaseManager& mgr) { m_database_mgr_ptr = & mgr; }
00105     
00107     inline void setReactionEngine(ReactionEngine& engine) { m_reaction_engine_ptr = & engine; }
00108 
00110     inline void setProtocolFactory(ProtocolFactory& factory) { m_protocol_factory_ptr = & factory; }
00111 
00113     inline void setServiceManager(pion::server::ServiceManager& mgr) { m_service_mgr_ptr = & mgr; }
00114 
00115 protected:
00116     
00118     inline void copyPlugin(const PlatformPlugin& pp) {
00119         m_plugin_id = pp.m_plugin_id;
00120         m_plugin_name = pp.m_plugin_name;
00121         m_plugin_comment = pp.m_plugin_comment;
00122     }
00123     
00125     inline CodecFactory& getCodecFactory(void) {
00126         PION_ASSERT(m_codec_factory_ptr != NULL);
00127         return *m_codec_factory_ptr;
00128     }
00129     
00131     inline DatabaseManager& getDatabaseManager(void) {
00132         PION_ASSERT(m_database_mgr_ptr != NULL);
00133         return *m_database_mgr_ptr;
00134     }
00135     
00137     inline ReactionEngine& getReactionEngine(void) {
00138         PION_ASSERT(m_reaction_engine_ptr != NULL);
00139         return *m_reaction_engine_ptr;
00140     }
00141 
00143     inline ProtocolFactory& getProtocolFactory(void) {
00144         PION_ASSERT(m_protocol_factory_ptr != NULL);
00145         return *m_protocol_factory_ptr;
00146     }
00147 
00149     inline pion::server::ServiceManager& getServiceManager(void) {
00150         PION_ASSERT(m_service_mgr_ptr != NULL);
00151         return *m_service_mgr_ptr;
00152     }
00153 
00154 private:
00155     
00157     static const std::string        NAME_ELEMENT_NAME;
00158     
00160     static const std::string        COMMENT_ELEMENT_NAME;
00161 
00162 
00164     std::string                     m_plugin_id;
00165 
00167     std::string                     m_plugin_name;
00168 
00170     std::string                     m_plugin_comment;
00171     
00173     CodecFactory *                  m_codec_factory_ptr;
00174     
00176     DatabaseManager *               m_database_mgr_ptr;
00177     
00179     ReactionEngine *                m_reaction_engine_ptr;
00180 
00182     ProtocolFactory *               m_protocol_factory_ptr;
00183 
00185     pion::server::ServiceManager *  m_service_mgr_ptr;
00186 };
00187 
00188     
00189 }   // end namespace platform
00190 }   // end namespace pion
00191 
00192 #endif

Generated on Wed Apr 13 16:38:34 2011 for pion-platform by  doxygen 1.4.7