NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
FunctionDefinitionManager Class Reference

This class implements the function definition managing instance. More...

#include <define.hpp>

Inheritance diagram for FunctionDefinitionManager:
Collaboration diagram for FunctionDefinitionManager:

Public Member Functions

 FunctionDefinitionManager (bool _isLocal)
 Default constructor of the FunctionDefinitionManager class. Prepares the list of protected command strings. More...
 
 FunctionDefinitionManager (const FunctionDefinitionManager &_defined)
 FunctionDefinitionManager copy constructor. Delegates first to the default constructor. More...
 
bool isDefined (const std::string &sFunc)
 This method checks, whether the passed function is already defined. More...
 
bool defineFunc (const std::string &sExpr, bool bRedefine=false, bool bFallback=false)
 This function defines a custom function, by passing it to a new FunctionDefinition class instance. More...
 
bool undefineFunc (const std::string &sFunc)
 This function removes a previously defined function from the internal memory. More...
 
bool call (std::string &sExpr, int nRecursion=0)
 This function searches for known custom definitions in the passed expression and replaces them with their parsed definition strings. More...
 
size_t getDefinedFunctions () const
 Returns the number of defined functions. More...
 
std::string getDefinitionString (size_t _i) const
 Returns the definition string of the ith defined custom function. More...
 
std::string getFunctionSignature (size_t _i) const
 Returns the function signature of the ith defined custom function. More...
 
std::string getImplementation (size_t _i) const
 Returns the implementation of the ith defined custom function. More...
 
std::string getComment (size_t _i) const
 Returns the comment of the ith defined function. More...
 
bool reset ()
 This member function resets the FunctionDefinitionManager object to a state before any function was defined. More...
 
bool save (const Settings &_option)
 This function saves the function definitions to the definition file. More...
 
bool load (const Settings &_option, bool bAutoLoad=false)
 This function loads previously saved function definitions to memory. More...
 
std::string getNamesOfDefinedFunctions () const
 Returns a list of the names of the custom defined functions. More...
 
void setTableList (const std::string &sTableList)
 Sets the internal table list. This list is used to avoid redefinition of an already existing table as a function. More...
 
void setPredefinedFuncs (const std::string &sPredefined)
 This member function updates the internal list of predefined functions. If the list is whitespace-separated, it will be converted into a comma-separated list. More...
 
std::string getPredefinedFuncs () const
 Return a list of the internal defined default functions. More...
 
size_t getFunctionIndex (const std::string &sFuncName)
 Returns the numerical index of the selected custom defined functions. More...
 
- Public Member Functions inherited from FileSystem
 FileSystem ()
 Default constructor. More...
 
FileSystemassign (const FileSystem &_fSys)
 Assignment member function to copy the settings from another FileSystem instance. More...
 
std::string ValidFileName (std::string _sFileName, const std::string sExtension=".dat", bool checkExtension=true, bool doCleanPath=true) const
 This member function evaluates, whether the passed filename is a valid filename. One may supply a preferred filename extension. More...
 
std::string ValidFolderName (std::string _sFileName, bool doCleanPath=true, bool appendTrailingSeparator=true) const
 This member function evaluates, whether the passed foldername is a valid foldername. More...
 
std::string ValidizeAndPrepareName (const std::string &_sFileName, const std::string &sExtension=".dat") const
 This member function validizes the passed file name and creates the needed folders on-the-fly. More...
 
int setPath (std::string _sPath, bool bMkDir, std::string _sExePath)
 This member function may be used to set the preferred file path of the current FileSystem instance. More...
 
void createRevisionsFolder ()
 This member function creates the hidden revisions folders for the version control system. More...
 
std::string getPath () const
 Returns the default path of this FileSystem instance. More...
 
std::vector< std::string > getFileParts (const std::string &sFilePath) const
 This member function separates all path parts into single strings: the drive letter, the path, the name and the extension. This function may also handle folder paths and network paths. More...
 
FileInfo getFileInfo (const std::string &sFilePath) const
 Return the file information about the passed file path. More...
 
void setTokens (std::string _sTokens)
 This member function may be used to update the path placeholders of the current FileSystem instance. More...
 
bool isFile (const std::string &_sPath) const
 This function determines, whether a path name indicates a file or a folder. More...
 
void initializeFromKernel ()
 Member function to remote-initialize the class from the kernel. Cannot be used during kernel start-up. More...
 
void setProgramPath (std::string _sExePath)
 
std::string getProgramPath () const
 
void declareFileType (const std::string &sFileType)
 

Private Member Functions

std::string resolveRecursiveDefinitions (std::string sDefinition)
 This private member function resolves recursive definitions, which are handled by replacing the occuring function calls with their previous definition. More...
 
std::map< std::string, FunctionDefinition >::const_iterator findItemById (size_t id) const
 This private member function returns the iterator to the function pointed by the passed ID. More...
 

Private Attributes

std::map< std::string, FunctionDefinitionmFunctionsMap
 
std::string sFileName
 
