default_processors.hpp

См. документацию.
00001 /*
00002 
00003 Copyright (c) 2002-2005, Yauheni Akhotnikau
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008 
00009 - Redistributions of source code must retain the above copyright notice, this
00010 list of conditions and the following disclaimer.
00011 
00012 - Redistributions in binary form must reproduce the above copyright notice, this
00013 list of conditions and the following disclaimer in the documentation and/or
00014 other materials provided with the distribution.
00015 
00016 - The name of the author may not be used to endorse or promote products derived
00017 from this software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00020 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00021 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00022 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00024 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00025 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00026 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00027 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00028 OF SUCH DAMAGE.
00029 
00030 */
00031 
00040 #if !defined( _OESS_1__TLV__DEFAULT_PROCESSORS_HPP_ )
00041 #define _OESS_1__TLV__DEFAULT_PROCESSORS_HPP_
00042 
00043 #include <oess_1/tlv/h/declspec.hpp>
00044 
00045 #include <oess_1/io/h/bin_data_size.hpp>
00046 
00047 #include <oess_1/tlv/h/base.hpp>
00048 
00049 namespace oess_1
00050 {
00051 
00052 namespace tlv
00053 {
00054 
00055 //
00056 // default_tag_processor_t
00057 //
00058 
00060 
00064 template< class Tag_type = default_tag_type_t >
00065 class default_tag_processor_t :
00066   public tag_processor_t
00067 {
00068   public :
00070     typedef default_tag_processor_t< Tag_type > self_t;
00071 
00072   private :
00074     Tag_type  m_id;
00075 
00076   public :
00078     default_tag_processor_t()
00079       :
00080         m_id()
00081     {
00082     }
00083 
00085     default_tag_processor_t( Tag_type id )
00086       :
00087         m_id( id )
00088     {
00089     }
00091     default_tag_processor_t( const self_t & o )
00092       :
00093         m_id( o.m_id )
00094     {
00095     }
00096     virtual ~default_tag_processor_t()
00097     {
00098     }
00099 
00101     self_t &
00102     operator=( const self_t & o )
00103     {
00104       m_id = o.m_id;
00105       return this;
00106     }
00107 
00109     virtual size_t
00110     tlv_tag_size() const
00111     {
00112       return oess_1::io::bin_data_size_t< Tag_type >::image_size;
00113     }
00114 
00116 
00120     virtual void
00121     tlv_unpack_tag(
00124       oess_1::io::ibinstream_t & s )
00125     {
00126       s >> m_id;
00127     }
00128 
00130 
00134     virtual void
00135     tlv_pack_tag(
00138       oess_1::io::obinstream_t & s ) const
00139     {
00140       s << m_id;
00141     }
00142 
00144     virtual default_tag_type_t
00145     query_tag() const
00146     {
00147       return (default_tag_type_t) m_id;
00148     }
00149 
00151     virtual void
00152     set_tag( const default_tag_type_t & value )
00153     {
00154       m_id = value;
00155     }
00156 };
00157 
00159 inline oess_1::io::ibinstream_t &
00160 operator>>(
00163   oess_1::io::ibinstream_t & s,
00165   tag_processor_t & o )
00166 {
00167   o.tlv_unpack_tag( s );
00168   return s;
00169 }
00170 
00172 inline oess_1::io::obinstream_t &
00173 operator<<(
00176   oess_1::io::obinstream_t & s,
00178   const tag_processor_t & o )
00179 {
00180   o.tlv_pack_tag( s );
00181   return s;
00182 }
00183 
00184 //
00185 // default_length_processor_t
00186 //
00187 
00189 
00193 template< class Length_type >
00194 class default_length_processor_t :
00195   public length_processor_t
00196 {
00197   public :
00198     default_length_processor_t()
00199     {
00200     }
00201     
00202     virtual ~default_length_processor_t()
00203     {
00204     }
00205 
00208     virtual size_t
00209     tlv_length_size(
00211       size_t value_length ) const
00212     {
00213       return oess_1::io::bin_data_size_t< Length_type >::image_size;
00214     }
00215 
00217     virtual void
00218     tlv_unpack_length(
00221       oess_1::io::ibinstream_t & s,
00223       size_t & value_length )
00224     {
00225       Length_type l;
00226       s >> l;
00227       value_length = l;
00228     }
00229 
00231     virtual void
00232     tlv_pack_length(
00235       oess_1::io::obinstream_t & s,
00237       size_t value_length ) const
00238     {
00239       Length_type l = value_length;
00240       s << l;
00241     }
00242 };
00243 
00244 } /* namespace tlv */
00245 
00246 } /* namespace oess_1 */
00247 
00248 #endif
00249 

Документация по ObjESSty. Последние изменения: Fri Oct 13 18:35:36 2006. Создано системой  doxygen 1.4.7
Hosted by uCoz