00001 /* 00002 * Gnome Chemistry Utils 00003 * value.h 00004 * 00005 * Copyright (C) 2002-2006 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 using namespace std; 00031 00032 namespace gcu 00033 { 00034 00035 class Value 00036 { 00037 public: 00038 Value (); 00039 virtual ~Value (); 00040 00041 virtual char const *GetAsString (); 00042 virtual double GetAsDouble (); 00043 }; 00044 00045 class SimpleValue: public Value 00046 { 00047 friend class Element; 00048 00049 public: 00050 SimpleValue (); 00051 virtual ~SimpleValue (); 00052 00053 char const *GetAsString (); 00054 double GetAsDouble (); 00055 GcuValue const GetValue () {return val;} 00056 00057 private: 00058 GcuValue val; 00059 string str; 00060 }; 00061 00062 class DimensionalValue: public Value 00063 { 00064 friend class Element; 00065 00066 public: 00067 DimensionalValue (); 00068 virtual ~DimensionalValue (); 00069 00070 char const *GetAsString (); 00071 double GetAsDouble (); 00072 GcuDimensionalValue const GetValue () {return val;} 00073 00074 private: 00075 GcuDimensionalValue val; 00076 string str; 00077 }; 00078 00079 class StringValue: public Value 00080 { 00081 friend class Element; 00082 00083 public: 00084 StringValue (); 00085 virtual ~StringValue (); 00086 00087 char const *GetAsString (); 00088 00089 private: 00090 string val; 00091 }; 00092 00093 class LocalizedStringValue: public Value 00094 { 00095 friend class Element; 00096 00097 public: 00098 LocalizedStringValue (); 00099 virtual ~LocalizedStringValue (); 00100 00101 char const *GetAsString (); 00102 char const *GetLocalizedString (char const *lang); 00103 00104 private: 00105 map <string, string> vals; 00106 }; 00107 00108 } // namespace gcu 00109 00110 #endif // GCU_VALUE_H