platform/src/Codec.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 <pion/platform/Codec.hpp>
00021 #include <pion/platform/ConfigManager.hpp>
00022 
00023 
00024 namespace pion {        // begin namespace pion
00025 namespace platform {    // begin namespace platform (Pion Platform Library)
00026 
00027 
00028 // static members of Codec
00029 const std::string           Codec::EVENT_ELEMENT_NAME = "EventType";
00030     
00031         
00032 // Codec member functions
00033 
00034 void Codec::setConfig(const Vocabulary& v, const xmlNodePtr config_ptr)
00035 {
00036     PlatformPlugin::setConfig(v, config_ptr);
00037     
00038     // determine the type of event used by the codec
00039     std::string codec_event_str;
00040     if (! ConfigManager::getConfigOption(EVENT_ELEMENT_NAME, codec_event_str,
00041                                          config_ptr))
00042         throw EmptyEventException(getId());
00043 
00044     // find the Term reference number for the event type
00045     Vocabulary::TermRef event_type = v.findTerm(codec_event_str);
00046     if (event_type == Vocabulary::UNDEFINED_TERM_REF)
00047         throw UnknownTermException(codec_event_str);
00048     m_event_term = v[event_type];
00049 
00050     // make sure that it is an object type Term
00051     if (m_event_term.term_type != Vocabulary::TYPE_OBJECT)
00052         throw NotAnObjectException(codec_event_str);
00053 }
00054     
00055 void Codec::updateVocabulary(const Vocabulary& v)
00056 {
00057     PlatformPlugin::updateVocabulary(v);
00058 
00059     // assume that term references never change
00060 }
00061 
00062 }   // end namespace platform
00063 }   // end namespace pion

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