test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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() { static const char * name = NAME; return name; } \
15  inline X operator=(const T& x) { set(x); return *this; } \
16  inline static void set(const T& x) { value = x; } \
17 private: \
18  static T value; \
19 }; \
20  \
21 NON_PARAMETRIC(X); \
22  \
23 inline std::ostream& operator<<(std::ostream& cout, const funct::X &) \
24 { return cout << funct::X::name(); } \
25  \
26 } \
27  \
28 struct __useless_ignoreme
29 
30 #define IMPLEMENT_VARIABLE_T(T, X) \
31 namespace funct { \
32  T X::value; \
33 } \
34  \
35 struct __useless_ignoreme \
36 
37 #define DEFINE_VARIABLE(X, NAME) \
38 DEFINE_VARIABLE_T(double, X, NAME)
39 
40 #define IMPLEMENT_VARIABLE(X) \
41 IMPLEMENT_VARIABLE_T(double, X)
42 
43 #define DEFINE_INT_VARIABLE(X, NAME) \
44 DEFINE_VARIABLE_T(int, X, NAME)
45 
46 #define IMPLEMENT_INT_VARIABLE(X) \
47 IMPLEMENT_VARIABLE_T(int, X)
48 
53 
54 #endif
#define DEFINE_VARIABLE(X, NAME)
Definition: Variables.h:37