Hurricane VLSI Database


Filter.h
1 // ****************************************************************************************************
2 // File: ./hurricane/Filter.h
3 // Authors: R. Escassut
4 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
5 //
6 // This file is part of Hurricane.
7 //
8 // Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU
9 // Lesser General Public License as published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
11 //
12 // Hurricane is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the Lesser GNU General Public License along with Hurricane. If
17 // not, see <http://www.gnu.org/licenses/>.
18 // ****************************************************************************************************
19 
20 #ifndef HURRICANE_FILTER
21 #define HURRICANE_FILTER
22 
23 #include "hurricane/Commons.h"
24 
25 namespace Hurricane {
26 
27 template<class Type> class GenericFilter;
28 template<class Type> class NotFilter;
29 
30 
31 
32 // ****************************************************************************************************
33 // Filter declaration
34 // ****************************************************************************************************
35 
36 template<class Type> class Filter {
37 // *********************************************************
38 
39 // Constructors
40 // ************
41 
42  public: Filter() {};
43 
44  private: Filter(const Filter& filter); // not implemented to forbid copie
45 
46 // Destructor
47 // **********
48 
49  public: virtual ~Filter() {};
50 
51 // Operators
52 // *********
53 
54  private: Filter& operator=(const Filter& filter); // not implemented to forbid assigment
55 
57  // ******************************************
58  {
59  return NotFilter<Type>(*this);
60  };
61 
62 // Accessors
63 // *********
64 
65  public: virtual Filter<Type>* getClone() const = 0;
66 
67 // Predicates
68 // **********
69 
70  public: virtual bool accept(Type type) const = 0;
71 
72 // Others
73 // ******
74 
75  public: virtual string _getTypeName() const { return _TName("Filter"); };
76  public: virtual string _getString() const = 0;
77 
78 };
79 
80 
81 
82 // ****************************************************************************************************
83 // GenericFilter declaration
84 // ****************************************************************************************************
85 
86 template<class Type> class GenericFilter : public Filter<Type> {
87 // ***********************************************************
88 
89 // Types
90 // *****
91 
92  public: typedef Filter<Type> Inherit;
93 
94 // Attributes
95 // **********
96 
97  private: Filter<Type>* _filter;
98 
99 // Constructors
100 // ************
101 
102  public: GenericFilter()
103  // ********************
104  : Inherit(),
105  _filter(NULL)
106  {
107  };
108 
109  public: GenericFilter(const Filter<Type>& filter)
110  // **********************************************
111  : Inherit(),
112  _filter(filter.getClone())
113  {
114  };
115 
116  public: GenericFilter(const GenericFilter<Type>& genericFilter)
117  // ************************************************************
118  : Inherit(),
119  _filter(genericFilter.getClone())
120  {
121  };
122 
123  public: GenericFilter(Filter<Type>* filter)
124  // *****************************************************
125  // CAUTION : filter will be deleted by the GenericFilter
126  // *****************************************************
127  : Inherit(),
128  _filter(filter)
129  {
130  };
131 
132 // Destructor
133 // **********
134 
135  public: virtual ~GenericFilter()
136  // *****************************
137  {
138  if (_filter) delete _filter;
139  };
140 
141 // Operators
142 // *********
143 
144  public: GenericFilter& operator=(const Filter<Type>& filter)
145  // *********************************************************
146  {
147  if (_filter) delete _filter;
148  _filter = filter.getClone();
149  return *this;
150  };
151 
152  public: GenericFilter& operator=(const GenericFilter& genericFilter)
153  // *****************************************************************
154  {
155  if (_filter) delete _filter;
156  _filter = genericFilter.getClone();
157  return *this;
158  };
159 
160  public: GenericFilter& operator=(Filter<Type>* filter)
161  // *****************************************************
162  // CAUTION : filter will be deleted by the GenericFilter
163  // *****************************************************
164  {
165  if (_filter) delete _filter;
166  _filter = filter;
167  return *this;
168  };
169 
170 // Accessors
171 // *********
172 
173  public: virtual Filter<Type>* getClone() const
174  // *******************************************
175  {
176  return (_filter) ? _filter->getClone() : NULL;
177  };
178 
179 // Predicates
180 // **********
181 
182  public: virtual bool accept(Type type) const
183  // *****************************************
184  {
185  return (_filter) ? _filter->accept(type) : false;
186  };
187 
188 // Others
189 // ******
190 
191  public: virtual string _getTypeName() const
192  // **************************************
193  {
194  return _TName("GenericFilter");
195  }
196 
197  public: virtual string _getString() const
198  // **************************************
199  {
200  if (!_filter)
201  return "<" + _getTypeName() + " unbound>";
202  else
203  return "<" + _getTypeName() + " " + getString(_filter) + ">";
204  };
205 
206 };
207 
208 
209 
210 // ****************************************************************************************************
211 // NotFilter declaration
212 // ****************************************************************************************************
213 
214 template<class Type> class NotFilter : public Filter<Type> {
215 // *******************************************************
216 
217 // Types
218 // *****
219 
220  public: typedef Filter<Type> Inherit;
221 
222 // Attributes
223 // **********
224 
225  private: GenericFilter<Type> _genericFilter;
226 
227 // Constructors
228 // ************
229 
230  public: NotFilter()
231  // ****************
232  : Inherit(),
233  _genericFilter()
234  {
235  };
236 
237  public: NotFilter(const Filter<Type>& filter)
238  // ******************************************
239  : Inherit(),
240  _genericFilter(filter)
241  {
242  };
243 
244  public: NotFilter(const NotFilter<Type>& notFilter)
245  // ************************************************
246  : Inherit(),
247  _genericFilter(notFilter._genericFilter)
248  {
249  };
250 
251 // Operators
252 // *********
253 
254  public: NotFilter& operator=(const NotFilter<Type>& notFilter)
255  // ***********************************************************
256  {
257  _genericFilter = notFilter._genericFilter;
258  return *this;
259  };
260 
261 // Accessors
262 // *********
263 
264  public: virtual Filter<Type>* getClone() const
265  // *******************************************
266  {
267  return new NotFilter(*this);
268  };
269 
270 // Predicates
271 // **********
272 
273  public: virtual bool accept(Type type) const
274  // *****************************************
275  {
276  return !_genericFilter.accept(type);
277  };
278 
279 // Others
280 // ******
281 
282  public: virtual string _getTypeName() const
283  // **************************************
284  {
285  return _TName("GenericNotFilter");
286  }
287 
288  public: virtual string _getString() const
289  // **************************************
290  {
291  return "<" + _getTypeName() + " " + getString(_genericFilter) + ">";
292  };
293 
294 };
295 
296 
297 // ****************************************************************************************************
298 // Generic functions
299 // ****************************************************************************************************
300 
301 
302 
303 } // End of Hurricane namespace.
304 
305 
306 #endif // HURRICANE_FILTER
307 
308 
309 // ****************************************************************************************************
310 // Copyright (c) BULL S.A. 2000-2018, All Rights Reserved
311 // ****************************************************************************************************
Filter description (API)
Definition: Filter.h:36
virtual Filter< Type > * getClone() const =0
GenericFilter< Type > operator!() const
Definition: Filter.h:56
virtual bool accept(Type type) const =0
Generic Filter auto-pointer.
Definition: Filter.h:86
GenericFilter(const Filter< Type > &filter)
Definition: Filter.h:109
GenericFilter(Filter< Type > *filter)
Definition: Filter.h:123
GenericFilter(const GenericFilter< Type > &genericFilter)
Definition: Filter.h:116
Filter negation.
Definition: Filter.h:214
NotFilter(const NotFilter< Type > &notFilter)
Definition: Filter.h:244
NotFilter(const Filter< Type > &filter)
Definition: Filter.h:237
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5


Generated by doxygen 1.9.1 on Thu Aug 11 2022 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved