pelib
2.0.0
|
00001 /* 00002 Copyright 2015 Nicolas Melot 00003 00004 This file is part of Pelib. 00005 00006 Pelib is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 Pelib is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with Pelib. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 00021 #include <typeinfo> 00022 #include <string> 00023 00024 #include <pelib/Data.hpp> 00025 00026 #ifndef PELIB_ALGEBRADATA 00027 #define PELIB_ALGEBRADATA 00028 00029 #define debug(var) std::cout << "[" << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "] " << #var << " = \"" << var << "\"" << std::endl; 00030 00031 namespace pelib 00032 { 00034 class AlgebraData : public Data 00035 { 00036 public: 00041 enum precision { leave, higher }; 00042 00044 AlgebraData(const std::string, precision = leave); 00045 00047 AlgebraData(const AlgebraData&, precision = leave); 00048 00050 virtual const std::string& 00051 getName() const; 00052 00054 virtual void 00055 setName(const std::string); 00056 00058 virtual AlgebraData* clone() const = 0; 00059 00062 virtual void merge(const AlgebraData*) = 0; 00063 00064 precision getPrecision() const; 00065 00066 template<class Value> static 00067 Value fixPrecision(const Value &data, std::streamsize precision); 00068 00069 protected: 00071 std::string name; 00072 precision prec; 00073 }; 00074 00075 template<class Value> 00076 Value 00077 AlgebraData::fixPrecision(const Value &data, std::streamsize precision) 00078 { 00079 if(std::string(typeid(Value).name()).compare(std::string(typeid(float).name())) == 0) 00080 { 00081 debug("Hello world!"); 00082 } 00083 return data; 00084 } 00085 } 00086 00087 #undef debug 00088 #endif