00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2011 Heiko Strathmann 00008 * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society 00009 */ 00010 00011 #ifndef __PARAMETERMAP_ 00012 #define __PARAMETERMAP_ 00013 00014 #include <shogun/base/DynArray.h> 00015 00016 namespace shogun 00017 { 00018 00019 struct TParameter; 00020 00028 class SGParamInfo 00029 { 00030 public: 00032 SGParamInfo(); 00033 00042 SGParamInfo(const char* name, EContainerType ctype, EStructType stype, 00043 EPrimitiveType ptype, int32_t param_version); 00044 00050 SGParamInfo(const TParameter* param, int32_t param_version); 00051 00055 SGParamInfo(const SGParamInfo& orig); 00056 00058 virtual ~SGParamInfo(); 00059 00061 void print_param_info(const char* prefix="") const; 00062 00064 char* to_string() const; 00065 00067 SGParamInfo* duplicate() const; 00068 00070 bool operator==(const SGParamInfo& other) const; 00071 00073 bool operator!=(const SGParamInfo& other) const; 00074 00076 bool operator<(const SGParamInfo& other) const; 00077 00079 bool operator>(const SGParamInfo& other) const; 00080 00083 bool is_empty() const; 00084 00085 public: 00087 char* m_name; 00088 00090 EContainerType m_ctype; 00091 00093 EStructType m_stype; 00094 00096 EPrimitiveType m_ptype; 00097 00099 int32_t m_param_version; 00100 }; 00101 00106 class ParameterMapElement 00107 { 00108 public: 00110 ParameterMapElement(); 00111 00117 ParameterMapElement(const SGParamInfo* key, 00118 DynArray<const SGParamInfo*>* values); 00119 00121 virtual ~ParameterMapElement(); 00122 00124 bool operator==(const ParameterMapElement& other) const; 00125 00127 bool operator<(const ParameterMapElement& other) const; 00128 00130 bool operator>(const ParameterMapElement& other) const; 00131 00133 virtual const char* get_name() const 00134 { 00135 return "ParameterMapElement"; 00136 } 00137 00138 public: 00140 const SGParamInfo* m_key; 00141 00143 DynArray<const SGParamInfo*>* m_values; 00144 00145 }; 00146 00161 class ParameterMap 00162 { 00163 public: 00165 ParameterMap(); 00166 00168 virtual ~ParameterMap(); 00169 00180 void put(const SGParamInfo* key, const SGParamInfo* value); 00181 00193 DynArray<const SGParamInfo*>* get(const SGParamInfo) const; 00194 00204 DynArray<const SGParamInfo*>* get(const SGParamInfo* key) const; 00205 00211 void finalize_map(); 00212 00214 void print_map(); 00215 00216 protected: 00218 DynArray<ParameterMapElement*> m_map_elements; 00219 00222 DynArray<ParameterMapElement*> m_multi_map_elements; 00223 00225 bool m_finalized; 00226 }; 00227 00228 } 00229 00230 #endif /* __PARAMETERMAP_ */