|
Differential Evolution C++ library
|
00001 /* 00002 * Copyright (c) 2011 Adrian Michel 00003 * http://www.amichel.com 00004 * 00005 * Permission to use, copy, modify, distribute and sell this 00006 * software and its documentation for any purpose is hereby 00007 * granted without fee, provided that both the above copyright 00008 * notice and this permission notice appear in all copies and in 00009 * the supporting documentation. 00010 * 00011 * This library is distributed in the hope that it will be 00012 * useful. However, Adrian Michel makes no representations about 00013 * the suitability of this software for any purpose. It is 00014 * provided "as is" without any express or implied warranty. 00015 * 00016 * Should you find this library useful, please email 00017 * info@amichel.com with a link or other reference 00018 * to your work. 00019 */ 00020 00021 #ifndef DE_TYPES_HPP_INCLUDED 00022 #define DE_TYPES_HPP_INCLUDED 00023 00024 // MS compatible compilers support #pragma once 00025 00026 #if defined(_MSC_VER) && (_MSC_VER >= 1020) 00027 #pragma once 00028 #endif 00029 00030 #include <vector> 00031 #include <exception> 00032 00033 namespace de 00034 { 00042 class Double 00043 { 00044 private: 00045 double m_value; 00046 00047 public: 00055 Double( double value ) 00056 : m_value( value ) 00057 { 00058 } 00059 00065 Double() 00066 : m_value( 0 ) 00067 { 00068 } 00069 00079 double operator=( double value ) 00080 { 00081 m_value = value; 00082 00083 return m_value; 00084 } 00085 00093 operator double() const 00094 { 00095 return m_value; 00096 } 00097 }; 00098 00102 typedef std::vector< Double > DVector; 00103 00107 typedef boost::shared_ptr< DVector > DVectorPtr; 00108 00109 00116 class exception : public std::exception 00117 { 00118 private: 00119 const std::string m_what; 00120 00121 public: 00122 virtual ~exception() throw() 00123 { 00124 } 00133 exception( const char* what ) 00134 : m_what( what != 0 ? what : "" ) 00135 { 00136 } 00137 00146 virtual const char* what() const throw() 00147 { 00148 return m_what.c_str(); 00149 } 00150 }; 00151 00152 } 00153 #endif //DE_TYPES_HPP_INCLUDED