std::string sBuilt_In
 
std::string sCommands
 
std::string sTables
 
bool isLocal
 

Additional Inherited Members

- Protected Member Functions inherited from FileSystem
int createFolders (const std::string &_sPath) const
 This member function creates all missing directories in the passed path. More...
 
- Protected Attributes inherited from FileSystem
std::string sPath
 
std::string sExecutablePath
 
std::string sTokens [7][2]
 
std::string sValidExtensions
 

Detailed Description

This class implements the function definition managing instance.

Definition at line 73 of file define.hpp.

Constructor & Destructor Documentation

◆ FunctionDefinitionManager() [1/2]

FunctionDefinitionManager::FunctionDefinitionManager ( bool  _isLocal)

Default constructor of the FunctionDefinitionManager class. Prepares the list of protected command strings.

Definition at line 507 of file define.cpp.

References isLocal, sBuilt_In, sCommands, sFileName, and sTables.

◆ FunctionDefinitionManager() [2/2]

FunctionDefinitionManager::FunctionDefinitionManager ( const FunctionDefinitionManager _defined)

FunctionDefinitionManager copy constructor. Delegates first to the default constructor.

Parameters
_definedconst FunctionDefinitionManager&

Definition at line 525 of file define.cpp.

References isLocal, mFunctionsMap, sFileName, and sTables.

Member Function Documentation

◆ call()

bool FunctionDefinitionManager::call ( std::string &  sExpr,
int  nRecursion = 0 
)

◆ defineFunc()

bool FunctionDefinitionManager::defineFunc ( const std::string &  sExpr,
bool  bRedefine = false,
bool  bFallback = false 
)

◆ findItemById()

map< string, FunctionDefinition >::const_iterator FunctionDefinitionManager::findItemById ( size_t  id) const
private

This private member function returns the iterator to the function pointed by the passed ID.

Parameters
idsize_t
Returns
map<string, FunctionDefinition>::const_iterator

Definition at line 590 of file define.cpp.

References mFunctionsMap.

Referenced by getComment(), getDefinitionString(), getFunctionSignature(), and getImplementation().

◆ getComment()

string FunctionDefinitionManager::getComment ( size_t  _i) const

Returns the comment of the ith defined function.

Parameters
_isize_t
Returns
string

Definition at line 1021 of file define.cpp.

References findItemById(), and mFunctionsMap.

Referenced by NumeReKernel::getFunctionLanguageStrings(), and listDefinitions().

Here is the call graph for this function:

◆ getDefinedFunctions()

unsigned int FunctionDefinitionManager::getDefinedFunctions ( ) const

Returns the number of defined functions.

Returns
unsigned int

Definition at line 950 of file define.cpp.

References mFunctionsMap.

Referenced by NumeReKernel::CloseSession(), cmd_set(), NumeReKernel::getFunctionLanguageStrings(), and listDefinitions().

◆ getDefinitionString()

string FunctionDefinitionManager::getDefinitionString ( size_t  _i) const

Returns the definition string of the ith defined custom function.

Parameters
_isize_t
Returns
string

Definition at line 964 of file define.cpp.

References findItemById(), and mFunctionsMap.

Referenced by calculateChiMap(), fitDataSet(), and solveLGSSymbolic().

Here is the call graph for this function:

◆ getFunctionIndex()

size_t FunctionDefinitionManager::getFunctionIndex ( const std::string &  sFuncName)
inline

Returns the numerical index of the selected custom defined functions.

Parameters
sFuncNameconst std::string&
Returns
size_t
Remarks
This index is only valid as long as the FunctionDefinitionManager object instance is not modified (defining/undefining functions).

Definition at line 179 of file define.hpp.

References mFunctionsMap.

Referenced by calculateChiMap(), fitDataSet(), and solveLGSSymbolic().

◆ getFunctionSignature()

string FunctionDefinitionManager::getFunctionSignature ( size_t  _i) const

Returns the function signature of the ith defined custom function.

Parameters
_isize_t
Returns
string

Definition at line 983 of file define.cpp.

References findItemById(), and mFunctionsMap.

Referenced by NumeReKernel::getFunctionLanguageStrings(), and listDefinitions().

Here is the call graph for this function:

◆ getImplementation()

string FunctionDefinitionManager::getImplementation ( size_t  _i) const

Returns the implementation of the ith defined custom function.

Parameters
_isize_t
Returns
string

Definition at line 1002 of file define.cpp.

References findItemById(), and mFunctionsMap.

Referenced by listDefinitions().

Here is the call graph for this function:

◆ getNamesOfDefinedFunctions()

std::string FunctionDefinitionManager::getNamesOfDefinedFunctions ( ) const
inline

Returns a list of the names of the custom defined functions.

Returns
std::string

Definition at line 127 of file define.hpp.

References mFunctionsMap.

Referenced by cmd_new().

◆ getPredefinedFuncs()

std::string FunctionDefinitionManager::getPredefinedFuncs ( ) const
inline

Return a list of the internal defined default functions.

