platform/src/Protocol.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/Protocol.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 Protocol
00029 const std::string           Protocol::EVENT_ELEMENT_NAME = "EventType";
00030     
00031         
00032 // Protocol member functions
00033 
00034 bool Protocol::checkRecoveryPacket(bool request, const char* ptr, size_t len)
00035 {
00036     return false;
00037 }
00038 
00039 void Protocol::setConfig(const Vocabulary& v, const xmlNodePtr config_ptr)
00040 {
00041     PlatformPlugin::setConfig(v, config_ptr);
00042     
00043     // determine the type of event used by the protocol
00044     std::string protocol_event_str;
00045     if (! ConfigManager::getConfigOption(EVENT_ELEMENT_NAME, protocol_event_str,
00046                                          config_ptr))
00047         throw EmptyEventException(getId());
00048 
00049     // find the Term reference number for the event type
00050     Vocabulary::TermRef event_type = v.findTerm(protocol_event_str);
00051     if (event_type == Vocabulary::UNDEFINED_TERM_REF)
00052         throw UnknownTermException(protocol_event_str);
00053     m_event_term = v[event_type];
00054     
00055     // make sure that it is an object type Term
00056     if (m_event_term.term_type != Vocabulary::TYPE_OBJECT)
00057         throw NotAnObjectException(protocol_event_str);
00058 }
00059     
00060 void Protocol::updateVocabulary(const Vocabulary& v)
00061 {
00062     PlatformPlugin::updateVocabulary(v);
00063 
00064     // assume that term references never change
00065 }
00066 
00067 }   // end namespace platform
00068 }   // end namespace pion

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