00001 #ifndef PhysicsTools_Utilities_Variables_h 00002 #define PhysicsTools_Utilities_Variables_h 00003 #include "PhysicsTools/Utilities/interface/ParametricTrait.h" 00004 #include <iostream> 00005 00006 #define DEFINE_VARIABLE_T(T, X, NAME) \ 00007 namespace funct { \ 00008 struct X { \ 00009 typedef T type; \ 00010 X() { } \ 00011 X(const T& x) { set(x); } \ 00012 inline operator T() const { return value; } \ 00013 inline T operator()() const { return value; } \ 00014 inline static const char* name() { static const char * name = NAME; return name; } \ 00015 inline X operator=(const T& x) { set(x); return *this; } \ 00016 inline static void set(const T& x) { value = x; } \ 00017 private: \ 00018 static T value; \ 00019 }; \ 00020 \ 00021 NON_PARAMETRIC(X); \ 00022 \ 00023 inline std::ostream& operator<<(std::ostream& cout, const funct::X &) \ 00024 { return cout << funct::X::name(); } \ 00025 \ 00026 } \ 00027 \ 00028 struct __useless_ignoreme 00029 00030 #define IMPLEMENT_VARIABLE_T(T, X) \ 00031 namespace funct { \ 00032 T X::value; \ 00033 } \ 00034 \ 00035 struct __useless_ignoreme \ 00036 00037 #define DEFINE_VARIABLE(X, NAME) \ 00038 DEFINE_VARIABLE_T(double, X, NAME) 00039 00040 #define IMPLEMENT_VARIABLE(X) \ 00041 IMPLEMENT_VARIABLE_T(double, X) 00042 00043 #define DEFINE_INT_VARIABLE(X, NAME) \ 00044 DEFINE_VARIABLE_T(int, X, NAME) 00045 00046 #define IMPLEMENT_INT_VARIABLE(X) \ 00047 IMPLEMENT_VARIABLE_T(int, X) 00048 00049 DEFINE_VARIABLE(DefaultVariable, "_"); 00050 DEFINE_VARIABLE(X, "x"); 00051 DEFINE_VARIABLE(Y, "y"); 00052 DEFINE_VARIABLE(Z, "z"); 00053 00054 #endif