OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
image_state_visitor.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 // Copyright (C) 2003-2010 by the IPLT authors
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 3.0 of the License, or (at your option)
10 // any later version.
11 // This library is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 // details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //------------------------------------------------------------------------------
20 
21 /*
22  Author: Ansgar Philippsen
23 */
24 
25 #ifndef IMG_IMAGE_STATE_VISITOR_HH
26 #define IMG_IMAGE_STATE_VISITOR_HH
27 
29 #include "image_state_impl.hh"
30 #include "image_state_def.hh"
31 
32 namespace ost { namespace img { namespace image_state {
33 
35 class DLLEXPORT InvalidImageStateVisitor: public Error {
36 public:
38 };
39 
40 /*
41  one-time definition of the constructor adapters, allowing
42  zero to 10 ctor parameters to be automagically used. There
43  is probably a recursive way to do this more elegantly...
44 */
45 
46 #define IMAGE_STATE_VISITOR_CTOR_ADAPTERS(CLASS) \
47  /* no param */ \
48  CLASS (): FNC() {} \
49  /* 1 param */ \
50  template <class P0> \
51  CLASS (const P0& p0): \
52  FNC(p0) {} \
53  /* 2 params */ \
54  template <class P0, \
55  class P1> \
56  CLASS (const P0& p0, \
57  const P1& p1): \
58  FNC(p0,p1) {} \
59  /* 3 params */ \
60  template <class P0, \
61  class P1, \
62  class P2> \
63  CLASS (const P0& p0, \
64  const P1& p1, \
65  const P2& p2): \
66  FNC(p0,p1,p2) {} \
67  /* 4 params */ \
68  template <class P0, \
69  class P1, \
70  class P2, \
71  class P3> \
72  CLASS (const P0& p0, \
73  const P1& p1, \
74  const P2& p2, \
75  const P3& p3): \
76  FNC(p0,p1,p2,p3) {} \
77  /* 5 params */ \
78  template <class P0, \
79  class P1, \
80  class P2, \
81  class P3, \
82  class P4> \
83  CLASS (const P0& p0, \
84  const P1& p1, \
85  const P2& p2, \
86  const P3& p3, \
87  const P4& p4): \
88  FNC(p0,p1,p2,p3,p4) {} \
89  /* 6 params */ \
90  template <class P0, \
91  class P1, \
92  class P2, \
93  class P3, \
94  class P4, \
95  class P5> \
96  CLASS (const P0& p0, \
97  const P1& p1, \
98  const P2& p2, \
99  const P3& p3, \
100  const P4& p4, \
101  const P5& p5): \
102  FNC(p0,p1,p2,p3,p4,p5) {} \
103  /* 7 params */ \
104  template <class P0, \
105  class P1, \
106  class P2, \
107  class P3, \
108  class P4, \
109  class P5, \
110  class P6> \
111  CLASS (const P0& p0, \
112  const P1& p1, \
113  const P2& p2, \
114  const P3& p3, \
115  const P4& p4, \
116  const P5& p5, \
117  const P6& p6): \
118  FNC(p0,p1,p2,p3,p4,p5,p6) {} \
119  /* 8 params */ \
120  template <class P0, \
121  class P1, \
122  class P2, \
123  class P3, \
124  class P4, \
125  class P5, \
126  class P6, \
127  class P7> \
128  CLASS (const P0& p0, \
129  const P1& p1, \
130  const P2& p2, \
131  const P3& p3, \
132  const P4& p4, \
133  const P5& p5, \
134  const P6& p6, \
135  const P7& p7): \
136  FNC(p0,p1,p2,p3,p4,p5,p6,p7) {} \
137  /* 9 params */ \
138  template <class P0, \
139  class P1, \
140  class P2, \
141  class P3, \
142  class P4, \
143  class P5, \
144  class P6, \
145  class P7, \
146  class P8> \
147  CLASS (const P0& p0, \
148  const P1& p1, \
149  const P2& p2, \
150  const P3& p3, \
151  const P4& p4, \
152  const P5& p5, \
153  const P6& p6, \
154  const P7& p7, \
155  const P8& p8): \
156  FNC(p0,p1,p2,p3,p4,p5,p6,p7,p8) {} \
157  /* 10 params */ \
158  template <class P0, \
159  class P1, \
160  class P2, \
161  class P3, \
162  class P4, \
163  class P5, \
164  class P6, \
165  class P7, \
166  class P8, \
167  class P9> \
168  CLASS (const P0& p0, \
169  const P1& p1, \
170  const P2& p2, \
171  const P3& p3, \
172  const P4& p4, \
173  const P5& p5, \
174  const P6& p6, \
175  const P7& p7, \
176  const P8& p8, \
177  const P9& p9): \
178  FNC(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9) {} \
179  /* 11 params */ \
180  template <class P0, \
181  class P1, \
182  class P2, \
183  class P3, \
184  class P4, \
185  class P5, \
186  class P6, \
187  class P7, \
188  class P8, \
189  class P9, \
190  class PA> \
191  CLASS (const P0& p0, \
192  const P1& p1, \
193  const P2& p2, \
194  const P3& p3, \
195  const P4& p4, \
196  const P5& p5, \
197  const P6& p6, \
198  const P7& p7, \
199  const P8& p8, \
200  const P9& p9, \
201  const PA& pa): \
202  FNC(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pa) {} \
203  /* 12 params */ \
204  template <class P0, \
205  class P1, \
206  class P2, \
207  class P3, \
208  class P4, \
209  class P5, \
210  class P6, \
211  class P7, \
212  class P8, \
213  class P9, \
214  class PA, \
215  class PB> \
216  CLASS (const P0& p0, \
217  const P1& p1, \
218  const P2& p2, \
219  const P3& p3, \
220  const P4& p4, \
221  const P5& p5, \
222  const P6& p6, \
223  const P7& p7, \
224  const P8& p8, \
225  const P9& p9, \
226  const PA& pa, \
227  const PB& pb): \
228  FNC(p0,p1,p2,p3,p4,p5,p6,p7,p8,p9,pa,pb) {}
229 
230 
233 public:
235  virtual void Visit_(const RealSpatialImageState& is) = 0;
236  virtual void Visit_(const ComplexSpatialImageState& is) = 0;
237  virtual void Visit_(const RealFrequencyImageState& is) = 0;
238  virtual void Visit_(const ComplexFrequencyImageState& is) = 0;
239  virtual void Visit_(const ComplexHalfFrequencyImageState& is) = 0;
240  virtual void Visit_(const WordSpatialImageState& is) = 0;
241 };
242 
243 
245 
301 template <class FNC>
302 class DLLEXPORT ImageStateNonModVisitor: public FNC, public ImageStateNonModVisitorBase {
303 public:
304 
306 
307  // base interface
308  virtual void Visit_(const RealSpatialImageState& is) {T_Visit_(is);}
309  virtual void Visit_(const ComplexSpatialImageState& is) {T_Visit_(is);}
310  virtual void Visit_(const RealFrequencyImageState& is) {T_Visit_(is);}
311  virtual void Visit_(const ComplexFrequencyImageState& is) {T_Visit_(is);}
312  virtual void Visit_(const ComplexHalfFrequencyImageState& is) {T_Visit_(is);}
313  virtual void Visit_(const WordSpatialImageState& is) {T_Visit_(is);}
314 
315 private:
316  template <typename T, class D>
317  void T_Visit_(const ImageStateImpl<T,D>& isi) {
318  this->VisitState(isi);
319  }
320 };
321 
322 
325 public:
328  virtual void Visit_(RealSpatialImageState& is) = 0;
329  virtual void Visit_(ComplexSpatialImageState& is) = 0;
330  virtual void Visit_(RealFrequencyImageState& is) = 0;
331  virtual void Visit_(ComplexFrequencyImageState& is) = 0;
332  virtual void Visit_(ComplexHalfFrequencyImageState& is) = 0;
333  virtual void Visit_(WordSpatialImageState& is) = 0;
334 };
335 
336 
338 
356 template <class FNC>
357 class DLLEXPORT ImageStateModIPVisitor: public FNC, public ImageStateModIPVisitorBase {
358 public:
360 
361  virtual void Visit_(RealSpatialImageState& is) {T_Visit_(is);}
362  virtual void Visit_(ComplexSpatialImageState& is) {T_Visit_(is);}
363  virtual void Visit_(RealFrequencyImageState& is) {T_Visit_(is);}
364  virtual void Visit_(ComplexFrequencyImageState& is) {T_Visit_(is);}
365  virtual void Visit_(ComplexHalfFrequencyImageState& is) {T_Visit_(is);}
366  virtual void Visit_(WordSpatialImageState& is) {T_Visit_(is);}
367 
368 private:
369  template <typename T, class D>
370  void T_Visit_(ImageStateImpl<T,D>& isi) {
371  this->VisitState(isi);
372  }
373 };
374 
375 
378 public:
381  virtual void Visit_(RealSpatialImageState& is) const = 0;
382  virtual void Visit_(ComplexSpatialImageState& is) const = 0;
383  virtual void Visit_(RealFrequencyImageState& is) const = 0;
384  virtual void Visit_(ComplexFrequencyImageState& is) const = 0;
385  virtual void Visit_(ComplexHalfFrequencyImageState& is) const = 0;
386  virtual void Visit_(WordSpatialImageState& is) const = 0;
387 };
388 
389 
391 
411 template <class FNC>
413 public:
415 
416  virtual void Visit_(RealSpatialImageState& is) const {T_Visit_(is);}
417  virtual void Visit_(ComplexSpatialImageState& is) const {T_Visit_(is);}
418  virtual void Visit_(RealFrequencyImageState& is) const {T_Visit_(is);}
419  virtual void Visit_(ComplexFrequencyImageState& is) const {T_Visit_(is);}
420  virtual void Visit_(ComplexHalfFrequencyImageState& is) const {T_Visit_(is);}
421  virtual void Visit_(WordSpatialImageState& is) const {T_Visit_(is);}
422 
423 private:
424  template <typename T, class D>
425  void T_Visit_(ImageStateImpl<T,D>& isi) const {
426  this->VisitState(isi);
427  }
428 };
429 
430 
433 public:
436  virtual ImageStateBasePtr Visit_(const RealSpatialImageState& is) = 0;
437  virtual ImageStateBasePtr Visit_(const ComplexSpatialImageState& is) = 0;
438  virtual ImageStateBasePtr Visit_(const RealFrequencyImageState& is) = 0;
439  virtual ImageStateBasePtr Visit_(const ComplexFrequencyImageState& is) = 0;
440  virtual ImageStateBasePtr Visit_(const ComplexHalfFrequencyImageState& is) = 0;
441  virtual ImageStateBasePtr Visit_(const WordSpatialImageState& is) = 0;
442 };
443 
445 
463 template <class FNC>
464 class DLLEXPORT ImageStateModOPVisitor: public FNC, public ImageStateModOPVisitorBase {
465 public:
466 
468 
469  virtual ImageStateBasePtr Visit_(const RealSpatialImageState& is) {return T_Visit_(is);}
470  virtual ImageStateBasePtr Visit_(const ComplexSpatialImageState& is) {return T_Visit_(is);}
471  virtual ImageStateBasePtr Visit_(const RealFrequencyImageState& is) {return T_Visit_(is);}
472  virtual ImageStateBasePtr Visit_(const ComplexFrequencyImageState& is) {return T_Visit_(is);}
473  virtual ImageStateBasePtr Visit_(const ComplexHalfFrequencyImageState& is) {return T_Visit_(is);}
474  virtual ImageStateBasePtr Visit_(const WordSpatialImageState& is) {return T_Visit_(is);}
475 
476 private:
477  template <typename T, class D>
478  ImageStateBasePtr T_Visit_(const ImageStateImpl<T,D>& isi) {
479  return this->VisitState(isi);
480  }
481 };
482 
483 
486 public:
489  virtual ImageStateBasePtr Visit_(const RealSpatialImageState& is) const = 0;
490  virtual ImageStateBasePtr Visit_(const ComplexSpatialImageState& is) const = 0;
491  virtual ImageStateBasePtr Visit_(const RealFrequencyImageState& is) const = 0;
492  virtual ImageStateBasePtr Visit_(const ComplexFrequencyImageState& is) const = 0;
493  virtual ImageStateBasePtr Visit_(const ComplexHalfFrequencyImageState& is) const = 0;
494  virtual ImageStateBasePtr Visit_(const WordSpatialImageState& is) const = 0;
495 };
496 
498 
518 template <class FNC>
520 public:
521 
523 
524  virtual ImageStateBasePtr Visit_(const RealSpatialImageState& is) const {return T_Visit_(is);}
525  virtual ImageStateBasePtr Visit_(const ComplexSpatialImageState& is) const {return T_Visit_(is);}
526  virtual ImageStateBasePtr Visit_(const RealFrequencyImageState& is) const {return T_Visit_(is);}
527  virtual ImageStateBasePtr Visit_(const ComplexFrequencyImageState& is) const {return T_Visit_(is);}
528  virtual ImageStateBasePtr Visit_(const ComplexHalfFrequencyImageState& is) const {return T_Visit_(is);}
529  virtual ImageStateBasePtr Visit_(const WordSpatialImageState& is) const {return T_Visit_(is);}
530 
531 private:
532  template <typename T, class D>
533  ImageStateBasePtr T_Visit_(const ImageStateImpl<T,D>& isi) const {
534  return this->VisitState(isi);
535  }
536 };
537 
540 public:
543  virtual ImageStateBasePtr Visit_(RealSpatialImageState& is) = 0;
544  virtual ImageStateBasePtr Visit_(ComplexSpatialImageState& is) = 0;
545  virtual ImageStateBasePtr Visit_(RealFrequencyImageState& is) = 0;
546  virtual ImageStateBasePtr Visit_(ComplexFrequencyImageState& is) = 0;
547  virtual ImageStateBasePtr Visit_(ComplexHalfFrequencyImageState& is) = 0;
548  virtual ImageStateBasePtr Visit_(WordSpatialImageState& is) = 0;
549 };
550 
552 
571 template <class FNC>
573 public:
574 
576 
577  virtual ImageStateBasePtr Visit_(RealSpatialImageState& is) {return T_Visit_(is);}
578  virtual ImageStateBasePtr Visit_(ComplexSpatialImageState& is) {return T_Visit_(is);}
579  virtual ImageStateBasePtr Visit_(RealFrequencyImageState& is) {return T_Visit_(is);}
580  virtual ImageStateBasePtr Visit_(ComplexFrequencyImageState& is) {return T_Visit_(is);}
581  virtual ImageStateBasePtr Visit_(ComplexHalfFrequencyImageState& is) {return T_Visit_(is);}
582  virtual ImageStateBasePtr Visit_(WordSpatialImageState& is) {return T_Visit_(is);}
583 
584 private:
585  template <typename T, class D>
586  ImageStateBasePtr T_Visit_(ImageStateImpl<T,D>& isi) {
587  return this->VisitState(isi);
588  }
589 };
590 
591 #undef IMAGE_STATE_VISITOR_CTOR_ADAPTERS
592 
593 }}} // ns
594 
595 #endif
virtual ImageStateBasePtr Visit_(ComplexHalfFrequencyImageState &is)
out-of-place modifying image state const visitor base class
virtual void Visit_(WordSpatialImageState &is) const
ImageStateVisitor general exception.
in-place modifying image state const visitor base class
std::string String
Definition: base.hh:54
morphing image state visitor base class
out-of-place modifying image state visitor
virtual void Visit_(const WordSpatialImageState &is)
virtual void Visit_(const ComplexHalfFrequencyImageState &is)
virtual void Visit_(WordSpatialImageState &is)
virtual ImageStateBasePtr Visit_(const RealFrequencyImageState &is) const
virtual ImageStateBasePtr Visit_(const ComplexHalfFrequencyImageState &is)
virtual void Visit_(const RealFrequencyImageState &is)
virtual void Visit_(const ComplexSpatialImageState &is)
virtual void Visit_(ComplexSpatialImageState &is) const
virtual ImageStateBasePtr Visit_(const ComplexHalfFrequencyImageState &is) const
virtual void Visit_(ComplexHalfFrequencyImageState &is) const
virtual ImageStateBasePtr Visit_(const ComplexFrequencyImageState &is)
virtual ImageStateBasePtr Visit_(const RealFrequencyImageState &is)
virtual ImageStateBasePtr Visit_(ComplexFrequencyImageState &is)
virtual void Visit_(const ComplexFrequencyImageState &is)
virtual void Visit_(RealFrequencyImageState &is) const
virtual ImageStateBasePtr Visit_(const WordSpatialImageState &is) const
virtual void Visit_(ComplexSpatialImageState &is)
non-modifying image state visitor base class
in-place modifying image state visitor base class
virtual void Visit_(RealFrequencyImageState &is)
virtual void Visit_(ComplexHalfFrequencyImageState &is)
in-place modifying image state visitor
virtual ImageStateBasePtr Visit_(const ComplexFrequencyImageState &is) const
virtual ImageStateBasePtr Visit_(ComplexSpatialImageState &is)
out-of-place modifying image state visitor base class
virtual ImageStateBasePtr Visit_(const WordSpatialImageState &is)
out-of-place modifying image state visitor
virtual ImageStateBasePtr Visit_(WordSpatialImageState &is)
virtual ImageStateBasePtr Visit_(const ComplexSpatialImageState &is)
virtual ImageStateBasePtr Visit_(RealFrequencyImageState &is)
boost::shared_ptr< ImageStateBase > ImageStateBasePtr
virtual ImageStateBasePtr Visit_(const ComplexSpatialImageState &is) const
in-place modifying image state visitor
virtual void Visit_(ComplexFrequencyImageState &is)
#define DLLEXPORT_OST_IMG_BASE
#define IMAGE_STATE_VISITOR_CTOR_ADAPTERS(CLASS)
virtual void Visit_(ComplexFrequencyImageState &is) const