hwsd  1.1.1
 All Classes Files Functions Variables Enumerations Enumerator Pages
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 }
37  class Filter : public lunchbox::Referenced
38  {
39  public:
41  HWSD_API Filter();
42 
44  HWSD_API virtual ~Filter();
45 
52  HWSD_API FilterPtr operator | ( FilterPtr rhs );
53 
60  HWSD_API FilterPtr operator |= ( FilterPtr rhs );
61 
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:
127  HWSD_API SessionFilter( const std::string& name );
128  HWSD_API virtual ~SessionFilter();
129 
131  HWSD_API virtual bool operator() ( const GPUInfos& current,
132  const GPUInfo& candidate );
133 
134  HWSD_API virtual bool operator() ( const NetInfos& current,
135  const NetInfo& candidate );
136  private:
137  detail::SessionFilter* const impl_;
138  };
139 
141  class GPUFilter : public Filter
142  {
143  public:
148  HWSD_API GPUFilter( const std::string& regex );
149  HWSD_API virtual ~GPUFilter();
150 
155  HWSD_API virtual bool operator() ( const hwsd::GPUInfos& current,
156  const hwsd::GPUInfo& candidate );
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,
166  const uint32_t type );
167  HWSD_API virtual ~NetFilter();
168 
173  HWSD_API virtual bool operator() ( const hwsd::NetInfos& current,
174  const hwsd::NetInfo& candidate );
175  private:
176  detail::NetFilter* const impl_;
177  };
178 }
179 #endif // HWSD_FILTER_H
virtual HWSD_API bool operator()(const GPUInfos &current, const GPUInfo &candidate)
Defines export visibility macros for hwsd.
HWSD_API Filter()
Create a new filter.
HWSD_API FilterPtr operator|=(FilterPtr rhs)
Chain another filter to this one.
Filter overlapping duplicates with different GPU types.
Definition: filter.h:105
virtual HWSD_API ~Filter()
Destruct this filter.
Filters for a specific session.
Definition: filter.h:120
virtual HWSD_API bool operator()(const GPUInfos &current, const GPUInfo &candidate)
Call all chained operators.
HWSD_API SessionFilter(const std::string &name)
Matches the given name literally.
virtual HWSD_API bool operator()(const hwsd::GPUInfos &current, const hwsd::GPUInfo &candidate)
virtual HWSD_API bool operator()(const hwsd::NetInfos &current, const hwsd::NetInfo &candidate)
A structure containing network-specific information.
Definition: netInfo.h:32
HWSD_API GPUFilter(const std::string &regex)
Matches the GPU agaings the given regex.
HWSD_API FilterPtr operator|(FilterPtr rhs)
Chain another filter to this one.
Base class for all discovery filters.
Definition: filter.h:37
Filter for network interfaces matching prefixes and/or type.
Definition: filter.h:162
A structure containing GPU-specific information.
Definition: gpuInfo.h:33
virtual HWSD_API bool operator()(const GPUInfos &current, const GPUInfo &candidate)
Filters for a specific GPU regex.
Definition: filter.h:141
virtual HWSD_API bool operator()(const GPUInfos &current, const GPUInfo &candidate)
Filters all duplicates during discovery.
Definition: filter.h:88