VR-Forces 4.1.1 Class Documentation
featureSet.h
Go to the documentation of this file.
1 
2 
3 
4 
5 #pragma once
6 
8 #include <features/query.h>
9 
10 #include <boost/function.hpp>
11 #include <vector>
12 #include <memory>
13 
14 namespace MAKVRinTerra
15 {
16  class DtFeature;
17 
21  {
26  };
27 
31  {
36  };
37 
38  template <typename F, typename FS>
40 
48  template <typename F>
49  class DT_DLL_features DtFeatureSetTemplate : boost::noncopyable
50  {
51  public:
53  typedef F Feature;
54 
57 
59  typedef boost::function<void (const Feature&)> ForEachFunction;
60 
63  template <
64  typename WrappedFeature = Feature,
65  template <typename> class PtrTemplate = boost::scoped_ptr>
66  class Wrapper;
67 
70 
73 
76 
78 
82 
84  virtual ~DtFeatureSetTemplate();
85 
89  virtual void forEachFeature(ForEachFunction func, DtWaitType wait) const = 0;
90 
93  virtual void forEachFeatureParallel(ForEachFunction func, DtWaitType wait) const;
94 
104  virtual DtQuery schema() const;
105 
106  virtual DtFeatureSetTemplate* filter(
107  const DtQuery& query, DtLoadType load) const;
108 
114  virtual DtFeatureSetTemplate* clone() const = 0;
115 
127  virtual bool loaded(double timeout=0.0) const = 0;
128 
135  virtual unsigned numberOfFeatures() const;
136  };
137 
139  template <typename F>
141  {
142  return from.clone();
143  }
144 
146  template <typename F, typename FS>
148  {
149  public:
151 
154 
157  void add(FS* fs);
158  void add(const FS&);
159  void add(std::auto_ptr<FS>);
160 
162  unsigned size() const;
163 
164  void forEachFeature(ForEachFunction func, DtWaitType) const;
166  DtFeatureSetList* filter(const DtQuery&, DtLoadType) const;
167  DtFeatureSetList* clone() const;
168  DtQuery schema() const;
169  bool loaded(double = 0.0) const;
170  unsigned numberOfFeatures() const;
171 
172  protected:
174  explicit DtFeatureSetList(const DtFeatureSetList&);
175 
176  typedef std::list<FS*> PtrList;
177 
180  };
181 
183  template <typename F>
185  {
186  public:
188 
190  Filtered(const DtFeatureSetTemplate&, const DtQuery&);
191 
192  const DtFeatureSetTemplate& filteredFeatureSet() const;
193  const DtQuery& query() const;
194 
195  void forEachFeature(ForEachFunction func, DtWaitType) const;
198  Filtered* clone() const;
199  DtQuery schema() const;
200  bool loaded(double = 0.0) const;
201  unsigned numberOfFeatures() const;
202 
203  protected:
204  explicit Filtered(const Filtered&);
205 
206  private:
207  struct Caller;
208 
209  boost::scoped_ptr<DtFeatureSetTemplate> myFeatureSet;
212  };
213 
214  template <typename F>
216  {
217  public:
219 
221  Empty* filter(const DtQuery&, DtLoadType) const;
222  Empty* clone() const;
223  DtQuery schema() const;
224  bool loaded(double = 0.0) const;
225  unsigned numberOfFeatures() const;
226  };
227 
228  template <typename F>
230  {
231  public:
233 
234  typedef std::vector<typename F::CPtr> FeatureVector;
235 
236  static DtFeatureSetTemplate* Make(FeatureSet*);
237 
238  explicit Storage(const FeatureSet&);
239  explicit Storage(const DtQuery&);
240 
243  DtQuery schema() const;
244  Storage* clone() const;
245  bool loaded(double = 0.0) const;
246  unsigned numberOfFeatures() const;
247 
248  void addFeature(const F& feature);
249 
250  protected:
251  struct AddFeature;
252  struct ParallelCaller;
253 
254  explicit Storage(const Storage&);
255 
257  boost::shared_ptr<FeatureVector> myFeatures;
258  };
259 
261  template <typename F>
262  template <typename Wrapped, template <typename> class PtrTemplate>
264  {
265  public:
268 
269  typedef Wrapped WrappedFeature;
271  typedef PtrTemplate<WrappedFeatureSet> WrappedPtr;
272 
273  explicit Wrapper(const WrappedFeatureSet& fs)
274  : mySet(fs.clone())
275  {
276  }
277 
279  : mySet(fs)
280  {
281  }
282 
283  template <typename PtrType>
284  explicit Wrapper(PtrType fs)
285  : mySet(fs)
286  {
287  }
288 
289  bool isSet() const
290  {
291  return mySet.get();
292  }
293 
294  void set(WrappedFeatureSet* fs)
295  {
296  mySet.reset(fs);
297  }
298 
299  template <typename PtrType>
300  void set(PtrType fs)
301  {
302  mySet = fs;
303  }
304 
306  {
307  assert(mySet.get());
308  mySet->forEachFeature(func,wait);
309  }
310 
312  {
313  assert(mySet.get());
314  mySet->forEachFeatureParallel(func,wait);
315  }
316 
317  FeatureSet* filter(const DtQuery& query, DtLoadType load) const
318  {
319  assert(mySet.get());
320  return new Wrapper(mySet->filter(query,load));
321  }
322 
323  FeatureSet* clone() const
324  {
325  assert(mySet.get());
326  return new Wrapper(mySet->clone());
327  }
328 
329  DtQuery schema() const
330  {
331  assert(mySet.get());
332  return mySet->schema();
333  }
334 
335  bool loaded(double timeout = 0.0) const
336  {
337  assert(mySet.get());
338  return mySet->loaded(timeout);
339  }
340 
341  unsigned numberOfFeatures() const
342  {
343  assert(mySet.get());
344  return mySet->numberOfFeatures();
345  }
346 
347  protected:
349  };
350 
351  template <typename F>
352  template <template <typename> class PtrTemplate>
353  class DtFeatureSetTemplate<F>::Wrapper<F,PtrTemplate>
354  : public DtFeatureSetTemplate<F>
355  {
356  public:
359 
360  typedef F WrappedFeature;
362  typedef PtrTemplate<FeatureSet> WrappedPtr;
363 
364  explicit Wrapper(const WrappedFeatureSet& fs)
365  : mySet(fs.clone())
366  {
367  }
368 
370  : mySet(fs)
371  {
372  }
373 
374  template <typename PtrType>
375  explicit Wrapper(PtrType fs)
376  : mySet(fs)
377  {
378  }
379 
380  bool isSet() const
381  {
382  return mySet.get();
383  }
384 
385  void set(WrappedFeatureSet* fs)
386  {
387  mySet.reset(fs);
388  }
389 
390  template <typename PtrType>
391  void set(PtrType fs)
392  {
393  mySet = fs;
394  }
395 
397  {
398  assert(mySet.get());
399  mySet->forEachFeature(func,wait);
400  }
401 
403  {
404  assert(mySet.get());
405  mySet->forEachFeatureParallel(func,wait);
406  }
407 
408  FeatureSet* filter(const DtQuery& query, DtLoadType load) const
409  {
410  assert(mySet.get());
411  return mySet->filter(query,load);
412  }
413 
414  FeatureSet* clone() const
415  {
416  assert(mySet.get());
417  return mySet->clone();
418  }
419 
420  DtQuery schema() const
421  {
422  assert(mySet.get());
423  return mySet->schema();
424  }
425 
426  bool loaded(double timeout = 0.0) const
427  {
428  assert(mySet.get());
429  return mySet->loaded(timeout);
430  }
431 
432  unsigned numberOfFeatures() const
433  {
434  assert(mySet.get());
435  return mySet->numberOfFeatures();
436  }
437 
438  protected:
440  };
441 
443 }

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)