Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

80221Bundle/MIHMessageRegistry.hh

Go to the documentation of this file.
00001 // $Id: MIHMessageRegistry.hh 1789 2011-05-19 09:31:33Z tho $
00002 //
00003 // Copyright (C) 2010
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Thorsten Horstmann <tho@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Packets_80221Bundle_MIHMessageRegistry_
00027 #define HH_SENF_Packets_80221Bundle_MIHMessageRegistry_ 1
00028 
00029 // Custom includes
00030 #include <boost/ptr_container/ptr_map.hpp>
00031 #include <senf/Utils/singleton.hh>
00032 #include <senf/Packets/Packets.hh>
00033 
00034 #include "MIHMessageRegistry.ih"
00035 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00036 namespace senf {
00037 
00038     class MIHMessageRegistry
00039         : public senf::singleton<MIHMessageRegistry>
00040     {
00041     public:
00042         typedef boost::uint16_t key_t;
00043 
00044         using senf::singleton<MIHMessageRegistry>::instance;
00045         friend class senf::singleton<MIHMessageRegistry>;
00046 
00047         template <typename MIHPacket>
00048         struct RegistrationProxy {
00049             RegistrationProxy();
00050         };
00051 
00052         template <typename MIHPacket>
00053         void registerMessageType();
00054 
00055         void validate(key_t messageId, senf::Packet message);
00056 
00057     private:
00058         typedef boost::ptr_map<key_t, detail::MIHMessageRegistry_EntryBase > Map;
00059         Map map_;
00060 
00061         MIHMessageRegistry() {};
00062     };
00063 
00064 
00065 #   define SENF_MIH_PACKET_REGISTRY_REGISTER( packet )                      \
00066         SENF_PACKET_REGISTRY_REGISTER(                                      \
00067             senf::MIHMessageRegistry, packet::type::MESSAGE_ID, packet )    \
00068         namespace {                                                         \
00069             senf::MIHMessageRegistry::RegistrationProxy< packet >           \
00070             BOOST_PP_CAT(mihPacketRegistration_, __LINE__);                 \
00071         }
00072 
00073 }
00074 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00075 //#include "MIHMessageRegistry.cci"
00076 #include "MIHMessageRegistry.ct"
00077 //#include "MIHMessageRegistry.cti"
00078 #endif
00079 
00080 
00081 
00082 // Local Variables:
00083 // mode: c++
00084 // fill-column: 100
00085 // c-file-style: "senf"
00086 // indent-tabs-mode: nil
00087 // ispell-local-dictionary: "american"
00088 // compile-command: "scons -u test"
00089 // comment-column: 40
00090 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research