value.h

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 #include <string>
00030 #include <stdexcept>
00031 
00032 namespace gcu
00033 {
00034 
00038 class Value
00039 {
00040 public:
00044         Value ();
00048         virtual ~Value ();
00049 
00053         virtual char const *GetAsString () const;
00054 
00058         virtual double GetAsDouble () const;
00059 };
00060 
00064 class SimpleValue: public Value
00065 {
00066 friend class Element;
00067 
00068 public:
00072         SimpleValue ();
00073         SimpleValue (GcuValue value);
00077         virtual ~SimpleValue ();
00078 
00082         char const *GetAsString () const;
00086         double GetAsDouble () const;
00090         GcuValue const GetValue () {return val;}
00091         SimpleValue operator+ (SimpleValue const &value) const;
00092         SimpleValue operator* (int n) const;
00093 
00094 private:
00095         GcuValue val;
00096         std::string str;
00097 };
00102 class DimensionalValue: public Value
00103 {
00104 friend class Element;
00105 
00106 public:
00110         DimensionalValue ();
00114         virtual ~DimensionalValue ();
00115 
00119         char const *GetAsString () const;
00123         double GetAsDouble () const;
00124 
00125         DimensionalValue operator+ (DimensionalValue const &value) const throw (std::invalid_argument);
00126         DimensionalValue operator* (int n) const;
00130         GcuDimensionalValue const GetValue () const {return val;}
00131 
00132 private:
00133         GcuDimensionalValue val;
00134         std::string str;
00135 };
00136 
00140 class StringValue: public Value
00141 {
00142 friend class Element;
00143 
00144 public:
00148         StringValue ();
00152         virtual ~StringValue ();
00153 
00157         char const *GetAsString () const;
00158 
00159 private:
00160         std::string val;
00161 };
00162 
00166 class LocalizedStringValue: public Value
00167 {
00168 friend class Element;
00169 
00170 public:
00174         LocalizedStringValue ();
00178         virtual ~LocalizedStringValue ();
00179 
00184         char const *GetAsString () const;
00190         char const *GetLocalizedString (char const *lang) const;
00191 
00192 private:
00193         std::map <std::string, std::string> vals;
00194 };
00195 
00196 }       // namespace gcu
00197 
00198 #endif  //      GCU_VALUE_H

Generated on Sun Jun 22 13:26:05 2008 for The Gnome Chemistry Utils by  doxygen 1.5.6