IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Dynamically generates IRealFunction classes from user definitions. User can define in string form how function, its derivative, second derivative, integral, or inverse function is calculated. Then this class can be used to compile these definitions in the wrapping script, which is then used to create the corresponding function objects. More...
Public Member Functions | |
RealFunctionLoader () | |
Constructor. | |
void | InvalidateDefinitions () |
Clears strings that define the function (i.e. strings that define expressions for function value, derivative, integral, inverse, etc.). | |
void | SetNames (string returnedValueName, string functionArgumentName, string independentVariableName) |
Sets names used in generated script code. | |
void | SaveCode (string filePath) |
Saves the generated script code to the specified file. File is overwritten if it already exists. | |
string | Compile () |
Compiles the code that contains dynamically loadable definition of a real function of one variable. | |
LoadableRealFunctionBase | CreateRealFunction () |
Creates and returns an instance of dynamically compiled real function object. | |
LoadableRealFunctionBase | CreateRealFunction (double Kx, double Sx) |
Creates and returns an instance of dynamically compiled real function object. | |
LoadableRealFunctionBase | CreateRealFunction (double Kx, double Sx, double Ky, double Sy) |
Creates and returns an instance of dynamically compiled real function object. | |
Static Public Member Functions | |
static void | Example () |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions. | |
static void | Example (string scriptPath) |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions. | |
Public Attributes | |
const string | DefaultScriptClassName = "RealFunctionScript" |
Default name of the class used in loadable scripts containing user definitions of real function class. | |
const string | FuncNameInitDynamic = "InitDynamic" |
Name of the function that initializes variables realated to dynamically loaded real function class. | |
const string | VarNameReturnedValueName = "_returnedValueName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) where returned value is stored. | |
const string | DefaultReturnedValueName = "ret" |
Default name of the variable that holds returned value in script functions. | |
const string | VarNameFunctionArgumentName = "_functionArgumentName" |
Name of variable (internal in class defined in loadable script) that holds the name of function argument (defined within functions in the dynamically loaded script) through which independent variable is passed. | |
const string | DefaultFunctionArgumentName = "arg" |
Default name of the function argument in script functions. | |
const string | VarNameIndependentVariableName = "_independentVariableName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) that holds the independent variable in dunction definitions. | |
const string | DefaultIndependentVariableName = "x" |
Default name of the independent variable in expression definitions used in scripts to define calculation of function values, derivatives, etc. | |
const string | VarNameValueDefinitionString = "_valueDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function value. | |
const string | VarNameDerivativeDefinitionString = "_derivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function derivative. | |
const string | VarNameSecondDerivativeDefinitionString = "_secondDerivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function second derivative. | |
const string | VarNameIntegralDefinitionString = "_integralDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function integral. | |
const string | VarNameInverseDefinitionString = "_inverseDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function inverse. | |
const string | FuncNameValueDefinition = "RefValue" |
Name of the function (internal in class defined in loadable script) that defines calculation of function value. | |
const string | FuncNameDerivativeDefinition = "RefDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function derivative. | |
const string | FuncNameSecondDerivativeDefinition = "RefSecondDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function second derivative. | |
const string | FuncNameIntegralDefinition = "RefIntegral" |
Name of the function (internal in class defined in loadable script) that defines calculation of function integral. | |
const string | FuncNameInverseDefinition = "RefInverse" |
Name of the function (internal in class defined in loadable script) that defines calculation of function inverse. | |
const string | VarNameValueDefined = "_valueDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function value is implemented. | |
const string | VarNameDerivativeDefined = "_derivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function derivative is implemented. | |
const string | VarNameSecondDerivativeDefined = "_secondDerivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function second derivative is implemented. | |
const string | VarNameIntegralDefined = "_integralDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function integral is implemented. | |
const string | VarNameInverseDefined = "_inverseDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function inverse is implemented. | |
Protected Member Functions | |
virtual string | GetCode () |
Generates and returns script code for dynamically loadable function definition. | |
Properties | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. | |
bool | ValueDefined [get] |
Whether calculation of function value is implemented. | |
bool | DerivativeDefined [get] |
Whether calculation of function derivative is implemented. | |
bool | SecondDerivativeDefined [get] |
Whether calculation of function second derivative is implemented. | |
bool | IntegralDefined [get] |
Whether calculation of function indefinite integral is implemented. | |
bool | InverseDefined [get] |
Whether calculation of inverse function is implemented. | |
string | ReturnedValueName [get, set] |
Name of variable (within functions in the loadable scripts) that holds the returned value. Set to constant DefaultReturnedValueName by default. | |
string | FunctionArgumentName [get, set] |
Name of function arguments (in functions in the loadable scripts) that holds the independent variable. Set to constant DefaultFunctionArgumentName by default. | |
string | IndependentVariableName [get, set] |
Name of variable (within functions in the loadable scripts) that holds the independent variable. Set to constant DefaultIndependentVariableName by default. | |
string | ValueDefinitionString [get, set] |
Expression that defines function value. | |
string | DerivativeDefinitionString [get, set] |
Expression that defines function derivative. | |
string | SecondDerivativeDefinitionString [get, set] |
Expression that defines function second derivative. | |
string | IntegralDefinitionString [get, set] |
Expression that defines function indefinite integral derivative. | |
string | InverseDefinitionString [get, set] |
Expression that defines function inverse. | |
string | Code [get, set] |
Generated script code. | |
ScriptLoaderBase | Loader [get, set] |
Script loader used to load and instantiate real function class generated from script. | |
bool | IsCompiled [get, set] |
Whether the current function definition has been compiled or not. | |
string | ScriptClassName [get, set] |
Name of the script class that containe definition of the compiled real function class. | |
LoadableScriptRealFunctionBase | Creator [get] |
Returns an object of the dynamically compiled class that can create function objects. | |
Private Member Functions | |
void | AppendIndents (StringBuilder sb, int numIndent) |
Appends to the apecified string builder the specified level of indentation. | |
void | AppendSetVariable (StringBuilder sb, string varName, object value, int numIndents) |
Appends to the apecified string builder the C# statements that sets the specified variable to the specified value. | |
void | AppendFunctonDefinition (StringBuilder sb, string functionName, string definitionString, int numIndents) |
Appends to the apecified string builder the C# definition of a double function returning double. Function is of form 'protected override double (double arg)'. | |
Private Attributes | |
object | _mainLock = new object() |
string | _returnedValueName = DefaultReturnedValueName |
string | _functionArgumentName = DefaultFunctionArgumentName |
string | _independentVariableName = DefaultIndependentVariableName |
string | _valueDefinitionString |
string | _derivativeDefinitionString |
string | _secondDerivativeDefinitionString |
string | _integralDefinitionString |
string | _inverseDefinitionString |
string | _code |
ScriptLoaderBase | _loader |
bool | _iscompiled = false |
string | _scriptClassName |
Dynamically generates IRealFunction classes from user definitions. User can define in string form how function, its derivative, second derivative, integral, or inverse function is calculated. Then this class can be used to compile these definitions in the wrapping script, which is then used to create the corresponding function objects.
$A Igor Jun10;
IG::Lib::RealFunctionLoader::RealFunctionLoader | ( | ) | [inline] |
Constructor.
void IG::Lib::RealFunctionLoader::InvalidateDefinitions | ( | ) | [inline] |
Clears strings that define the function (i.e. strings that define expressions for function value, derivative, integral, inverse, etc.).
void IG::Lib::RealFunctionLoader::SetNames | ( | string | returnedValueName, |
string | functionArgumentName, | ||
string | independentVariableName | ||
) | [inline] |
Sets names used in generated script code.
returnedValueName | Name of the variabble that holds returned value in functions in generated script code. |
functionArgumentName | Name of function argument in generated script code. |
independentVariableName | Name of independent variable in generated script code. |
void IG::Lib::RealFunctionLoader::SaveCode | ( | string | filePath | ) | [inline] |
Saves the generated script code to the specified file. File is overwritten if it already exists.
filePath | Path to the file where script code is saved. |
void IG::Lib::RealFunctionLoader::AppendIndents | ( | StringBuilder | sb, |
int | numIndent | ||
) | [inline, private] |
Appends to the apecified string builder the specified level of indentation.
sb | String builder to which indents are appended. |
numIndente | Number of indents that are appended. |
void IG::Lib::RealFunctionLoader::AppendSetVariable | ( | StringBuilder | sb, |
string | varName, | ||
object | value, | ||
int | numIndents | ||
) | [inline, private] |
Appends to the apecified string builder the C# statements that sets the specified variable to the specified value.
sb | String builder to which the statement is appended. |
varName | Name of the variable that is set. |
value | Value that is assigned to the variable. |
numIndents | Number of indents that are written before code lines. |
void IG::Lib::RealFunctionLoader::AppendFunctonDefinition | ( | StringBuilder | sb, |
string | functionName, | ||
string | definitionString, | ||
int | numIndents | ||
) | [inline, private] |
Appends to the apecified string builder the C# definition of a double function returning double. Function is of form 'protected override double (double arg)'.
sb | String builder to which the code (function definition) is appended. |
functionName | Name of the function. |
definitionString | Expression that specifies how the returned value is calculated. |
numIndents | Number of indents that are prepended before code lines. |
virtual string IG::Lib::RealFunctionLoader::GetCode | ( | ) | [inline, protected, virtual] |
Generates and returns script code for dynamically loadable function definition.
string IG::Lib::RealFunctionLoader::Compile | ( | ) | [inline] |
Compiles the code that contains dynamically loadable definition of a real function of one variable.
LoadableRealFunctionBase IG::Lib::RealFunctionLoader::CreateRealFunction | ( | ) | [inline] |
Creates and returns an instance of dynamically compiled real function object.
LoadableRealFunctionBase IG::Lib::RealFunctionLoader::CreateRealFunction | ( | double | Kx, |
double | Sx | ||
) | [inline] |
Creates and returns an instance of dynamically compiled real function object.
$A Igor Sep11;
LoadableRealFunctionBase IG::Lib::RealFunctionLoader::CreateRealFunction | ( | double | Kx, |
double | Sx, | ||
double | Ky, | ||
double | Sy | ||
) | [inline] |
Creates and returns an instance of dynamically compiled real function object.
$A Igor Sep11;
static void IG::Lib::RealFunctionLoader::Example | ( | ) | [inline, static] |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions.
$A Igor Jun10;
static void IG::Lib::RealFunctionLoader::Example | ( | string | scriptPath | ) | [inline, static] |
Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions.
scriptPath | Path where script that defines the function is saved. If null or empty string then script is not saved to a file. |
$A Igor Jun10;
object IG::Lib::RealFunctionLoader::_mainLock = new object() [private] |
const string IG::Lib::RealFunctionLoader::DefaultScriptClassName = "RealFunctionScript" |
Default name of the class used in loadable scripts containing user definitions of real function class.
const string IG::Lib::RealFunctionLoader::FuncNameInitDynamic = "InitDynamic" |
Name of the function that initializes variables realated to dynamically loaded real function class.
const string IG::Lib::RealFunctionLoader::VarNameReturnedValueName = "_returnedValueName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) where returned value is stored.
const string IG::Lib::RealFunctionLoader::DefaultReturnedValueName = "ret" |
Default name of the variable that holds returned value in script functions.
const string IG::Lib::RealFunctionLoader::VarNameFunctionArgumentName = "_functionArgumentName" |
Name of variable (internal in class defined in loadable script) that holds the name of function argument (defined within functions in the dynamically loaded script) through which independent variable is passed.
const string IG::Lib::RealFunctionLoader::DefaultFunctionArgumentName = "arg" |
Default name of the function argument in script functions.
const string IG::Lib::RealFunctionLoader::VarNameIndependentVariableName = "_independentVariableName" |
Name of variable (internal in class defined in loadable script) that holds the name of local variable (defined within functions in the dynamically loaded script) that holds the independent variable in dunction definitions.
const string IG::Lib::RealFunctionLoader::DefaultIndependentVariableName = "x" |
Default name of the independent variable in expression definitions used in scripts to define calculation of function values, derivatives, etc.
const string IG::Lib::RealFunctionLoader::VarNameValueDefinitionString = "_valueDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function value.
const string IG::Lib::RealFunctionLoader::VarNameDerivativeDefinitionString = "_derivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function derivative.
const string IG::Lib::RealFunctionLoader::VarNameSecondDerivativeDefinitionString = "_secondDerivativeDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function second derivative.
const string IG::Lib::RealFunctionLoader::VarNameIntegralDefinitionString = "_integralDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function integral.
const string IG::Lib::RealFunctionLoader::VarNameInverseDefinitionString = "_inverseDefinitionString" |
Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function inverse.
const string IG::Lib::RealFunctionLoader::FuncNameValueDefinition = "RefValue" |
Name of the function (internal in class defined in loadable script) that defines calculation of function value.
const string IG::Lib::RealFunctionLoader::FuncNameDerivativeDefinition = "RefDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function derivative.
const string IG::Lib::RealFunctionLoader::FuncNameSecondDerivativeDefinition = "RefSecondDerivative" |
Name of the function (internal in class defined in loadable script) that defines calculation of function second derivative.
const string IG::Lib::RealFunctionLoader::FuncNameIntegralDefinition = "RefIntegral" |
Name of the function (internal in class defined in loadable script) that defines calculation of function integral.
const string IG::Lib::RealFunctionLoader::FuncNameInverseDefinition = "RefInverse" |
Name of the function (internal in class defined in loadable script) that defines calculation of function inverse.
const string IG::Lib::RealFunctionLoader::VarNameValueDefined = "_valueDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function value is implemented.
const string IG::Lib::RealFunctionLoader::VarNameDerivativeDefined = "_derivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function derivative is implemented.
const string IG::Lib::RealFunctionLoader::VarNameSecondDerivativeDefined = "_secondDerivativeDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function second derivative is implemented.
const string IG::Lib::RealFunctionLoader::VarNameIntegralDefined = "_integralDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function integral is implemented.
const string IG::Lib::RealFunctionLoader::VarNameInverseDefined = "_inverseDefined" |
Name of the variable (internal in class defined in loadable script) that holds a flag telling whether calculation of function inverse is implemented.
string IG::Lib::RealFunctionLoader::_returnedValueName = DefaultReturnedValueName [private] |
string IG::Lib::RealFunctionLoader::_functionArgumentName = DefaultFunctionArgumentName [private] |
string IG::Lib::RealFunctionLoader::_independentVariableName = DefaultIndependentVariableName [private] |
string IG::Lib::RealFunctionLoader::_valueDefinitionString [private] |
string IG::Lib::RealFunctionLoader::_derivativeDefinitionString [private] |
string IG::Lib::RealFunctionLoader::_secondDerivativeDefinitionString [private] |
string IG::Lib::RealFunctionLoader::_integralDefinitionString [private] |
string IG::Lib::RealFunctionLoader::_inverseDefinitionString [private] |
string IG::Lib::RealFunctionLoader::_code [private] |
bool IG::Lib::RealFunctionLoader::_iscompiled = false [private] |
string IG::Lib::RealFunctionLoader::_scriptClassName [private] |
object IG::Lib::RealFunctionLoader::Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
Implements IG::Lib::ILockable.
bool IG::Lib::RealFunctionLoader::ValueDefined [get] |
Whether calculation of function value is implemented.
bool IG::Lib::RealFunctionLoader::DerivativeDefined [get] |
Whether calculation of function derivative is implemented.
bool IG::Lib::RealFunctionLoader::SecondDerivativeDefined [get] |
Whether calculation of function second derivative is implemented.
bool IG::Lib::RealFunctionLoader::IntegralDefined [get] |
Whether calculation of function indefinite integral is implemented.
bool IG::Lib::RealFunctionLoader::InverseDefined [get] |
Whether calculation of inverse function is implemented.
string IG::Lib::RealFunctionLoader::ReturnedValueName [get, set] |
Name of variable (within functions in the loadable scripts) that holds the returned value. Set to constant DefaultReturnedValueName by default.
string IG::Lib::RealFunctionLoader::FunctionArgumentName [get, set] |
Name of function arguments (in functions in the loadable scripts) that holds the independent variable. Set to constant DefaultFunctionArgumentName by default.
string IG::Lib::RealFunctionLoader::IndependentVariableName [get, set] |
Name of variable (within functions in the loadable scripts) that holds the independent variable. Set to constant DefaultIndependentVariableName by default.
string IG::Lib::RealFunctionLoader::ValueDefinitionString [get, set] |
Expression that defines function value.
string IG::Lib::RealFunctionLoader::DerivativeDefinitionString [get, set] |
Expression that defines function derivative.
string IG::Lib::RealFunctionLoader::SecondDerivativeDefinitionString [get, set] |
Expression that defines function second derivative.
string IG::Lib::RealFunctionLoader::IntegralDefinitionString [get, set] |
Expression that defines function indefinite integral derivative.
string IG::Lib::RealFunctionLoader::InverseDefinitionString [get, set] |
Expression that defines function inverse.
string IG::Lib::RealFunctionLoader::Code [get, set] |
Generated script code.
ScriptLoaderBase IG::Lib::RealFunctionLoader::Loader [get, set] |
Script loader used to load and instantiate real function class generated from script.
$A Igor Jun10 Aug10;
bool IG::Lib::RealFunctionLoader::IsCompiled [get, set] |
Whether the current function definition has been compiled or not.
string IG::Lib::RealFunctionLoader::ScriptClassName [get, set] |
Name of the script class that containe definition of the compiled real function class.
LoadableScriptRealFunctionBase IG::Lib::RealFunctionLoader::Creator [get] |
Returns an object of the dynamically compiled class that can create function objects.