hwsd  2.0.0
Local and remote ZeroConf service discovery for hardware resources
filter.h
1 
2 /* Copyright (c) 2011-2013, Stefan Eilemann <eile@eyescale.ch>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef HWSD_FILTER_H
19 #define HWSD_FILTER_H
20 
21 #include <hwsd/api.h>
22 #include <hwsd/types.h>
23 
24 #include <lunchbox/referenced.h> // base class
25 #include <string>
26 
27 namespace hwsd
28 {
29 namespace detail
30 {
31 class Filter;
32 class SessionFilter;
33 class GPUFilter;
34 class NetFilter;
35 }
36 
38 class Filter : public lunchbox::Referenced
39 {
40 public:
42  HWSD_API Filter();
43 
45  HWSD_API virtual ~Filter();
46 
53  HWSD_API FilterPtr operator|(FilterPtr rhs);
54 
61  HWSD_API FilterPtr operator|=(FilterPtr rhs);
62 
74  HWSD_API virtual bool operator()(const GPUInfos& current,
75  const GPUInfo& candidate);
76 
77  HWSD_API virtual bool operator()(const NetInfos& current,
78  const NetInfo& candidate);
79 
80 private:
81  detail::Filter* const impl_;
82 };
83 
85 inline FilterPtr operator|(FilterPtr a, FilterPtr b)
86 {
87  return (*a) |= b;
88 }
89 
91 class DuplicateFilter : public Filter
92 {
93 public:
94  virtual ~DuplicateFilter() {}
99  HWSD_API virtual bool operator()(const GPUInfos& current,
100  const GPUInfo& candidate);
101 
102  HWSD_API virtual bool operator()(const NetInfos& current,
103  const NetInfo& candidate);
104 };
105 
107 class MirrorFilter : public Filter
108 {
109 public:
110  virtual ~MirrorFilter() {}
116  HWSD_API virtual bool operator()(const GPUInfos& current,
117  const GPUInfo& candidate);
118 };
119 
121 class SessionFilter : public Filter
122 {
123 public:
125  HWSD_API explicit SessionFilter(const std::string& name);
126  HWSD_API virtual ~SessionFilter();
127 
129  HWSD_API virtual bool operator()(const GPUInfos& current,
130  const GPUInfo& candidate);
131 
132  HWSD_API virtual bool operator()(const NetInfos& current,
133  const NetInfo& candidate);
134 
135 private:
136  detail::SessionFilter* const impl_;
137 };
138 
140 class GPUFilter : public Filter
141 {
142 public:
147  HWSD_API explicit GPUFilter(const std::string& regex);
148  HWSD_API virtual ~GPUFilter();
149 
154  HWSD_API virtual bool operator()(const hwsd::GPUInfos& current,
155  const hwsd::GPUInfo& candidate);
156 
157 private:
158  detail::GPUFilter* const impl_;
159 };
160 
162 class NetFilter : public Filter
163 {
164 public:
165  HWSD_API NetFilter(const lunchbox::Strings& prefixes, const uint32_t type);
166  HWSD_API virtual ~NetFilter();
167 
172  HWSD_API virtual bool operator()(const hwsd::NetInfos& current,
173  const hwsd::NetInfo& candidate);
174 
175 private:
176  detail::NetFilter* const impl_;
177 };
178 }
179 #endif // HWSD_FILTER_H
Defines export visibility macros for library hwsd.
Filter overlapping duplicates with different GPU types.
Definition: filter.h:107
Filters for a specific session.
Definition: filter.h:121
Definition: filter.h:27
A structure containing network-specific information.
Definition: netInfo.h:32
Base class for all discovery filters.
Definition: filter.h:38
Filter for network interfaces matching prefixes and/or type.
Definition: filter.h:162
A structure containing GPU-specific information.
Definition: gpuInfo.h:32
Filters for a specific GPU regex.
Definition: filter.h:140
Filters all duplicates during discovery.
Definition: filter.h:91