00001 /* 00002 * Gnome Chemistry Utils 00003 * value.h 00004 * 00005 * Copyright (C) 2002-2007 Jean Bréfort <jean.brefort@normalesup.org> 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of the 00010 * License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00020 * USA 00021 */ 00022 00023 #ifndef GCU_VALUE_H 00024 #define GCU_VALUE_H 00025 00026 #include "chemistry.h" 00027 #include <string> 00028 #include <map> 00029 00030 namespace gcu 00031 { 00032 00036 class Value 00037 { 00038 public: 00042 Value (); 00046 virtual ~Value (); 00047 00051 virtual char const *GetAsString () const; 00052 00056 virtual double GetAsDouble () const; 00057 }; 00058 00062 class SimpleValue: public Value 00063 { 00064 friend class Element; 00065 00066 public: 00070 SimpleValue (); 00074 virtual ~SimpleValue (); 00075 00079 char const *GetAsString () const; 00083 double GetAsDouble () const; 00087 GcuValue const GetValue () {return val;} 00088 00089 private: 00090 GcuValue val; 00091 std::string str; 00092 }; 00097 class DimensionalValue: public Value 00098 { 00099 friend class Element; 00100 00101 public: 00105 DimensionalValue (); 00109 virtual ~DimensionalValue (); 00110 00114 char const *GetAsString () const; 00118 double GetAsDouble () const; 00122 GcuDimensionalValue const GetValue () {return val;} 00123 00124 private: 00125 GcuDimensionalValue val; 00126 std::string str; 00127 }; 00128 00132 class StringValue: public Value 00133 { 00134 friend class Element; 00135 00136 public: 00140 StringValue (); 00144 virtual ~StringValue (); 00145 00149 char const *GetAsString () const; 00150 00151 private: 00152 std::string val; 00153 }; 00154 00158 class LocalizedStringValue: public Value 00159 { 00160 friend class Element; 00161 00162 public: 00166 LocalizedStringValue (); 00170 virtual ~LocalizedStringValue (); 00171 00176 char const *GetAsString () const; 00182 char const *GetLocalizedString (char const *lang) const; 00183 00184 private: 00185 std::map <std::string, std::string> vals; 00186 }; 00187 00188 } // namespace gcu 00189 00190 #endif // GCU_VALUE_H