ConfigurationVisitor.hxx
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 #ifndef __CONFIGURATIONVISITOR__
00023 #define __CONFIGURATIONVISITOR__
00024
00025 namespace CLAM{
00026 class ConfigurationVisitor {
00027 public:
00028 virtual ~ConfigurationVisitor() {}
00029 virtual void VisitConfig()=0;
00030 };
00031
00040 template <typename Configuration, typename Builder>
00041 class ConfigurationGetter : public ConfigurationVisitor {
00042 public:
00043 ConfigurationGetter(Configuration * config, Builder* builder) {
00044 mBuilder = builder;
00045 mConfig = config;
00046 }
00047
00048 virtual ~ConfigurationGetter() {}
00049
00050 template <typename T>
00051 void Accept(const char *name, T &value) {
00052 mBuilder->AddWidget(name, &value, value);
00053 }
00054
00055 virtual void VisitConfig() {
00056 mConfig->VisitAll(*this);
00057 }
00058
00059 private:
00060 Builder * mBuilder;
00061 Configuration * mConfig;
00062
00063 };
00073 template <typename Configuration, typename Builder>
00074 class ConfigurationSetter : public ConfigurationVisitor {
00075 public:
00076 ConfigurationSetter(Configuration * config, Builder* builder) {
00077 mBuilder = builder;
00078 mConfig = config;
00079 }
00080
00081 virtual ~ConfigurationSetter() {}
00082
00083 template <typename T>
00084 void Accept(const char *name, T &value) {
00085 mBuilder->RetrieveValue(name, &value, value);
00086 }
00087
00088 virtual void VisitConfig() {
00089 mConfig->VisitAll(*this);
00090 }
00091
00092 private:
00093 Builder * mBuilder;
00094 Configuration * mConfig;
00095
00096 };
00097
00138 }
00139 #endif//__CONFIGURATIONVISITOR__
00140