query_fns.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "selectors.h"
4 
6 {
7 
8  inline auto
9  all()
10  {
11  return [](auto& selector) { selector.all(); };
12  }
13 
14  inline auto
15  withID(const MemoryID& id)
16  {
17  return [&](auto& selector) { selector.withID(id); };
18  }
19 
20  // NAME-BASED QUERIES
21 
22  inline auto
23  withName(const std::string& name)
24  {
25  return [&name](auto& selector) { selector.withName(name); };
26  }
27 
28  inline auto
29  withNamesMatching(const std::string& regex)
30  {
31  return [&regex](auto& selector) { selector.withNamesMatching(regex); };
32  }
33 
34  inline auto
35  withNames(const std::vector<std::string>& names)
36  {
37  return [&names](auto& selector) { selector.withNames(names); };
38  }
39 
40  template <class StringContainerT>
41  auto
42  withNames(const StringContainerT& names)
43  {
44  return [&names](auto& selector) { selector.withNames(names); };
45  }
46 
47  template <class IteratorT>
48  auto
49  withNames(IteratorT begin, IteratorT end)
50  {
51  return [begin, end](auto& selector) { selector.withNames(begin, end); };
52  }
53 
54  inline auto
55  withNamesStartingWith(const std::string& prefix)
56  {
57  return [&prefix](auto& selector) { selector.withNamesStartingWith(prefix); };
58  }
59 
60  inline auto
61  withNamesEndingWith(const std::string& suffix)
62  {
63  return [&suffix](auto& selector) { selector.withNamesEndingWith(suffix); };
64  }
65 
66  inline auto
67  withNamesContaining(const std::string& substring)
68  {
69  return [&substring](auto& selector) { selector.withNamesContaining(substring); };
70  }
71 
72  // SNAPSHOT QUERIES
73 
74  inline std::function<void(query::SnapshotSelector&)>
75  atTime(Time time)
76  {
77  return [=](query::SnapshotSelector& selector) { selector.atTime(time); };
78  }
79 
80  inline std::function<void(query::SnapshotSelector&)>
82  {
83  return [=](query::SnapshotSelector& selector) { selector.latest(); };
84  }
85 
86  inline std::function<void(query::SnapshotSelector&)>
87  indexRange(long first, long last)
88  {
89  return [=](query::SnapshotSelector& selector) { selector.indexRange(first, last); };
90  }
91 
92  inline std::function<void(query::SnapshotSelector&)>
94  {
95  return [=](query::SnapshotSelector& selector) { selector.timeRange(min, max); };
96  }
97 
98  inline std::function<void(query::SnapshotSelector&)>
100  {
101  return [=](query::SnapshotSelector& selector) { selector.atTimeApprox(time, eps); };
102  }
103 
104  inline std::function<void(query::SnapshotSelector&)>
106  {
107  return [=](query::SnapshotSelector& selector) { selector.beforeOrAtTime(time); };
108  }
109 
110  inline std::function<void(query::SnapshotSelector&)>
111  beforeTime(Time time, long nElements = 1)
112  {
113  return [=](query::SnapshotSelector& selector) { selector.beforeTime(time, nElements); };
114  }
115 
116 } // 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:87
armarx::max
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:297
armarx::armem::client::query_fns::withName
auto withName(const std::string &name)
Definition: query_fns.h:23
armarx::armem::client::query::SnapshotSelector
Definition: selectors.h:11
armarx::armem::client::query_fns::beforeOrAtTime
std::function< void(query::SnapshotSelector &)> beforeOrAtTime(Time time)
Definition: query_fns.h:105
armarx::armem::client::query_fns::withNamesEndingWith
auto withNamesEndingWith(const std::string &suffix)
Definition: query_fns.h:61
armarx::armem::client::query_fns::all
auto all()
Definition: query_fns.h:9
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:99
selectors.h
armarx::armem::client::query_fns::withNamesMatching
auto withNamesMatching(const std::string &regex)
Definition: query_fns.h:29
armarx::armem::client::query_fns::withNamesStartingWith
auto withNamesStartingWith(const std::string &prefix)
Definition: query_fns.h:55
armarx::armem::client::query_fns::withNamesContaining
auto withNamesContaining(const std::string &substring)
Definition: query_fns.h:67
armarx::armem::client::query_fns::beforeTime
std::function< void(query::SnapshotSelector &)> beforeTime(Time time, long nElements=1)
Definition: query_fns.h:111
armarx::armem::client::query_fns::timeRange
std::function< void(query::SnapshotSelector &)> timeRange(Time min, Time max)
Definition: query_fns.h:93
armarx::armem::client::query_fns::withNames
auto withNames(const std::vector< std::string > &names)
Definition: query_fns.h:35
armarx::armem::client::query_fns::latest
std::function< void(query::SnapshotSelector &)> latest()
Definition: query_fns.h:81
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:13
armarx::min
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
Definition: VectorHelpers.h:327
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:16
armarx::armem::client::query_fns::atTime
std::function< void(query::SnapshotSelector &)> atTime(Time time)
Definition: query_fns.h:75
armarx::armem::client::query_fns::withID
auto withID(const MemoryID &id)
Definition: query_fns.h:15
armarx::armem::client::query_fns
Definition: query_fns.h:5