NameSelectorOps.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 
8 {
9 
10  template <class DerivedT>
12  {
13  public:
14 
15  NameSelectorOps() = default;
16  virtual ~NameSelectorOps() = default;
17 
18 
19  virtual DerivedT& withName(const std::string& name) = 0;
20  virtual DerivedT& withNamesMatching(const std::string& regex) = 0;
21 
22 
23  virtual DerivedT& withNames(const std::vector<std::string>& names)
24  {
25  return withNames<std::vector<std::string>>(names);
26  }
27 
28  template <class StringContainerT>
29  DerivedT& withNames(const StringContainerT& names)
30  {
31  return withNames(names.begin(), names.end());
32  }
33  template <class IteratorT>
34  DerivedT& withNames(IteratorT begin, IteratorT end)
35  {
36  for (auto it = begin; it != end; ++it)
37  {
38  this->withName(*it);
39  }
40  return dynamic_cast<DerivedT&>(*this);
41  }
42 
43 
44  virtual DerivedT& withNamesStartingWith(const std::string& prefix)
45  {
46  return withNamesMatching(prefix + ".*");
47  }
48  virtual DerivedT& withNamesEndingWith(const std::string& suffix)
49  {
50  return withNamesMatching(".*" + suffix);
51  }
52  virtual DerivedT& withNamesContaining(const std::string& substring)
53  {
54  return withNamesMatching(".*" + substring + ".*");
55  }
56 
57 
58  };
59 
60 }
armarx::armem::client::query::detail
Definition: NameSelectorOps.h:7
armarx::armem::client::query::detail::NameSelectorOps::withName
virtual DerivedT & withName(const std::string &name)=0
armarx::armem::client::query::detail::NameSelectorOps::withNamesStartingWith
virtual DerivedT & withNamesStartingWith(const std::string &prefix)
Definition: NameSelectorOps.h:44
armarx::armem::client::query::detail::NameSelectorOps::withNames
DerivedT & withNames(IteratorT begin, IteratorT end)
Definition: NameSelectorOps.h:34
armarx::armem::client::query::detail::NameSelectorOps
Definition: NameSelectorOps.h:11
armarx::armem::client::query::detail::NameSelectorOps::withNamesMatching
virtual DerivedT & withNamesMatching(const std::string &regex)=0
armarx::armem::client::query::detail::NameSelectorOps::withNames
virtual DerivedT & withNames(const std::vector< std::string > &names)
Definition: NameSelectorOps.h:23
armarx::armem::client::query::detail::NameSelectorOps::NameSelectorOps
NameSelectorOps()=default
armarx::viz::data::ElementFlags::names
const simox::meta::IntEnumNames names
Definition: json_elements.cpp:14
armarx::armem::client::query::detail::NameSelectorOps::withNamesEndingWith
virtual DerivedT & withNamesEndingWith(const std::string &suffix)
Definition: NameSelectorOps.h:48
armarx::armem::client::query::detail::NameSelectorOps::withNames
DerivedT & withNames(const StringContainerT &names)
Definition: NameSelectorOps.h:29
armarx::armem::client::query::detail::NameSelectorOps::~NameSelectorOps
virtual ~NameSelectorOps()=default
armarx::armem::client::query::detail::NameSelectorOps::withNamesContaining
virtual DerivedT & withNamesContaining(const std::string &substring)
Definition: NameSelectorOps.h:52