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