NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
This class implements the function definition managing instance. More...
#include <define.hpp>
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... | |
FileSystem & | assign (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, FunctionDefinition > | mFunctionsMap |
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 |
This class implements the function definition managing instance.
Definition at line 73 of file define.hpp.
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::FunctionDefinitionManager | ( | const FunctionDefinitionManager & | _defined | ) |
FunctionDefinitionManager copy constructor. Delegates first to the default constructor.
_defined | const FunctionDefinitionManager& |
Definition at line 525 of file define.cpp.
References isLocal, mFunctionsMap, sFileName, and sTables.
bool FunctionDefinitionManager::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.
sExpr | string& |
nRecursion | int |
Definition at line 801 of file define.cpp.
References call(), checkDelimiter(), NumeReKernel::getInstance(), getMatchingParenthesis(), SyntaxError::invalid_position, isInQuotes(), mFunctionsMap, StripSpaces(), SyntaxError::TOO_MANY_FUNCTION_CALLS, and SyntaxError::UNMATCHED_PARENTHESIS.
Referenced by FlowCtrl::calc(), call(), FlowCtrl::checkParsingModeAndExpandDefinitions(), FlowCtrl::compile(), createMatFromLines(), createMatFromLinesFilled(), Plot::createSubPlotSet(), defineFunc(), differentiate(), FlowCtrl::evalHeader(), FlowCtrl::evalRangeBasedHeader(), evaluateExpression(), evaluateFittingParams(), evaluateParameterValues(), ProcedureVarFactory::evaluateProcedureArguments(), Plot::evaluateSubplot(), Procedure::execute(), findExtrema(), findZeroes(), CommandLineParser::getExprAsMathExpression(), Script::handleLocalDefinitions(), NumeReKernel::MainLoop(), parseArg(), CommandLineParser::parseExprAsNumericalValues(), CommandLineParser::parseExprAsString(), performMatrixOperation(), Procedure::ProcCalc(), readAndParseIntervals(), resolveRecursiveDefinitions(), and Odesolver::solve().
bool FunctionDefinitionManager::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.
sExpr | const string& |
bRedefine | bool |
bFallback | bool |
Definition at line 655 of file define.cpp.
References SyntaxError::CACHE_ALREADY_EXISTS, call(), SyntaxError::CANNOT_FIND_DEFINE_OPRT, SyntaxError::CANNOT_FIND_FUNCTION_ARGS, findParameter(), SyntaxError::FUNCTION_ALREADY_EXISTS, SyntaxError::FUNCTION_IS_PREDEFINED, SyntaxError::FUNCTION_STRING_IS_COMMAND, getArgAtPos(), FunctionDefinition::getDefinition(), NumeReKernel::getInstance(), SyntaxError::invalid_position, isDefined(), isLocal, mFunctionsMap, NumeReKernel::refreshFunctionTree(), resolveRecursiveDefinitions(), sBuilt_In, sCommands, FunctionDefinition::sName, and sTables.
Referenced by calculateChiMap(), calculateSplines(), cmd_define(), cmd_ifndefined(), cmd_redefine(), Procedure::execute(), fitDataSet(), Script::handleLocalDefinitions(), solveLGSSymbolic(), and taylor().
|
private |
This private member function returns the iterator to the function pointed by the passed ID.
id | size_t |
Definition at line 590 of file define.cpp.
References mFunctionsMap.
Referenced by getComment(), getDefinitionString(), getFunctionSignature(), and getImplementation().
string FunctionDefinitionManager::getComment | ( | size_t | _i | ) | const |
Returns the comment of the ith defined function.
_i | size_t |
Definition at line 1021 of file define.cpp.
References findItemById(), and mFunctionsMap.
Referenced by NumeReKernel::getFunctionLanguageStrings(), and listDefinitions().
unsigned int FunctionDefinitionManager::getDefinedFunctions | ( | ) | const |
Returns the number of defined functions.
Definition at line 950 of file define.cpp.
References mFunctionsMap.
Referenced by NumeReKernel::CloseSession(), cmd_set(), NumeReKernel::getFunctionLanguageStrings(), and listDefinitions().
string FunctionDefinitionManager::getDefinitionString | ( | size_t | _i | ) | const |
Returns the definition string of the ith defined custom function.
_i | size_t |
Definition at line 964 of file define.cpp.
References findItemById(), and mFunctionsMap.
Referenced by calculateChiMap(), fitDataSet(), and solveLGSSymbolic().
|
inline |
Returns the numerical index of the selected custom defined functions.
sFuncName | const std::string& |
Definition at line 179 of file define.hpp.
References mFunctionsMap.
Referenced by calculateChiMap(), fitDataSet(), and solveLGSSymbolic().
string FunctionDefinitionManager::getFunctionSignature | ( | size_t | _i | ) | const |
Returns the function signature of the ith defined custom function.
_i | size_t |
Definition at line 983 of file define.cpp.
References findItemById(), and mFunctionsMap.
Referenced by NumeReKernel::getFunctionLanguageStrings(), and listDefinitions().
string FunctionDefinitionManager::getImplementation | ( | size_t | _i | ) | const |
Returns the implementation of the ith defined custom function.
_i | size_t |
Definition at line 1002 of file define.cpp.
References findItemById(), and mFunctionsMap.
Referenced by listDefinitions().
|
inline |
Returns a list of the names of the custom defined functions.
Definition at line 127 of file define.hpp.
References mFunctionsMap.
Referenced by cmd_new().
|
inline |
Return a list of the internal defined default functions.
Definition at line 162 of file define.hpp.
References sBuilt_In.
Referenced by Procedure::Procedure(), and NumeReKernel::StartUp().
bool FunctionDefinitionManager::isDefined | ( | const std::string & | sFunc | ) |
This method checks, whether the passed function is already defined.
sFunc | const string& |
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().
bool FunctionDefinitionManager::load | ( | const Settings & | _option, |
bool | bAutoLoad = false |
||
) |
This function loads previously saved function definitions to memory.
_option | const Settings& |
bAutoLoad | 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().
bool FunctionDefinitionManager::reset | ( | ) |
This member function resets the FunctionDefinitionManager object to a state before any function was defined.
Definition at line 1040 of file define.cpp.
References mFunctionsMap.
Referenced by Script::close(), Script::openScript(), and Procedure::resetProcedure().
|
private |
This private member function resolves recursive definitions, which are handled by replacing the occuring function calls with their previous definition.
sDefinition | string |
Definition at line 545 of file define.cpp.
References call(), and StripSpaces().
Referenced by defineFunc().
bool FunctionDefinitionManager::save | ( | const Settings & | _option | ) |
This function saves the function definitions to the definition file.
_option | const Settings& |
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().
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.
sPredefined | const string& |
Definition at line 1158 of file define.cpp.
References sBuilt_In.
Referenced by Procedure::Procedure(), Procedure::setPredefinedFuncs(), Script::setPredefinedFuncs(), and NumeReKernel::StartUp().
|
inline |
Sets the internal table list. This list is used to avoid redefinition of an already existing table as a function.
sTableList | const std::string& |
Definition at line 148 of file define.hpp.
References sTables.
Referenced by cmd_define().
bool FunctionDefinitionManager::undefineFunc | ( | const std::string & | sFunc | ) |
This function removes a previously defined function from the internal memory.
sFunc | const string& |
Definition at line 772 of file define.cpp.
References NumeReKernel::getInstance(), isLocal, mFunctionsMap, and NumeReKernel::refreshFunctionTree().
Referenced by undefineFunctions().
|
private |
Definition at line 82 of file define.hpp.
Referenced by defineFunc(), FunctionDefinitionManager(), and undefineFunc().
|
private |
Definition at line 76 of file define.hpp.
Referenced by call(), defineFunc(), findItemById(), FunctionDefinitionManager(), getComment(), getDefinedFunctions(), getDefinitionString(), getFunctionIndex(), getFunctionSignature(), getImplementation(), getNamesOfDefinedFunctions(), isDefined(), load(), reset(), save(), and undefineFunc().
|
private |
Definition at line 79 of file define.hpp.
Referenced by defineFunc(), FunctionDefinitionManager(), getPredefinedFuncs(), isDefined(), and setPredefinedFuncs().
|
private |
Definition at line 80 of file define.hpp.
Referenced by defineFunc(), FunctionDefinitionManager(), and isDefined().
|
private |
Definition at line 77 of file define.hpp.
Referenced by FunctionDefinitionManager(), load(), and save().
|
private |
Definition at line 81 of file define.hpp.
Referenced by defineFunc(), FunctionDefinitionManager(), and setTableList().