Returns
std::string

Definition at line 162 of file define.hpp.

References sBuilt_In.

Referenced by Procedure::Procedure(), and NumeReKernel::StartUp().

◆ isDefined()

bool FunctionDefinitionManager::isDefined ( const std::string &  sFunc)

This method checks, whether the passed function is already defined.

Parameters
sFuncconst string&
Returns
bool

Definition at line 625 of file define.cpp.

References mFunctionsMap, sBuilt_In, sCommands, and StripSpaces().

Referenced by calculateChiMap(), calculateSplines(), cmd_ifndefined(), defineFunc(), fitDataSet(), solveLGSSymbolic(), and taylor().

Here is the call graph for this function:

◆ load()

bool FunctionDefinitionManager::load ( const Settings _option,
bool  bAutoLoad = false 
)

This function loads previously saved function definitions to memory.

Parameters
_optionconst Settings&
bAutoLoadbool
Returns
bool

Definition at line 1104 of file define.cpp.

References _lang, Language::get(), FunctionDefinition::importFunction(), LineBreak(), mFunctionsMap, NumeReKernel::print(), NumeReKernel::printPreFmt(), sFileName, FunctionDefinition::sName, Settings::systemPrints(), toString(), toSystemCodePage(), and FileSystem::ValidFileName().

Referenced by cmd_define(), cmd_load(), cmd_set(), and NumeReKernel::StartUp().

Here is the call graph for this function:

◆ reset()

bool FunctionDefinitionManager::reset ( )

This member function resets the FunctionDefinitionManager object to a state before any function was defined.

Returns
bool

Definition at line 1040 of file define.cpp.

References mFunctionsMap.

Referenced by Script::close(), Script::openScript(), and Procedure::resetProcedure().

◆ resolveRecursiveDefinitions()

string FunctionDefinitionManager::resolveRecursiveDefinitions ( std::string  sDefinition)
private

This private member function resolves recursive definitions, which are handled by replacing the occuring function calls with their previous definition.

Parameters
sDefinitionstring
Returns
string

Definition at line 545 of file define.cpp.

References call(), and StripSpaces().

Referenced by defineFunc().

Here is the call graph for this function:

◆ save()

bool FunctionDefinitionManager::save ( const Settings _option)

This function saves the function definitions to the definition file.

Parameters
_optionconst Settings&
Returns
bool

Definition at line 1056 of file define.cpp.

References _lang, Language::get(), mFunctionsMap, NumeReKernel::printPreFmt(), sFileName, Settings::systemPrints(), toSystemCodePage(), date::detail::trunc(), and FileSystem::ValidFileName().

Referenced by NumeReKernel::CloseSession(), cmd_define(), and cmd_save().

Here is the call graph for this function:

◆ setPredefinedFuncs()

void FunctionDefinitionManager::setPredefinedFuncs ( const std::string &  sPredefined)

This member function updates the internal list of predefined functions. If the list is whitespace-separated, it will be converted into a comma-separated list.

Parameters
sPredefinedconst string&
Returns
void

Definition at line 1158 of file define.cpp.

References sBuilt_In.

Referenced by Procedure::Procedure(), Procedure::setPredefinedFuncs(), Script::setPredefinedFuncs(), and NumeReKernel::StartUp().

◆ setTableList()

void FunctionDefinitionManager::setTableList ( const std::string &  sTableList)
inline

Sets the internal table list. This list is used to avoid redefinition of an already existing table as a function.

Parameters
sTableListconst std::string&
Returns
void

Definition at line 148 of file define.hpp.

References sTables.

Referenced by cmd_define().

◆ undefineFunc()

bool FunctionDefinitionManager::undefineFunc ( const std::string &  sFunc)

This function removes a previously defined function from the internal memory.

Parameters
sFuncconst string&
Returns
bool

Definition at line 772 of file define.cpp.

References NumeReKernel::getInstance(), isLocal, mFunctionsMap, and NumeReKernel::refreshFunctionTree().

Referenced by undefineFunctions().

Here is the call graph for this function:

Member Data Documentation

◆ isLocal

bool FunctionDefinitionManager::isLocal
private

Definition at line 82 of file define.hpp.

Referenced by defineFunc(), FunctionDefinitionManager(), and undefineFunc().

◆ mFunctionsMap

◆ sBuilt_In

std::string FunctionDefinitionManager::sBuilt_In
private

◆ sCommands

std::string FunctionDefinitionManager::sCommands
private

Definition at line 80 of file define.hpp.

Referenced by defineFunc(), FunctionDefinitionManager(), and isDefined().

◆ sFileName

std::string FunctionDefinitionManager::sFileName
private

Definition at line 77 of file define.hpp.

Referenced by FunctionDefinitionManager(), load(), and save().

◆ sTables

std::string FunctionDefinitionManager::sTables
private

Definition at line 81 of file define.hpp.

Referenced by defineFunc(), FunctionDefinitionManager(), and setTableList().


The documentation for this class was generated from the following files: