parameter_initializer.h

Go to the documentation of this file.
00001 //    sampalib.org ESL library and tools
00002 //    Copyright (C) 2007  Thierry Grellier
00003 //
00004 //    This program is free software; you can redistribute it and/or modify
00005 //    it under the terms of the GNU General Public License version 2 as
00006 //    published by the Free Software Foundation.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //    You should have received a copy of the GNU General Public License along
00014 //    with this program; if not, write to the Free Software Foundation, Inc.,
00015 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 //
00017 //    contact: www.sampalib.org
00018 
00019 #ifndef PARAMETER_INITIALIZER_H
00020 #define PARAMETER_INITIALIZER_H
00021 
00022 #include "sampa/core/parameter.h"
00023 #include <string>
00024 
00025 namespace Sampa {
00026 
00027 class LuaInterpreter;
00028 
00029 class ParameterInitializerBase {
00030 public:
00031   void initialize(const char* name, bool optional);
00032 protected:
00033   virtual int retrieve(LuaInterpreter* interpreter, const std::string& full_name) = 0;
00034   virtual std::string to_string() const = 0;
00035 };
00036 
00037 template <class Parameter>
00038 class ParameterInitializer : public ParameterInitializerBase {
00039 public:
00040   inline ParameterInitializer(Parameter* parm) : m_parm(parm) {  }
00041 protected:
00042   // not implemented : to be implemented in partial specialization
00043   int retrieve(LuaInterpreter* interpreter, const std::string& full_name);
00044   std::string to_string() const;
00045 private:
00046   Parameter* m_parm;
00047 };
00048 
00049 template <class Enumerated>
00050 class EnumeratedParameterInitializer : public ParameterInitializerBase {
00051 public:
00052   inline EnumeratedParameterInitializer(EnumeratedParameter<Enumerated>* parm) : m_parm(parm) {  }
00053 protected:
00054   int retrieve(LuaInterpreter* interpreter, const std::string& full_name);
00055   std::string to_string() const;
00056 private:
00057   EnumeratedParameter<Enumerated>* m_parm;
00058   // to be initialized in partial specialisation, with M_enum_labels[i] = 0, end marker
00059   static const char* M_enum_labels[];
00060   static Enumerated  M_enum_consts[];
00061 };
00062 
00063 } // namespace Sampa
00064 
00065 #endif

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3