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

VectorParser.ih

Go to the documentation of this file.
00001 // $Id: VectorParser.ih 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 IH_SENF_Packets_VectorParser_
00027 #define IH_SENF_Packets_VectorParser_ 1
00028 
00029 // Custom includes
00030 
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 namespace senf {
00034 namespace detail {
00035 
00036 #ifndef DOXYGEN
00037 
00038     template <class ElementParser, class AuxPolicy, class AuxTag>
00039     struct VectorParserPolicy
00040     {};
00041 
00042     template <class ElementParser, class AuxPolicy>
00043     struct VectorParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::none>
00044     {
00045         typedef AuxPolicy type;
00046     };
00047 
00048     template <class ElementParser, class AuxPolicy, class Transform>
00049     struct VectorParserPolicy<ElementParser, AuxPolicy,
00050                               senf::detail::auxtag::transform<Transform,
00051                                                               senf::detail::auxtag::none> >
00052     {
00053         typedef senf::detail::TransformAuxParserPolicy<AuxPolicy, Transform> type;
00054     };
00055 
00056     template <unsigned fixedSize>
00057     struct VectorParserBytesTransform
00058     {
00059         typedef PacketParserBase::size_type value_type;
00060         static value_type get(value_type v) { return v/fixedSize; }
00061         static value_type set(value_type v) { return v*fixedSize; }
00062     };
00063 
00064     template <class ElementParser, class AuxPolicy>
00065     struct VectorParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::bytes>
00066     {
00067         typedef senf::detail::TransformAuxParserPolicy<
00068             AuxPolicy,
00069             VectorParserBytesTransform<ElementParser::fixed_bytes> > type;
00070     };
00071 
00072     template <class ElementParser>
00073     struct VectorParserTraits
00074     {
00075         template <class AuxPolicy, class AuxTag>
00076         struct parser {
00077             typedef senf::VectorParser<
00078                 ElementParser,
00079                 typename VectorParserPolicy<ElementParser, AuxPolicy, AuxTag>::type > type;
00080         };
00081     };
00082 
00083 
00084 #   define SENF_PARSER_VECTOR_I(access, name, size, elt_type)                                     \
00085         SENF_PARSER_REQUIRE_VAR(vector)                                                           \
00086         SENF_PARSER_COLLECTION_I( access,                                                         \
00087                                   name,                                                           \
00088                                   size,                                                           \
00089                                   senf::detail::VectorParserTraits<elt_type> )
00090 
00091 #endif
00092 
00093 }}
00094 
00095 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00096 #endif
00097 
00098 
00099 // Local Variables:
00100 // mode: c++
00101 // fill-column: 100
00102 // comment-column: 40
00103 // c-file-style: "senf"
00104 // indent-tabs-mode: nil
00105 // ispell-local-dictionary: "american"
00106 // compile-command: "scons -u test"
00107 // End:

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