platform/reactors/DatabaseOutputReactor.hpp

00001 // ------------------------------------------------------------------------
00002 // Pion is a development platform for building Reactors that process Events
00003 // ------------------------------------------------------------------------
00004 // Copyright (C) 2007-2009 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_DATABASEOUTPUTREACTOR_HEADER__
00021 #define __PION_DATABASEOUTPUTREACTOR_HEADER__
00022 
00023 #include <pion/PionConfig.hpp>
00024 #include <pion/PionLogger.hpp>
00025 #include <pion/platform/Event.hpp>
00026 #include <pion/platform/Reactor.hpp>
00027 #include <pion/platform/DatabaseInserter.hpp>
00028 
00029 
00030 namespace pion {        // begin namespace pion
00031 namespace plugins {     // begin namespace plugins
00032 
00033 
00037 class DatabaseOutputReactor :
00038     public pion::platform::Reactor
00039 {
00040 public:
00041 
00043     DatabaseOutputReactor(void)
00044         : pion::platform::Reactor(TYPE_STORAGE),
00045         m_logger(PION_GET_LOGGER("pion.DatabaseOutputReactor"))
00046     {}
00047 
00049     virtual ~DatabaseOutputReactor() { stop(); }
00050 
00058     virtual void setConfig(const pion::platform::Vocabulary& v, const xmlNodePtr config_ptr);
00059 
00066     virtual void updateVocabulary(const pion::platform::Vocabulary& v);
00067 
00072     virtual void updateDatabases(void);
00073 
00079     virtual void process(const pion::platform::EventPtr& e);
00080 
00090     virtual void query(std::ostream& out, const QueryBranches& branches,
00091         const QueryParams& qp);
00092 
00094     virtual void start(void);
00095 
00097     virtual void stop(void);
00098 
00100     inline void setLogger(PionLogger log_ptr) { 
00101         m_logger = log_ptr;
00102         m_inserter->setLogger(log_ptr);
00103     }
00104 
00106     inline PionLogger getLogger(void) { return m_logger; }
00107 
00108 
00109 private:
00110 
00112     static const std::string                DATABASE_ELEMENT_NAME;
00113 
00115     static const std::string                TABLE_ELEMENT_NAME;
00116 
00118     static const std::string                FIELD_ELEMENT_NAME;
00119 
00121     static const std::string                EVENTS_QUEUED_ELEMENT_NAME;
00122 
00124     static const std::string                KEY_CACHE_SIZE_ELEMENT_NAME;
00125 
00127     PionLogger                              m_logger;
00128 
00129     typedef boost::scoped_ptr<pion::platform::DatabaseInserter>     DatabaseInserterPtr;
00130 
00132     DatabaseInserterPtr                     m_inserter;
00133 };
00134 
00135 
00136 }   // end namespace plugins
00137 }   // end namespace pion
00138 
00139 #endif

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