CMS 3D CMS Logo

Variables.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_Utilities_Variables_h
2 #define PhysicsTools_Utilities_Variables_h
4 #include <iostream>
5 
6 #define DEFINE_VARIABLE_T(T, X, NAME) \
7  namespace funct { \
8  struct X { \
9  typedef T type; \
10  X() {} \
11  X(const T& x) { set(x); } \
12  inline operator T() const { return value; } \
13  inline T operator()() const { return value; } \
14  inline static const char* name() { \
15  static const char* name = NAME; \
16  return name; \
17  } \
18  inline X operator=(const T& x) { \
19  set(x); \
20  return *this; \
21  } \
22  inline static void set(const T& x) { value = x; } \
23  \
24  private: \
25  static T value; \
26  }; \
27  \
28  NON_PARAMETRIC(X); \
29  \
30  inline std::ostream& operator<<(std::ostream& cout, const funct::X&) { return cout << funct::X::name(); } \
31  } \
32  \
33  struct __useless_ignoreme
34 
35 #define IMPLEMENT_VARIABLE_T(T, X) \
36  namespace funct { \
37  T X::value; \
38  } \
39  \
40  struct __useless_ignoreme
41 
42 #define DEFINE_VARIABLE(X, NAME) DEFINE_VARIABLE_T(double, X, NAME)
43 
44 #define IMPLEMENT_VARIABLE(X) IMPLEMENT_VARIABLE_T(double, X)
45 
46 #define DEFINE_INT_VARIABLE(X, NAME) DEFINE_VARIABLE_T(int, X, NAME)
47 
48 #define IMPLEMENT_INT_VARIABLE(X) IMPLEMENT_VARIABLE_T(int, X)
49 
54 
55 #endif
DEFINE_VARIABLE
#define DEFINE_VARIABLE(X, NAME)
Definition: Variables.h:42
funct::DefaultVariable
Definition: Variables.h:50
funct::X
Definition: Variables.h:51
ParametricTrait.h
funct::Y
Definition: Variables.h:52
funct::Z
Definition: Variables.h:53