|
libpsynth 0.2.1
|
00001 00011 /* 00012 * Copyright (C) 2009 Juan Pedro BolĂvar Puente 00013 * 00014 * This file is part of Psychosynth. 00015 * 00016 * Psychosynth is free software: you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License as published by 00018 * the Free Software Foundation, either version 3 of the License, or 00019 * (at your option) any later version. 00020 * 00021 * Psychosynth is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU General Public License 00027 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00028 * 00029 */ 00030 00031 #ifndef PSYNTH_TYPE_INFO_H_ 00032 #define PSYNTH_TYPE_INFO_H_ 00033 00034 #include <typeinfo> 00035 00036 namespace psynth 00037 { 00038 namespace base 00039 { 00040 00045 class type_value 00046 { 00047 public: 00048 type_value () 00049 : _info (&typeid (void)) 00050 {}; 00051 00052 type_value (const std::type_info& t) 00053 : _info (&t) 00054 {} 00055 00056 bool before (const type_value& t) const 00057 { 00058 return _info->before (*t._info); 00059 } 00060 00061 const char* name () const 00062 { 00063 return _info->name (); 00064 } 00065 00066 const std::type_info& get () const 00067 { 00068 return *_info; 00069 } 00070 00071 private: 00072 const std::type_info* _info; 00073 }; 00074 00075 inline bool operator== (const type_value& lhs, const type_value& rhs) 00076 { 00077 return lhs.get () == rhs.get (); 00078 } 00079 00080 inline bool operator< (const type_value& lhs, const type_value& rhs) 00081 { 00082 return lhs.before (rhs); 00083 } 00084 00085 inline bool operator!= (const type_value& lhs, const type_value& rhs) 00086 { 00087 return ! (lhs == rhs); 00088 } 00089 00090 inline bool operator> (const type_value& lhs, const type_value& rhs) 00091 { 00092 return rhs < lhs; 00093 } 00094 00095 inline bool operator<= (const type_value& lhs, const type_value& rhs) 00096 { 00097 return !(lhs > rhs); 00098 } 00099 00100 inline bool operator>= (const type_value& lhs, const type_value& rhs) 00101 { 00102 return !(lhs < rhs); 00103 } 00104 00105 } /* namespace base */ 00106 } /* namespace psynth */ 00107 00108 #endif /* PSYNTH_TYPE_VALUE_H_ */
1.7.4