IGLib  1.7.2
The IGLib base library for development of numerical, technical and business applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Lib.RealFunctionLoader Class Reference

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...

+ Inheritance diagram for IG.Lib.RealFunctionLoader:
+ Collaboration diagram for IG.Lib.RealFunctionLoader:

Public Member Functions

 RealFunctionLoader ()
 Constructor. More...
 
void InvalidateDefinitions ()
 Clears strings that define the function (i.e. strings that define expressions for function value, derivative, integral, inverse, etc.). More...
 
void SetNames (string returnedValueName, string functionArgumentName, string independentVariableName)
 Sets names used in generated script code. More...
 
void SaveCode (string filePath)
 Saves the generated script code to the specified file. File is overwritten if it already exists. More...
 
string Compile ()
 Compiles the code that contains dynamically loadable definition of a real function of one variable. More...
 
LoadableRealFunctionBase CreateRealFunction ()
 Creates and returns an instance of dynamically compiled real function object. More...
 
LoadableRealFunctionBase CreateRealFunction (double Kx, double Sx)
 Creates and returns an instance of dynamically compiled real function object. More...
 
LoadableRealFunctionBase CreateRealFunction (double Kx, double Sx, double Ky, double Sy)
 Creates and returns an instance of dynamically compiled real function object. More...
 

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. More...
 
static void Example (string scriptPath)
 Example of use of the RealFunctionLoader class. Creates a function loader and uses it for dynamic definition of functions. More...
 

Public Attributes

const string DefaultScriptClassName = "RealFunctionScript"
 Default name of the class used in loadable scripts containing user definitions of real function class. More...
 
const string FuncNameInitDynamic = "InitDynamic"
 Name of the function that initializes variables realated to dynamically loaded real function class. More...
 
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. More...
 
const string DefaultReturnedValueName = "ret"
 Default name of the variable that holds returned value in script functions. More...
 
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. More...
 
const string DefaultFunctionArgumentName = "arg"
 Default name of the function argument in script functions. More...
 
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. More...
 
const string DefaultIndependentVariableName = "x"
 Default name of the independent variable in expression definitions used in scripts to define calculation of function values, derivatives, etc. More...
 
const string VarNameValueDefinitionString = "_valueDefinitionString"
 Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function value. More...
 
const string VarNameDerivativeDefinitionString = "_derivativeDefinitionString"
 Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function derivative. More...
 
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. More...
 
const string VarNameIntegralDefinitionString = "_integralDefinitionString"
 Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function integral. More...
 
const string VarNameInverseDefinitionString = "_inverseDefinitionString"
 Name of the variable (internal in class defined in loadable script) that holds user definition (as string) of function inverse. More...
 
const string FuncNameValueDefinition = "RefValue"
 Name of the function (internal in class defined in loadable script) that defines calculation of function value. More...
 
const string FuncNameDerivativeDefinition = "RefDerivative"
 Name of the function (internal in class defined in loadable script) that defines calculation of function derivative. More...
 
const string FuncNameSecondDerivativeDefinition = "RefSecondDerivative"
 Name of the function (internal in class defined in loadable script) that defines calculation of function second derivative. More...
 
const string FuncNameIntegralDefinition = "RefIntegral"
 Name of the function (internal in class defined in loadable script) that defines calculation of function integral. More...
 
const string FuncNameInverseDefinition = "RefInverse"
 Name of the function (internal in class defined in loadable script) that defines calculation of function inverse. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 

Protected Member Functions

virtual string GetCode ()
 Generates and returns script code for dynamically loadable function definition. More...
 

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. More...
 
bool ValueDefined [get]
 Whether calculation of function value is implemented. More...
 
bool DerivativeDefined [get]
 Whether calculation of function derivative is implemented. More...
 
bool SecondDerivativeDefined [get]
 Whether calculation of function second derivative is implemented. More...
 
bool IntegralDefined [get]
 Whether calculation of function indefinite integral is implemented. More...
 
bool InverseDefined [get]
 Whether calculation of inverse function is implemented. More...
 
string ReturnedValueName [get, set]
 Name of variable (within functions in the loadable scripts) that holds the returned value. Set to constant DefaultReturnedValueName by default. More...
 
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. More...
 
string IndependentVariableName [get, set]
 Name of variable (within functions in the loadable scripts) that holds the independent variable. Set to constant DefaultIndependentVariableName by default. More...
 
string ValueDefinitionString [get, set]
 Expression that defines function value. More...
 
string DerivativeDefinitionString [get, set]
 Expression that defines function derivative. More...
 
string SecondDerivativeDefinitionString [get, set]
 Expression that defines function second derivative. More...
 
string IntegralDefinitionString [get, set]
 Expression that defines function indefinite integral derivative. More...
 
string InverseDefinitionString [get, set]
 Expression that defines function inverse. More...
 
