MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
mip_definitions.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "mip_metadata.hpp"
4 
6 
7 #include <set>
8 #include <initializer_list>
9 
10 
11 namespace mip::metadata
12 {
13 
15 {
16  struct Less
17  {
18  inline bool operator()(const FieldInfo *a, const FieldInfo *b) const
19  {
20  return a->descriptor < b->descriptor;
21  }
22  inline bool operator()(const FieldInfo *a, CompositeDescriptor desc) const
23  {
24  return a->descriptor < desc;
25  }
26  inline bool operator()(CompositeDescriptor desc, const FieldInfo *a) const
27  {
28  return desc < a->descriptor;
29  }
30  using is_transparent = void;
31  };
32 
33  using Container = std::set<const FieldInfo *, Less>;
34 
35 public:
36  Definitions() = default;
37  Definitions(const std::initializer_list<const std::initializer_list<const FieldInfo*>*>& fields) { registerDefinitions(fields); }
38 
39  void registerField(const FieldInfo* field);
40  void registerDefinitions(std::initializer_list<const FieldInfo*> fields);
41  void registerDefinitions(const std::initializer_list<const std::initializer_list<const FieldInfo*>*>& fields);
42 
43  const FieldInfo* findField(mip::CompositeDescriptor descriptor) const;
44 
45 
46 private:
47  Container mFields;
48 };
49 
50 
51 
52 
53 } // namespace mip::metadata
mip::metadata::Definitions::Definitions
Definitions()=default
mip_descriptors.hpp
mip::metadata::Definitions::Definitions
Definitions(const std::initializer_list< const std::initializer_list< const FieldInfo * > * > &fields)
Definition: mip_definitions.hpp:37
mip::metadata
Definition: commands_3dm.hpp:9
mip::metadata::Definitions::registerField
void registerField(const FieldInfo *field)
Definition: mip_definitions.cpp:10
mip::metadata::Definitions::findField
const FieldInfo * findField(mip::CompositeDescriptor descriptor) const
Definition: mip_definitions.cpp:38
mip::metadata::Definitions
Definition: mip_definitions.hpp:14
mip_metadata.hpp
mip::metadata::FieldInfo
Definition: mip_structures.hpp:182
mip::metadata::Definitions::registerDefinitions
void registerDefinitions(std::initializer_list< const FieldInfo * > fields)
Definition: mip_definitions.cpp:15
mip::CompositeDescriptor
Convenience struct holding both descriptor set and field descriptor.
Definition: mip_descriptors.hpp:22
mip::metadata::FieldInfo::descriptor
CompositeDescriptor descriptor
Definition: mip_structures.hpp:184