MeVisLab Toolbox Reference
mlTypedProcessing.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2013, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_TYPED_PROCESSING_H
14 #define ML_TYPED_PROCESSING_H
15 
16 #include "mlInitSystemML.h"
17 
18 #include "mlTypedHandlers.h"
19 
20 ML_START_NAMESPACE
21 
22 namespace internal
23 {
24 
27  template <class Processor, template <typename, int, typename> class VariableType>
28  class SingleTypeCaller : public VariableType<SingleTypeCaller<Processor, VariableType>, 0, internal::EmptyType >
29  {
30  public:
31  inline void process(int dataType, Processor& f)
32  {
33  _f = &f;
34  internal::EmptyType args;
35  this->template doSwitchingCode<internal::EmptyTypeTuple4, internal::EmptyType >(dataType, args);
36  }
37 
38  template<typename Types>
39  inline void doSwitchingWithLabel(const internal::EmptyType&, internal::EmptyType*)
40  {
41  _f->template process<typename Types::T0>();
42  }
43  private:
44  Processor* _f;
45  };
46 
49  template <class Processor,
50  template <typename, int, typename> class VariableType1,
51  template <typename, int, typename> class VariableType2>
53  public VariableType1<DualTypeCaller<Processor, VariableType1, VariableType2>, 0, internal::EmptyType >,
54  public VariableType2<DualTypeCaller<Processor, VariableType1, VariableType2>, 1, internal::EmptyType >
55  {
56  public:
57  inline void process(int firstDataType, int secondDataType, Processor& f)
58  {
59  _f = &f;
60  _secondDataType = secondDataType;
61  internal::EmptyType args;
62  static_cast<VariableType1<DualTypeCaller<Processor, VariableType1, VariableType2>, 0, internal::EmptyType > *>(this)->template doSwitchingCode<internal::EmptyTypeTuple4, internal::EmptyType >(firstDataType, args);
63  }
64 
65  template<typename Types>
66  inline void doSwitchingWithLabel(const internal::EmptyType& args, internal::EmptyType*)
67  {
68  static_cast<VariableType2<DualTypeCaller<Processor, VariableType1, VariableType2>, 1, internal::EmptyType > *>(this)->template doSwitchingCode<Types, internal::DispatchVariableType1Label >(_secondDataType, args);
69  }
70 
71  template<typename Types>
72  inline void doSwitchingWithLabel(const internal::EmptyType&, internal::DispatchVariableType1Label*)
73  {
74  _f->template process<typename Types::T0, typename Types::T1>();
75  }
76 
77  private:
78  Processor* _f;
79  int _secondDataType;
80  };
81 
82 }
83 
84 namespace TypedProcessing
85 {
92 
129  template <template <typename, int, typename> class VariableType, class Processor>
130  static inline void call(MLDataType dataType, Processor& processor)
131  {
133  caller.process(dataType, processor);
134  }
135 
142  template <template <typename, int, typename> class VariableType1,
143  template <typename, int, typename> class VariableType2,
144  class Processor>
145  static inline void call(MLDataType firstDataType, MLDataType secondDataType, Processor& processor)
146  {
148  caller.process(firstDataType, secondDataType, processor);
149  }
150 }
151 
152 ML_END_NAMESPACE
153 
154 #endif
155 
Base class for all variable types, mainly for doxygen documentation purpose.
Internal helper class that uses VariableType1 and VariableType2 to convert two datatype integers to t...
void process(int firstDataType, int secondDataType, Processor &f)
void doSwitchingWithLabel(const internal::EmptyType &, internal::DispatchVariableType1Label *)
void doSwitchingWithLabel(const internal::EmptyType &args, internal::EmptyType *)
Internal helper class that uses a VariableType to convert a datatype integer to the correct Processor...
void process(int dataType, Processor &f)
void doSwitchingWithLabel(const internal::EmptyType &, internal::EmptyType *)
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:684
static void call(MLDataType firstDataType, MLDataType secondDataType, Processor &processor)
Call the process<DataType1, DataType2>() method on the given processor, where the DataType1 and DataT...