NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
procedurevarfactory.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2017 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include <string>
20#include <map>
21
22#include "../utils/tools.hpp"
23#include "../ui/error.hpp"
24#include "../datamanagement/memorymanager.hpp"
25#include "../maths/functionimplementation.hpp"
26#include "../maths/define.hpp"
27#include "../settings.hpp"
28#include "../io/output.hpp"
29#include "../plotting/plotdata.hpp"
30#include "../script.hpp"
31
32#ifndef PROCEDUREVARFACTORY_HPP
33#define PROCEDUREVARFACTORY_HPP
34
35// forward declaration of the procedure class
36class Procedure;
37
44{
45 private:
53
55
56 std::string sProcName;
57 unsigned int nth_procedure;
59
61 {
66 };
67
68 std::map<std::string,VarType> mLocalArgs;
69
70 void init();
71
72 std::string replaceProcedureName(std::string sProcedureName) const;
73 std::string createMangledArgName(const std::string& sDefinedName) const;
74 std::string createMangledVarName(const std::string& sDefinedName) const;
75
76 std::string resolveArguments(std::string sProcedureCommandLine, size_t nMapSize = std::string::npos);
77 std::string resolveLocalVars(std::string sProcedureCommandLine, size_t nMapSize = std::string::npos);
78 std::string resolveLocalStrings(std::string sProcedureCommandLine, size_t nMapSize = std::string::npos);
79 std::string resolveLocalTables(std::string sProcedureCommandLine, size_t nMapSize = std::string::npos);
80 std::string resolveLocalClusters(std::string sProcedureCommandLine, size_t nMapSize = std::string::npos);
81 unsigned int countVarListElements(const std::string& sVarList);
82 void checkArgument(const std::string& sArgument, const std::string& sArgumentList, unsigned int nCurrentIndex);
83 void checkArgumentValue(const std::string& sArgument, const std::string& sArgumentList, unsigned int nCurrentIndex);
84 bool checkSymbolName(const std::string& sSymbolName) const;
85 void createLocalInlineVars(std::string sVarList);
86 void createLocalInlineStrings(std::string sVarList);
87 void evaluateProcedureArguments(std::string& currentArg, std::string& currentValue, const std::string& sArgumentList);
88
89 public:
90 std::map<std::string, std::string> mArguments;
91 std::map<std::string, std::pair<std::string, mu::value_type*>> mLocalVars;
92 std::map<std::string, std::pair<std::string, std::string>> mLocalStrings;
93 std::map<std::string, std::string> mLocalTables;
94 std::map<std::string, std::string> mLocalClusters;
95
96 std::string sInlineVarDef;
97 std::string sInlineStringDef;
98 std::vector<std::string> vInlineArgDef;
99
101 ProcedureVarFactory(Procedure* _procedure, const std::string& sProc, unsigned int currentProc, bool _inliningMode = false);
103
104 void reset();
105 bool delayDeletionOfReturnedTable(const std::string& sTableName);
106 bool isReference(const std::string& sArgName) const;
107 std::map<std::string,std::string> createProcedureArguments(std::string sArgumentList, std::string sArgumentValues);
108 void createLocalVars(std::string sVarList);
109 void createLocalStrings(std::string sStringList);
110 void createLocalTables(std::string sTableList);
111 void createLocalClusters(std::string sClusterList);
112 std::string createTestStatsCluster();
113
114 std::string resolveVariables(const std::string& sProcedureCommandLine)
115 {
117 }
118};
119
120
121#endif // PROCEDUREVARFACTORY_HPP
122
This class implements the function definition managing instance.
Definition: define.hpp:74
This class represents the central memory managing instance. It will handle all tables and clusters,...
This class contains all the plot settings usable by the plotting algorithm.
Definition: plotdata.hpp:42
This class implements the logic to evaluate complex procedures, which may be called recursively.
Definition: procedure.hpp:56
This class is the variable factory used by procedure instances to create their local variables and re...
std::string resolveLocalStrings(std::string sProcedureCommandLine, size_t nMapSize=std::string::npos)
This private member function will resolve the calls to string variables in the passed procedure comma...
std::string resolveVariables(const std::string &sProcedureCommandLine)
std::map< std::string, std::string > createProcedureArguments(std::string sArgumentList, std::string sArgumentValues)
This member function will create the procedure arguments for the current procedure.
std::string resolveLocalTables(std::string sProcedureCommandLine, size_t nMapSize=std::string::npos)
This private member function will resolve the calls to local tables in the passed procedure command l...
std::map< std::string, VarType > mLocalArgs
std::map< std::string, std::string > mLocalClusters
void createLocalTables(std::string sTableList)
This member function will create the local tables for the current procedure.
void evaluateProcedureArguments(std::string &currentArg, std::string &currentValue, const std::string &sArgumentList)
This memberfunction will evaluate the passed procedure arguments and convert them to local variables ...
std::string resolveLocalVars(std::string sProcedureCommandLine, size_t nMapSize=std::string::npos)
This private member function will resolve the calls to numerical variables in the passed procedure co...
void createLocalStrings(std::string sStringList)
This member function will create the local string variables for the current procedure.
std::string replaceProcedureName(std::string sProcedureName) const
Replaces path characters and whitespaces to create variable names fitting for an non- relative proced...
void reset()
Resets the object.
void checkArgument(const std::string &sArgument, const std::string &sArgumentList, unsigned int nCurrentIndex)
This private member function checks, whether the keywords "var", "str" or "tab" are used in the curre...
std::map< std::string, std::string > mArguments
void createLocalInlineStrings(std::string sVarList)
This private member function creates the local string variables for inlined procedures.
FunctionDefinitionManager * _functionRef
std::map< std::string, std::pair< std::string, std::string > > mLocalStrings
std::string resolveLocalClusters(std::string sProcedureCommandLine, size_t nMapSize=std::string::npos)
This private member function will resolve the calls to local clusters in the passed procedure command...
ProcedureVarFactory()
Constructor.
std::string createMangledArgName(const std::string &sDefinedName) const
Creates a mangled name for an argument.
~ProcedureVarFactory()
Destructor.
bool checkSymbolName(const std::string &sSymbolName) const
Checks for invalid characters or similar.
unsigned int countVarListElements(const std::string &sVarList)
This private memebr function counts the number of elements in the passed string list.
std::string resolveArguments(std::string sProcedureCommandLine, size_t nMapSize=std::string::npos)
This private member function will resolve the calls to arguments in the passed procedure command line...
bool delayDeletionOfReturnedTable(const std::string &sTableName)
Searches for a local table or a local table in the arguments with the corresponding identifier,...
std::vector< std::string > vInlineArgDef
void createLocalClusters(std::string sClusterList)
This member function will create the local clusters for the current procedure.
void checkArgumentValue(const std::string &sArgument, const std::string &sArgumentList, unsigned int nCurrentIndex)
This private member function checks, whether the keywords "var", "str" or "tab" are used in the curre...
void createLocalInlineVars(std::string sVarList)
This private member function creates the local variables for inlined procedures.
std::map< std::string, std::string > mLocalTables
std::string createMangledVarName(const std::string &sDefinedName) const
Creates a mangled name for a variable.
std::string createTestStatsCluster()
Creates a special cluster containing the test statistics.
bool isReference(const std::string &sArgName) const
Returns whether the passed argument representation (i.e. local variable name) is actually a reference...
void init()
This member function is the initializer function.
void createLocalVars(std::string sVarList)
This member function will create the local numerical variables for the current procedure.
std::map< std::string, std::pair< std::string, mu::value_type * > > mLocalVars
This class manages the setting values of the internal (kernel) settings of this application.
Definition: settings.hpp:663
Mathematical expressions parser.
Definition: muParser.h:51