Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00034 #ifndef OBJECT_TYPE
00035 #error "Please, #define OBJECT_TYPE before including DeclareBuilder.h."
00036 #endif
00037
00038 #ifndef TAG
00039 #error "Please, #define TAG before including DeclareBuilder.h."
00040 #endif
00041
00042 #if defined(BUILDS_FROM_BOOL) || defined(BUILDS_FROM_DOUBLE) || \
00043 defined(BUILDS_FROM_PTIME) || defined(BUILDS_FROM_STRING)
00044 #define BUILDS_FROM_VARIANT
00045 #endif
00046
00047 namespace tag {
00048 class TAG;
00049 }
00050
00051 template<>
00052 class Builder<OBJECT_TYPE> :
00053
00054 #ifdef COMMAND
00055 public Command
00056 #else
00057 public Processor
00058 #endif
00059
00060 #ifdef BUILDS_FROM_BOOL
00061 , public BuilderFrom<OBJECT_TYPE, bool>
00062 #endif
00063
00064 #ifdef BUILDS_FROM_DOUBLE
00065 , public BuilderFrom<OBJECT_TYPE, double>
00066 #endif
00067
00068 #ifdef BUILDS_FROM_PTIME
00069 , public BuilderFrom<OBJECT_TYPE, ptime>
00070 #endif
00071
00072 #ifdef BUILDS_FROM_STRING
00073 , public BuilderFrom<OBJECT_TYPE, string>
00074 #endif
00075
00076 #ifdef BUILDS_FROM_VARIANT
00077 , public BuilderFromVariant
00078 #endif
00079
00080 {
00081
00082 public:
00083
00084 const char*
00085 getName() const;
00086
00087 #ifdef KV_COMMAND
00088 const char*
00089 getCommandName() const;
00090 #endif
00091
00092 #ifdef BUILDS_FROM_BOOL
00093 shared_ptr<OBJECT_TYPE>
00094 getObject(const bool& data) const;
00095 #endif
00096
00097 #ifdef BUILDS_FROM_DOUBLE
00098 shared_ptr<OBJECT_TYPE>
00099 getObject(const double& data) const;
00100 #endif
00101
00102 #ifdef BUILDS_FROM_PTIME
00103 shared_ptr<OBJECT_TYPE>
00104 getObject(const ptime& data) const;
00105 #endif
00106
00107 #ifdef BUILDS_FROM_STRING
00108 shared_ptr<OBJECT_TYPE>
00109 getObject(const string& data) const;
00110 #endif
00111
00112 value::Result
00113 getResult(const DataSet& data) const;
00114
00115 shared_ptr<OBJECT_TYPE>
00116 getObject(const DataSet& data) const;
00117
00118 private:
00119
00120 friend class ProcessorInstantiator<tag::TAG> ;
00121
00122 Builder();
00123
00124 };
00125
00126
00127
00128
00129
00130 template<>
00131 Processor&
00132 ProcessorInstantiator<tag::TAG>::getInstance() {
00133 static Builder<OBJECT_TYPE> singleton;
00134 return singleton;
00135 }
00136
00137 template<>
00138 Processor&
00139 ProcessorInstantiator<OBJECT_TYPE>::getInstance() {
00140 return ProcessorInstantiator<tag::TAG>::getInstance();
00141 }
00142
00143
00144
00145
00146
00147 value::Result Builder<OBJECT_TYPE>::getResult(const DataSet& data) const {
00148 return getObject(data);
00149 }
00150
00151
00152
00153
00154
00155 Builder<OBJECT_TYPE>::Builder() {
00156 util::Global<ProcessorMngr>::get()->add(this);
00157 }
00158
00159
00160
00161
00162
00163 #undef OBJECT_TYPE
00164 #undef TAG
00165
00166 #ifdef COMMAND
00167 #undef COMMAND
00168 #endif
00169
00170 #ifdef BUILDS_FROM_BOOL
00171 #undef BUILDS_FROM_BOOL
00172 #endif
00173
00174 #ifdef BUILDS_FROM_DOUBLE
00175 #undef BUILDS_FROM_DOUBLE
00176 #endif
00177
00178 #ifdef BUILDS_FROM_PTIME
00179 #undef BUILDS_FROM_PTIME
00180 #endif
00181
00182 #ifdef BUILDS_FROM_STRING
00183 #undef BUILDS_FROM_STRING
00184 #endif
00185
00186 #ifdef BUILDS_FROM_VARIANT
00187 #undef BUILDS_FROM_VARIANT
00188 #endif