hwsd  1.4.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 private:
80  detail::Filter* const impl_;
81 };
82 
84 inline FilterPtr operator | ( FilterPtr a, FilterPtr b )
85 { return (*a) |= b; }
86 
88 class DuplicateFilter : public Filter
89 {
90 public:
91  virtual ~DuplicateFilter() {}
92 
97  HWSD_API virtual bool operator() ( const GPUInfos& current,
98  const GPUInfo& candidate );
99 
100  HWSD_API virtual bool operator() ( const NetInfos& current,
101  const NetInfo& candidate );
102 };
103 
105 class MirrorFilter : public Filter
106 {
107 public:
108  virtual ~MirrorFilter() {}
109 
115  HWSD_API virtual bool operator() ( const GPUInfos& current,
116  const GPUInfo& candidate );
117 };
118 
120 class SessionFilter : public Filter
121 {
122 public:
124  HWSD_API explicit SessionFilter( const std::string& name );
125  HWSD_API virtual ~SessionFilter();
126 
128  HWSD_API virtual bool operator() ( const GPUInfos& current,
129  const GPUInfo& candidate );
130 
131  HWSD_API virtual bool operator() ( const NetInfos& current,
132  const NetInfo& candidate );
133 private:
134  detail::SessionFilter* const impl_;
135 };
136 
138 class GPUFilter : public Filter
139 {
140 public:
145  HWSD_API explicit GPUFilter( const std::string& regex );
146  HWSD_API virtual ~GPUFilter();
147 
152  HWSD_API virtual bool operator() ( const hwsd::GPUInfos& current,
153  const hwsd::GPUInfo& candidate );
154 private:
155  detail::GPUFilter* const impl_;
156 };
157 
159 class NetFilter : public Filter
160 {
161 public:
162  HWSD_API NetFilter( const lunchbox::Strings& prefixes,
163  const uint32_t type );
164  HWSD_API virtual ~NetFilter();
165 
170  HWSD_API virtual bool operator() ( const hwsd::NetInfos& current,
171  const hwsd::NetInfo& candidate );
172 private:
173  detail::NetFilter* const impl_;
174 };
175 }
176 #endif // HWSD_FILTER_H
virtual bool operator()(const hwsd::NetInfos &current, const hwsd::NetInfo &candidate)
SessionFilter(const std::string &name)
Matches the given name literally.
Defines export visibility macros for library hwsd.
Filter()
Create a new filter.
Filter overlapping duplicates with different GPU types.
Definition: filter.h:105
Filters for a specific session.
Definition: filter.h:120
GPUFilter(const std::string &regex)
Matches the GPU agaings the given regex.
Definition: filter.h:27
FilterPtr operator|=(FilterPtr rhs)
Chain another filter to this one.
virtual bool operator()(const hwsd::GPUInfos &current, const hwsd::GPUInfo &candidate)
A structure containing network-specific information.
Definition: netInfo.h:32
virtual bool operator()(const GPUInfos &current, const GPUInfo &candidate)
virtual bool operator()(const GPUInfos &current, const GPUInfo &candidate)
Base class for all discovery filters.
Definition: filter.h:38
Filter for network interfaces matching prefixes and/or type.
Definition: filter.h:159
A structure containing GPU-specific information.
Definition: gpuInfo.h:33
FilterPtr operator|(FilterPtr rhs)
Chain another filter to this one.
virtual bool operator()(const GPUInfos &current, const GPUInfo &candidate)
virtual bool operator()(const GPUInfos &current, const GPUInfo &candidate)
Call all chained operators.
Filters for a specific GPU regex.
Definition: filter.h:138
Filters all duplicates during discovery.
Definition: filter.h:88
virtual ~Filter()
Destruct this filter.