platform/reactors/FilterReactor.cpp

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 #include "FilterReactor.hpp"
00021 
00022 using namespace pion::platform;
00023 
00024 
00025 namespace pion {        // begin namespace pion
00026 namespace plugins {     // begin namespace plugins
00027 
00028 
00029 // FilterReactor member functions
00030 
00031 void FilterReactor::setConfig(const Vocabulary& v, const xmlNodePtr config_ptr)
00032 {
00033     // first set config options for the Reactor base class
00034     ConfigWriteLock cfg_lock(*this);
00035     Reactor::setConfig(v, config_ptr);
00036     
00037     // parse RuleChain configuration
00038     m_rules.setConfig(v, config_ptr);
00039 }
00040     
00041 void FilterReactor::updateVocabulary(const Vocabulary& v)
00042 {
00043     // first update anything in the Reactor base class that might be needed
00044     ConfigWriteLock cfg_lock(*this);
00045     Reactor::updateVocabulary(v);
00046     m_rules.updateVocabulary(v);
00047 }
00048     
00049 void FilterReactor::process(const EventPtr& e)
00050 {
00051     if ( m_rules(e) )       
00052         deliverEvent(e);
00053 }
00054     
00055     
00056 }   // end namespace plugins
00057 }   // end namespace pion
00058 
00059 
00061 extern "C" PION_PLUGIN_API pion::platform::Reactor *pion_create_FilterReactor(void) {
00062     return new pion::plugins::FilterReactor();
00063 }
00064 
00066 extern "C" PION_PLUGIN_API void pion_destroy_FilterReactor(pion::plugins::FilterReactor *reactor_ptr) {
00067     delete reactor_ptr;
00068 }

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