1 #ifndef _SERVICE_DISCOVERY_SERVICEPATTERN_CORE_H_
2 #define _SERVICE_DISCOVERY_SERVICEPATTERN_CORE_H_
6 #include <boost/regex.hpp>
7 #include <service_discovery/impl/avahi/ServiceConfiguration.hpp>
9 namespace servicediscovery {
23 SearchPattern(
const std::string& _name =
".*" ,
const std::string& _label =
".*",
const std::string& _txt =
".*",
const std::string _type =
".*")
25 , labelPattern(_label)
30 virtual ~SearchPattern() {}
32 boost::regex namePattern;
33 boost::regex labelPattern;
34 boost::regex txtPattern;
35 boost::regex typePattern;
41 virtual bool isMatching(
const ServiceDescription& description)
const;
70 virtual ~ServicePattern() {}
78 virtual bool matchDescription(
const ServiceDescription& service)
const = 0;
98 struct PropertyPattern :
public ServicePattern
100 PropertyPattern(
const std::string& label =
"*",
const std::string& expression =
".*")
101 : label(label), expression(expression, boost::regex::extended) {}
103 virtual ~PropertyPattern() {}
105 bool matchDescription(
const ServiceDescription& service)
const;
109 boost::regex expression;
116 std::string hasAuthority(
int authority);
128 struct PositionPattern :
public ServicePattern
130 PositionPattern(
int x,
int y,
int z,
double distance)
131 : x(x), y(y), z(z), distance(distance) {}
133 virtual ~PositionPattern() {}
135 bool matchDescription(
const ServiceDescription& service)
const;
150 struct FlagPattern :
public ServicePattern
152 FlagPattern(
int flags) : flags(flags) {}
154 virtual ~FlagPattern() {}
156 bool matchDescription(
const ServiceDescription& service)
const;
179 struct MultiPattern :
public ServicePattern
183 virtual ~MultiPattern() {}
185 bool matchDescription(
const ServiceDescription& service)
const;
187 MultiPattern& operator<<(
const ServicePattern& pattern) {
188 patterns.push_back(&pattern);
193 std::vector<const ServicePattern*> patterns;
201 struct AuthorityPattern :
public ServicePattern
203 AuthorityPattern(
int authority,
bool atleast =
true) : authority(authority), atleast(atleast) {}
205 virtual ~AuthorityPattern() {}
207 bool matchDescription(
const ServiceDescription& service)
const;
216 #endif // _SERVICE_DISCOVERY_SERVICEPATTERN_CORE_H_
std::string castFlags(pattern::Flags flags)
Definition: ServicePattern.cpp:58