query_fns.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "selectors.h"
4 
5 
7 {
8 
9  inline auto
10  all()
11  {
12  return [ ](auto & selector)
13  {
14  selector.all();
15  };
16  }
17 
18 
19  inline auto
20  withID(const MemoryID& id)
21  {
22  return [ & ](auto & selector)
23  {
24  selector.withID(id);
25  };
26  }
27 
28 
29  // NAME-BASED QUERIES
30 
31  inline
32  auto withName(const std::string& name)
33  {
34  return [ &name ](auto & selector)
35  {
36  selector.withName(name);
37  };
38  }
39 
40  inline auto withNamesMatching(const std::string& regex)
41  {
42  return [ &regex ](auto & selector)
43  {
44  selector.withNamesMatching(regex);
45  };
46  }
47 
48  inline auto withNames(const std::vector<std::string>& names)
49  {
50  return [ &names ](auto & selector)
51  {
52  selector.withNames(names);
53  };
54  }
55  template <class StringContainerT>
56  auto withNames(const StringContainerT& names)
57  {
58  return [ &names ](auto & selector)
59  {
60  selector.withNames(names);
61  };
62  }
63  template <class IteratorT>
64  auto withNames(IteratorT begin, IteratorT end)
65  {
66  return [ begin, end ](auto & selector)
67  {
68  selector.withNames(begin, end);
69  };
70  }
71 
72  inline auto withNamesStartingWith(const std::string& prefix)
73  {
74  return [ &prefix ](auto & selector)
75  {
76  selector.withNamesStartingWith(prefix);
77  };
78  }
79  inline auto withNamesEndingWith(const std::string& suffix)
80  {
81  return [ &suffix ](auto & selector)
82  {
83  selector.withNamesEndingWith(suffix);
84  };
85  }
86  inline auto withNamesContaining(const std::string& substring)
87  {
88  return [ &substring ](auto & selector)
89  {
90  selector.withNamesContaining(substring);
91  };
92  }
93 
94 
95  // SNAPSHOT QUERIES
96 
97  inline
98  std::function<void(query::SnapshotSelector&)>
99  atTime(Time time)
100  {
101  return [ = ](query::SnapshotSelector & selector)
102  {
103  selector.atTime(time);
104  };
105  }
106 
107  inline
108  std::function<void(query::SnapshotSelector&)>
110  {
111  return [ = ](query::SnapshotSelector & selector)
112  {
113  selector.latest();
114  };
115  }
116 
117  inline
118  std::function<void(query::SnapshotSelector&)>
119  indexRange(long first, long last)
120  {
121  return [ = ](query::SnapshotSelector & selector)
122  {
123  selector.indexRange(first, last);
124  };
125  }
126 
127  inline
128  std::function<void(query::SnapshotSelector&)>
130  {
131  return [ = ](query::SnapshotSelector & selector)
132  {
133  selector.timeRange(min, max);
134  };
135  }
136 
137  inline
138  std::function<void(query::SnapshotSelector&)>
140  {
141  return [ = ](query::SnapshotSelector & selector)
142  {
143  selector.atTimeApprox(time, eps);
144  };
145  }
146 
147  inline
148  std::function<void(query::SnapshotSelector&)>
150  {
151  return [ = ](query::SnapshotSelector & selector)
152  {
153  selector.beforeOrAtTime(time);
154  };
155  }
156 
157  inline
158  std::function<void(query::SnapshotSelector&)>
159  beforeTime(Time time, long nElements = 1)
160  {
161  return [ = ](query::SnapshotSelector & selector)
162  {
163  selector.beforeTime(time, nElements);
164  };
165  }
166 
167 } // namespace armarx::armem::client::query_fns
armarx::armem::client::query_fns::indexRange
std::function< void(query::SnapshotSelector &)> indexRange(long first, long last)
Definition: query_fns.h:119
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:267
armarx::armem::client::query_fns::withName
auto withName(const std::string &name)
Definition: query_fns.h:32
armarx::armem::client::query::SnapshotSelector
Definition: selectors.h:13
armarx::armem::client::query_fns::beforeOrAtTime
std::function< void(query::SnapshotSelector &)> beforeOrAtTime(Time time)
Definition: query_fns.h:149
armarx::armem::client::query_fns::withNamesEndingWith
auto withNamesEndingWith(const std::string &suffix)
Definition: query_fns.h:79
armarx::armem::client::query_fns::all
auto all()
Definition: query_fns.h:10
armarx::armem::MemoryID
A memory ID.
Definition: MemoryID.h:47
armarx::armem::client::query_fns::atTimeApprox
std::function< void(query::SnapshotSelector &)> atTimeApprox(Time time, Duration eps)
Definition: query_fns.h:139
selectors.h
armarx::armem::client::query_fns::withNamesMatching
auto withNamesMatching(const std::string &regex)
Definition: query_fns.h:40
armarx::armem::client::query_fns::withNamesStartingWith
auto withNamesStartingWith(const std::string &prefix)
Definition: query_fns.h:72
armarx::armem::client::query_fns::withNamesContaining
auto withNamesContaining(const std::string &substring)
Definition: query_fns.h:86
armarx::armem::client::query_fns::beforeTime
std::function< void(query::SnapshotSelector &)> beforeTime(Time time, long nElements=1)
Definition: query_fns.h:159
armarx::armem::client::query_fns::timeRange
std::function< void(query::SnapshotSelector &)> timeRange(Time min, Time max)
Definition: query_fns.h:129
armarx::armem::client::query_fns::withNames
auto withNames(const std::vector< std::string > &names)
Definition: query_fns.h:48
armarx::armem::client::query_fns::latest
std::function< void(query::SnapshotSelector &)> latest()
Definition: query_fns.h:109
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:14
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:294
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::armem::client::query_fns::atTime
std::function< void(query::SnapshotSelector &)> atTime(Time time)
Definition: query_fns.h:99
armarx::armem::client::query_fns::withID
auto withID(const MemoryID &id)
Definition: query_fns.h:20
armarx::armem::client::query_fns
Definition: query_fns.h:6