DCCL v4
field_codec_fixed.h
1 // Copyright 2009-2017 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (for 2013-)
3 // Massachusetts Institute of Technology (for 2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Dynamic Compact Control Language Library
8 // ("DCCL").
9 //
10 // DCCL is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // DCCL is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with DCCL. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef DCCLFIELDCODEC20110510H
23 #define DCCLFIELDCODEC20110510H
24 
25 #include "field_codec_typed.h"
26 
27 namespace dccl
28 {
33  template<typename WireType, typename FieldType = WireType>
34  class TypedFixedFieldCodec : public TypedFieldCodec<WireType, FieldType>
35  {
36  public:
38  virtual unsigned size() = 0;
39 
40  public:
41  unsigned size(const WireType& wire_value)
42  { return size(); }
43 
44  unsigned max_size()
45  { return size(); }
46 
47  unsigned min_size()
48  { return size(); }
49  };
50 }
51 
52 #endif
dccl::TypedFixedFieldCodec::size
virtual unsigned size()=0
The size of the encoded message in bits. Use TypedFieldCodec if the size depends on the data.
dccl
Dynamic Compact Control Language namespace.
Definition: gen_units_class_plugin.h:49
dccl::TypedFixedFieldCodec
Base class for static-typed field encoders/decoders that use a fixed number of bits on the wire regar...
Definition: field_codec_fixed.h:34
dccl::TypedFixedFieldCodec::max_size
unsigned max_size()
Calculate maximum size of the field in bits.
Definition: field_codec_fixed.h:44
dccl::TypedFieldCodec
Base class for static-typed (no boost::any) field encoders/decoders. Most single-valued user defined ...
Definition: field_codec_typed.h:82
dccl::TypedFixedFieldCodec::size
unsigned size(const WireType &wire_value)
Calculate the size (in bits) of a non-empty field.
Definition: field_codec_fixed.h:41
dccl::TypedFixedFieldCodec::min_size
unsigned min_size()
Calculate minimum size of the field in bits.
Definition: field_codec_fixed.h:47