BaseQueryProcessorBase.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <RobotAPI/interface/armem/query.h>
5 
6 #include <Ice/Handle.h>
7 
8 #include <set>
9 #include <vector>
10 
12 {
13 
14  using QueryTarget = armem::query::data::QueryTarget::QueryTargetEnum;
15 
16 
17  /**
18  * @brief Base class for memory query processors.
19  */
20  template <class DataT, class ResultT, class QueryT>
22  {
23  public:
24 
26  using QuerySeqT = std::vector<QueryPtrT>;
27 
28 
29  public:
30 
31  virtual ~BaseQueryProcessorBase() = default;
32 
33  ResultT process(const QueryT& query, const DataT& data) const
34  {
35  ResultT result { data.id() };
36  this->process(result, query, data);
37  return result;
38  }
39 
40  ResultT process(const QueryPtrT& query, const DataT& data) const
41  {
42  return this->process(*query, *data);
43  }
44 
45  ResultT process(const QuerySeqT& queries, const DataT& data) const
46  {
47  ResultT result { data.id() };
48  this->process(result, queries, data);
49  return result;
50  }
51 
52  void process(ResultT& result, const QuerySeqT& queries, const DataT& data) const
53  {
54  if (queries.empty())
55  {
56  return;
57  }
58 
59  for (const auto& query : queries)
60  {
61  this->process(result, *query, data);
62  }
63  }
64 
65 
66  /**
67  * @brief Process the query and populate `result`.
68  *
69  * @param result The result container.
70  * @param query The query.
71  * @param data The source container.
72  */
73  virtual void process(ResultT& result, const QueryT& query, const DataT& data) const = 0;
74 
75  };
76 
77 
78 }
armarx::armem::server::query_proc::base
Definition: BaseQueryProcessorBase.cpp:6
armarx::armem::server::query_proc::base::BaseQueryProcessorBase::process
ResultT process(const QueryPtrT &query, const DataT &data) const
Definition: BaseQueryProcessorBase.h:40
armarx::armem::server::query_proc::base::BaseQueryProcessorBase
Base class for memory query processors.
Definition: BaseQueryProcessorBase.h:21
armarx::armem::server::query_proc::base::BaseQueryProcessorBase::~BaseQueryProcessorBase
virtual ~BaseQueryProcessorBase()=default
IceInternal::Handle
Definition: forward_declarations.h:8
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::armem::server::query_proc::base::BaseQueryProcessorBase::process
ResultT process(const QuerySeqT &queries, const DataT &data) const
Definition: BaseQueryProcessorBase.h:45
armarx::armem::server::query_proc::base::BaseQueryProcessorBase::process
ResultT process(const QueryT &query, const DataT &data) const
Definition: BaseQueryProcessorBase.h:33
armarx::armem::server::query_proc::base::BaseQueryProcessorBase::process
void process(ResultT &result, const QuerySeqT &queries, const DataT &data) const
Definition: BaseQueryProcessorBase.h:52
armarx::armem::server::query_proc::base::BaseQueryProcessorBase< armem::server::ltm::CoreSegment, armem::wm::CoreSegment, armem::query::data::CoreSegmentQuery >::QuerySeqT
std::vector< QueryPtrT > QuerySeqT
Definition: BaseQueryProcessorBase.h:26
armarx::armem::server::query_proc::base::QueryTarget
armem::query::data::QueryTarget::QueryTargetEnum QueryTarget
Definition: BaseQueryProcessorBase.h:14
QueryTarget.h