query_fns.h
Go to the documentation of this file.
1#pragma once
2
3#include "selectors.h"
4
6{
7
8 inline auto
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&)>
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
std::function< void(query::SnapshotSelector &)> latest()
Definition query_fns.h:81
std::function< void(query::SnapshotSelector &)> atTimeApprox(Time time, Duration eps)
Definition query_fns.h:99
auto withNames(const std::vector< std::string > &names)
Definition query_fns.h:35
auto withNamesStartingWith(const std::string &prefix)
Definition query_fns.h:55
auto withID(const MemoryID &id)
Definition query_fns.h:15
std::function< void(query::SnapshotSelector &)> beforeTime(Time time, long nElements=1)
Definition query_fns.h:111
std::function< void(query::SnapshotSelector &)> beforeOrAtTime(Time time)
Definition query_fns.h:105
std::function< void(query::SnapshotSelector &)> indexRange(long first, long last)
Definition query_fns.h:87
std::function< void(query::SnapshotSelector &)> atTime(Time time)
Definition query_fns.h:75
auto withName(const std::string &name)
Definition query_fns.h:23
auto withNamesContaining(const std::string &substring)
Definition query_fns.h:67
auto withNamesEndingWith(const std::string &suffix)
Definition query_fns.h:61
auto withNamesMatching(const std::string &regex)
Definition query_fns.h:29
std::function< void(query::SnapshotSelector &)> timeRange(Time min, Time max)
Definition query_fns.h:93
armarx::core::time::DateTime Time
armarx::core::time::Duration Duration
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)