string Code [get, protected set]
 Generated script code. More...
 
ScriptLoaderBase Loader [get, protected set]
 Script loader used to load and instantiate real function class generated from script. More...
 
bool IsCompiled [get, protected set]
 Whether the current function definition has been compiled or not. More...
 
string ScriptClassName [get, protected set]
 Name of the script class that containe definition of the compiled real function class. More...
 
LoadableScriptRealFunctionBase Creator [get]
 Returns an object of the dynamically compiled class that can create function objects. More...
 
- Properties inherited from IG.Lib.ILockable
object Lock [get]
 

Private Member Functions

void AppendIndents (StringBuilder sb, int numIndent)
 Appends to the apecified string builder the specified level of indentation. More...
 
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. More...
 
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)'. More...
 

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
 

Detailed Description

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;

Constructor & Destructor Documentation

IG.Lib.RealFunctionLoader.RealFunctionLoader ( )
inline

Constructor.

Member Function Documentation

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.).

Referenced by IG.Lib.RealFunctionLoader.Example().

void IG.Lib.RealFunctionLoader.SetNames ( string  returnedValueName,
string  functionArgumentName,
string  independentVariableName 
)
inline

Sets names used in generated script code.

Parameters
returnedValueNameName of the variabble that holds returned value in functions in generated script code.
functionArgumentNameName of function argument in generated script code.
independentVariableNameName 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.

Parameters
filePathPath to the file where script code is saved.
void IG.Lib.RealFunctionLoader.AppendIndents ( StringBuilder  sb,
int  numIndent 
)
inlineprivate

Appends to the apecified string builder the specified level of indentation.

Parameters
sbString builder to which indents are appended.
numIndentNumber of indents that are appended.
void IG.Lib.RealFunctionLoader.AppendSetVariable ( StringBuilder  sb,
string  varName,
object  value,
int  numIndents 
)
inlineprivate

Appends to the apecified string builder the C# statements that sets the specified variable to the specified value.

Parameters
sbString builder to which the statement is appended.
varNameName of the variable that is set.
valueValue that is assigned to the variable.
numIndentsNumber of indents that are written before code lines.
void IG.Lib.RealFunctionLoader.AppendFunctonDefinition ( StringBuilder  sb,
string  functionName,
string  definitionString,
int  numIndents 
)
inlineprivate

Appends to the apecified string builder the C# definition of a double function returning double. Function is of form 'protected override double (double arg)'.

Parameters
sbString builder to which the code (function definition) is appended.
functionNameName of the function.
definitionStringExpression that specifies how the returned value is calculated.
numIndentsNumber of indents that are prepended before code lines.
virtual string IG.Lib.RealFunctionLoader.GetCode ( )
inlineprotectedvirtual

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.

Returns
LoadableRealFunctionBase IG.Lib.RealFunctionLoader.CreateRealFunction ( )
inline

Creates and returns an instance of dynamically compiled real function object.

Referenced by IG.Lib.RealFunctionLoader.Example().

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 ( )
inlinestatic

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)
inlinestatic

Member Data Documentation

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
ScriptLoaderBase IG.Lib.RealFunctionLoader._loader
private
bool IG.Lib.RealFunctionLoader._iscompiled = false
private
string IG.Lib.RealFunctionLoader._scriptClassName
private

Property Documentation

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.

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
getset

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
getset

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
getset

Name of variable (within functions in the loadable scripts) that holds the independent variable. Set to constant DefaultIndependentVariableName by default.

Referenced by IG.Lib.RealFunctionLoader.Example().

string IG.Lib.RealFunctionLoader.ValueDefinitionString
getset

Expression that defines function value.

Referenced by IG.Lib.RealFunctionLoader.Example().

string IG.Lib.RealFunctionLoader.DerivativeDefinitionString
getset

Expression that defines function derivative.

Referenced by IG.Lib.RealFunctionLoader.Example().

string IG.Lib.RealFunctionLoader.SecondDerivativeDefinitionString
getset

Expression that defines function second derivative.

string IG.Lib.RealFunctionLoader.IntegralDefinitionString
getset

Expression that defines function indefinite integral derivative.

string IG.Lib.RealFunctionLoader.InverseDefinitionString
getset

Expression that defines function inverse.

string IG.Lib.RealFunctionLoader.Code
getprotected set

Generated script code.

Referenced by IG.Lib.RealFunctionLoader.Example().

ScriptLoaderBase IG.Lib.RealFunctionLoader.Loader
getprotected set

Script loader used to load and instantiate real function class generated from script.

$A Igor Jun10 Aug10;

bool IG.Lib.RealFunctionLoader.IsCompiled
getprotected set

Whether the current function definition has been compiled or not.

string IG.Lib.RealFunctionLoader.ScriptClassName
getprotected 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.


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