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

VariantParser.hh

Go to the documentation of this file.
00001 // $Id: VariantParser.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2007
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@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_VariantParser_
00027 #define HH_SENF_Packets_VariantParser_ 1
00028 
00029 #ifndef HH_SENF_Packets_Packets_
00030 #error "Don't include 'VariantParser.hh' directly, include 'Packets.hh'"
00031 #endif
00032 
00033 // Custom includes
00034 #include <boost/mpl/vector.hpp>
00035 #include <boost/mpl/at.hpp>
00036 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
00037 #include <boost/preprocessor/repetition/enum_params.hpp>
00038 #include <boost/preprocessor/seq/for_each.hpp>
00039 #include "PacketParser.hh"
00040 
00041 //#include "VariantParser.mpp"
00042 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00043 
00044 namespace senf {
00045 
00046 #   ifndef SENF_LIMIT_PARSE_VARIANT
00047 
00051 #       define SENF_LIMIT_PARSE_VARIANT 6
00052 #   endif
00053 
00079     template <class AuxPolicy, class Parsers>
00080     class VariantParser
00081         : public PacketParserBase, private AuxPolicy
00082     {
00083         typedef Parsers parsers;
00084 
00085     public:
00087         //\{
00088 
00089         VariantParser(data_iterator i, state_type s);
00090         VariantParser(AuxPolicy policy, data_iterator i, state_type s);
00091 
00092         size_type bytes() const;
00093         void init();
00094 
00095         static const size_type init_bytes = senf::init_bytes<
00096             typename boost::mpl::at<parsers, boost::mpl::int_<0> >::type>::value
00097                 + AuxPolicy::aux_bytes;
00098 
00099         //\}
00100         //-////////////////////////////////////////////////////////////////////////
00101 
00102         unsigned variant() const;       
00103 
00109         template <unsigned N>
00110         typename boost::mpl::at< parsers, boost::mpl::int_<N> >::type get() const;
00112 
00118         template <unsigned N>
00119         void init();                    
00120 
00124     };
00125 
00245 #   define SENF_PARSER_VARIANT(name, chooser, types) \
00246         SENF_PARSER_VARIANT_I(public, name, chooser, types)
00247 
00254 #   define SENF_PARSER_PRIVATE_VARIANT(name, chooser, types) \
00255         SENF_PARSER_VARIANT_I(protected, name, chooser, types)
00256 }
00257 
00258 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00259 #endif
00260 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_VariantParser_i_)
00261 #define HH_SENF_Packets_VariantParser_i_
00262 //#include "VariantParser.cci"
00263 #include "VariantParser.ct"
00264 #include "VariantParser.cti"
00265 #endif
00266 
00267 
00268 // Local Variables:
00269 // mode: c++
00270 // fill-column: 100
00271 // comment-column: 40
00272 // c-file-style: "senf"
00273 // indent-tabs-mode: nil
00274 // ispell-local-dictionary: "american"
00275 // compile-command: "scons -u test"
00276 // End:

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