DCCL v4
Loading...
Searching...
No Matches
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
29namespace dccl
30{
35template <typename WireType, typename FieldType = WireType>
36class 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
Base class for static-typed (no dccl::any) field encoders/decoders. Most single-valued user defined v...
Base class for static-typed field encoders/decoders that use a fixed number of bits on the wire regar...
unsigned size() override=0
The size of the encoded message in bits. Use TypedFieldCodec if the size depends on the data.
unsigned min_size() override
Calculate minimum size of the field in bits.
unsigned size(const WireType &) override
Calculate the size (in bits) of a non-empty field.
unsigned max_size() override
Calculate maximum size of the field in bits.
Dynamic Compact Control Language namespace.
Definition any.h:47