23#ifndef libmath_library_h
24#define libmath_library_h
26#include <math++/error.h>
34template<
class>
class TNode;
35template<
class>
class TLibrary;
49 TFunction(
const std::string& AName,
const std::string& AExprStr = std::string());
53 T call(
const T& AParam,
const TLibrary<T>& ALibrary,
unsigned ALimit = 64)
const;
55 void name(
const std::string&);
56 std::string name()
const;
58 void expression(
const TNode<T> *ACopyOf);
59 void expression(
const std::string& AExprStr);
75 TConstant(
const std::string& AName,
const T& AValue = T());
77 void name(
const std::string&);
78 std::string name()
const;
102 typedef std::list<TFunction<T> > TFunctionList;
103 typedef std::list<TConstant<T> > TConstantList;
105 TFunctionList FFunctions;
106 TConstantList FConstants;
108 void removeIf(
const std::string& AName,
bool AReplaceIfExists);
135 T
call(
const std::string& AName,
const T& AParam)
const;
137 T
value(
const std::string& AName)
const;
147template<
typename T> std::ostream& operator<<(std::ostream&,
const math::TFunction<T>&);
149#include <math++/library.tcc>
void insert(const TConstant< T > &, bool AReplaceIfExists=false)
inserts given constant into library, it throws if it's duplicated
void insert(const TFunction< T > &, bool AReplaceIfExists=false)
inserts given function into library, it throws if it's duplicated
T value(const std::string &AName) const
value() look for a constant AName and returns its value. It throws on lookup error.
unsigned constants() const
returns the number of constants stored in this library.
bool hasFunction(const std::string &AName) const
returns true, if function (AName) exists
void remove(const std::string &AName)
removes function or constant called AName
bool hasConstant(const std::string &AName) const
returns true, if constant (AName) exists
unsigned functions() const
returns the number of functions stored in this library.
T call(const std::string &AName, const T &AParam) const
call() looks for a function AName calls it using AParam and returns its result. It throws on lookup e...
TFunction< T > function(const std::string &AName) const
returns reference to requested function, throws if not found
TConstant< T > constant(const std::string &AName) const
returns reference to requested constant, throws if not fuond