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