data_lookup_mixins.h
Go to the documentation of this file.
1 #pragma once
2 
5 
7 
8 #include <optional>
9 
10 
12 {
14 
15 
16  template <class AronDtoT>
17  std::optional<AronDtoT>
19  {
20  if (data)
21  {
22  AronDtoT aron;
23  aron.fromAron(data);
24  return aron;
25  }
26  else
27  {
28  return std::nullopt;
29  }
30  }
31 
32 
33 
34  template <class DerivedT>
36  {
37 
39  findInstanceData(int instanceIndex = 0) const
40  {
41  const auto* instance = derived<DerivedT>(this).findInstance(instanceIndex);
42  return instance ? instance->data() : nullptr;
43  }
44 
45 
46  template <class AronDtoT>
47  std::optional<AronDtoT>
48  findInstanceDataAs(int instanceIndex = 0) const
49  {
50  return getInstanceDataAs<AronDtoT>(derived<DerivedT>(this).findInstanceData(instanceIndex));
51  }
52 
53  };
54 
55 
56 
57  template <class DerivedT>
59  {
60 
62  findLatestInstanceData(int instanceIndex = 0) const
63  {
64  const auto* instance = derived<DerivedT>(this).findLatestInstance(instanceIndex);
65  return instance ? instance->data() : nullptr;
66  }
67 
68 
69  template <class AronDtoT>
70  std::optional<AronDtoT>
71  findLatestInstanceDataAs(int instanceIndex = 0) const
72  {
73  return getInstanceDataAs<AronDtoT>(derived<DerivedT>(this).findLatestInstanceData(instanceIndex));
74  }
75 
76  };
77 
78 
79 
80  template <class DerivedT>
82  {
83 
85  findLatestInstanceData(const MemoryID& entityID, int instanceIndex = 0) const
86  {
87  const auto* instance = derived<DerivedT>(this).findLatestInstance(entityID, instanceIndex);
88  return instance ? instance->data() : nullptr;
89  }
90 
91  template <class AronDtoT>
92  std::optional<AronDtoT>
93  findLatestInstanceDataAs(const MemoryID& entityID, int instanceIndex = 0) const
94  {
95  return getInstanceDataAs<AronDtoT>(derived<DerivedT>(this).findLatestInstanceData(entityID, instanceIndex));
96  }
97 
98  };
99 
100 }
armarx::armem::wm::detail::FindInstanceDataMixin::findLatestInstanceDataAs
std::optional< AronDtoT > findLatestInstanceDataAs(const MemoryID &entityID, int instanceIndex=0) const
Definition: data_lookup_mixins.h:93
armarx::armem::wm::detail::FindInstanceDataMixin::findLatestInstanceData
aron::data::DictPtr findLatestInstanceData(const MemoryID &entityID, int instanceIndex=0) const
Definition: data_lookup_mixins.h:85
forward_declarations.h
armarx::armem::wm::detail
Definition: data_lookup_mixins.h:11
armarx::armem::wm::detail::FindInstanceDataMixin
Definition: data_lookup_mixins.h:81
armarx::armem::wm::detail::FindInstanceDataMixinForEntity::findLatestInstanceData
aron::data::DictPtr findLatestInstanceData(int instanceIndex=0) const
Definition: data_lookup_mixins.h:62
armarx::armem::base::detail::derived
DerivedT & derived(ThisT *t)
Definition: derived.h:9
armarx::armem::wm::detail::getInstanceDataAs
std::optional< AronDtoT > getInstanceDataAs(aron::data::DictPtr data)
Definition: data_lookup_mixins.h:18
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
forward_declarations.h
armarx::armem::wm::detail::FindInstanceDataMixinForEntity::findLatestInstanceDataAs
std::optional< AronDtoT > findLatestInstanceDataAs(int instanceIndex=0) const
Definition: data_lookup_mixins.h:71
armarx::armem::wm::detail::FindInstanceDataMixinForSnapshot::findInstanceDataAs
std::optional< AronDtoT > findInstanceDataAs(int instanceIndex=0) const
Definition: data_lookup_mixins.h:48
armarx::armem::wm::detail::FindInstanceDataMixinForEntity
Definition: data_lookup_mixins.h:58
derived.h
armarx::aron::data::DictPtr
std::shared_ptr< Dict > DictPtr
Definition: Dict.h:41
armarx::armem::wm::detail::FindInstanceDataMixinForSnapshot::findInstanceData
aron::data::DictPtr findInstanceData(int instanceIndex=0) const
Definition: data_lookup_mixins.h:39
armarx::armem::wm::detail::FindInstanceDataMixinForSnapshot
Definition: data_lookup_mixins.h:35