ConfigurationVisitor.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 
Generated by  doxygen 1.6.3