2014-07-20 00:01:00 +08:00
/* Copyright 2013 Juan Rada-Vilela
Licensed under the Apache License , Version 2.0 ( the " License " ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an " AS IS " BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
*/
2014-09-03 18:09:32 +08:00
/*
2014-07-20 00:01:00 +08:00
* File : fuzzylite . h
* Author : jcrada
*
* Created on 1 February 2013 , 10 : 47 AM
*/
# ifndef FL_FUZZYLITE_H
# define FL_FUZZYLITE_H
# include <iostream>
# include <sstream>
# include <limits>
2015-01-12 22:08:57 +08:00
# include "LoggerCpp/LoggerCpp.h"
2014-07-20 00:01:00 +08:00
# ifndef FL_VERSION
# define FL_VERSION "?"
# endif
# ifndef FL_DATE
# define FL_DATE "?"
# endif
# ifndef FL_BUILD_PATH
# define FL_BUILD_PATH ""
# endif
namespace fl {
# ifdef FL_USE_FLOAT
2015-01-12 22:08:57 +08:00
typedef float scalar ;
2014-07-20 00:01:00 +08:00
# else
2015-01-12 22:08:57 +08:00
typedef double scalar ;
2014-07-20 00:01:00 +08:00
# endif
2015-01-12 22:08:57 +08:00
static const scalar nan = std : : numeric_limits < scalar > : : quiet_NaN ( ) ;
static const scalar inf = std : : numeric_limits < scalar > : : infinity ( ) ;
2014-07-20 00:01:00 +08:00
}
# define FL__FILE__ std::string(__FILE__).substr(std::string(FL_BUILD_PATH).size())
# define FL_LOG_PREFIX FL__FILE__ << " [" << __LINE__ << "]:"
# define FL_AT FL__FILE__, __LINE__, __FUNCTION__
2015-01-12 22:08:57 +08:00
# define FL_LOG(message) if (fl::fuzzylite::logging()){fl::fuzzylite::logger->info() << FL_LOG_PREFIX << message /*<< std::endl */ ;}
# define FL_LOGP(message) if (fl::fuzzylite::logging()){fl::fuzzylite::logger->info() << message /* << std::endl */ ;}
2014-07-20 00:01:00 +08:00
# ifndef FL_DEBUG
# define FL_DEBUG false
# endif
# define FL_BEGIN_DEBUG_BLOCK if (fl::fuzzylite::debug()){
# define FL_END_DEBUG_BLOCK }
# define FL_DBG(message) FL_BEGIN_DEBUG_BLOCK \
2015-01-12 22:08:57 +08:00
fl : : fuzzylite : : logger - > debug ( ) < < FL__FILE__ < < " :: " < < __FUNCTION__ < < " [ " < < __LINE__ < < " ]: " \
< < message /*<< std::endl*/ ; \
FL_END_DEBUG_BLOCK
2014-07-20 00:01:00 +08:00
//class FL_EXPORT is require to build DLLs in Windows.
# ifdef FL_WINDOWS
# define FL_EXPORT __declspec(dllexport)
# else
2014-09-03 18:09:32 +08:00
# define FL_EXPORT
2014-07-20 00:01:00 +08:00
# endif
# ifdef FL_WINDOWS
# include <ciso646> //alternative operator spellings:
//#define and &&
//#define or ||
//#define not !
//#define bitand &
//#define bitor |
//TODO: add these functions in Windows
//#define acosh(x)
//#define asinh(x)
//#define atanh(x)
//#define log1p
//to ignore warnings dealing with exceptions in Windows:
//http://msdn.microsoft.com/en-us/library/sa28fef8%28v=vs.80%29.aspx
# pragma warning(disable:4290) //C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
# pragma warning(disable:4251) //Windows NMake complains I should have pointers in all headers instead of stack allocated objects. For example, std::string* instead of std::string.
# pragma warning(disable:4127) //Ignore conditional expression constant of FL_DBG and alike
# pragma warning(disable:4706) //Ignore assignments within conditional expressions in Tsukamoto.
2014-09-03 18:09:32 +08:00
# else
2014-07-20 00:01:00 +08:00
# endif
namespace fl {
2015-01-12 22:08:57 +08:00
class FL_EXPORT fuzzylite {
protected :
static int _decimals ;
static scalar _macheps ;
static bool _debug ;
static bool _logging ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
public :
static Log : : Logger * logger ;
static std : : string name ( ) ;
static std : : string fullname ( ) ;
static std : : string version ( ) ;
static std : : string longVersion ( ) ;
static std : : string author ( ) ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
static std : : string date ( ) ;
static std : : string platform ( ) ;
static std : : string configuration ( ) ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
static std : : string floatingPoint ( ) ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
static bool debug ( ) ;
static void setDebug ( bool debug ) ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
static int decimals ( ) ;
static void setDecimals ( int decimals ) ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
static scalar macheps ( ) ;
static void setMachEps ( scalar macheps ) ;
2014-09-03 18:09:32 +08:00
2015-01-12 22:08:57 +08:00
static bool logging ( ) ;
static void setLogging ( bool logging ) ;
} ;
2014-07-20 00:01:00 +08:00
2015-01-12 22:08:57 +08:00
bool icasecmp ( const std : : string & l , const std : : string & r ) ;
std : : string toLower ( std : : string word ) ;
}
2014-07-20 00:01:00 +08:00
# endif /* FL_FUZZYLITE_H */