Public Member Functions | Static Public Member Functions | List of all members
openfluid::utils::Binding Class Reference

Class for easier binding with other programming languages. More...

#include <utils/Binding.hpp>

Public Member Functions

unsigned short int runSimulation (int IsVerbose=false)
 
void printSimulationInfo ()
 
const char * getSimulationOutputDir ()
 
int getDefaultDeltaT ()
 
void setDefaultDeltaT (int DeltaT)
 
const char * getPeriodBeginDate ()
 
const char * getPeriodEndDate ()
 
void setPeriod (const char *BeginDate, const char *EndDate)
 
const char * getSimulatorsIDs ()
 
const char * getSimulatorParamNames (const char *SimID)
 
const char * getSimulatorParam (const char *SimID, const char *ParamName)
 
void setSimulatorParam (const char *SimID, const char *ParamName, const char *ParamVal)
 
void removeSimulatorParam (const char *SimID, const char *ParamName)
 
const char * getGeneratorParamNames (const char *UnitsClass, const char *VarName)
 
const char * getGeneratorParam (const char *UnitsClass, const char *VarName, const char *ParamName)
 
void setGeneratorParam (const char *UnitsClass, const char *VarName, const char *ParamName, const char *ParamVal)
 
const char * getGeneratorsVarNames (const char *UnitsClass)
 
const char * getModelGlobalParamNames ()
 
const char * getModelGlobalParam (const char *ParamName)
 
void setModelGlobalParam (const char *ParamName, const char *ParamVal)
 
void removeModelGlobalParam (const char *ParamName)
 
const char * getObserversIDs ()
 
const char * getObserverParamNames (const char *ObsID)
 
const char * getObserverParam (const char *ObsID, const char *ParamName)
 
void setObserverParam (const char *ObsID, const char *ParamName, const char *ParamVal)
 
void removeObserverParam (const char *ObsID, const char *ParamName)
 
char ** getUnitsClasses ()
 
unsigned int getUnitsClassesCount ()
 
int * getUnitsIDs (const char *UnitsClass)
 
unsigned int getUnitsIDsCount (const char *UnitsClass)
 
const char * getAttributesNames (const char *UnitsClass)
 
void createAttribute (const char *UnitsClass, const char *AttrName, const char *AttrVal)
 
const char * getAttribute (const char *UnitsClass, int UnitID, const char *AttrName)
 
void setAttribute (const char *UnitsClass, int UnitID, const char *AttrName, const char *AttrVal)
 
void removeAttribute (const char *UnitsClass, const char *AttrName)
 
void addVariablesExportAsCSV (const char *BindingName, const char *UnitsClass, const char *UnitsIDs, const char *VarName, int Precision)
 

Static Public Member Functions

static void init ()
 
static Bindingmake ()
 
static void destroy (Binding *B)
 
static const char * getVersion ()
 
static const char * getLastError ()
 
static void addExtraSimulatorsPaths (const char *Paths)
 
static void resetExtraSimulatorsPaths ()
 
static unsigned int getSimulatorsPathsCount ()
 
static char ** getSimulatorsPaths ()
 
static unsigned int getExtraSimulatorsPathsCount ()
 
static char ** getExtraSimulatorsPaths ()
 
static void addExtraObserversPaths (const char *Paths)
 
static void resetExtraObserversPaths ()
 
static unsigned int getObserversPathsCount ()
 
static char ** getObserversPaths ()
 
static unsigned int getExtraObserversPathsCount ()
 
static char ** getExtraObserversPaths ()
 
static void setCurrentOutputDir (const char *Path)
 
static BindingopenDataset (const char *Path)
 
static BindingopenProject (const char *Path)
 

Detailed Description

Class for easier binding with other programming languages.

Class for easier binding of OpenFLUID with other programming languages, such as Python, R, JavaScript, ... This class provides common methods to open datasets, add wares paths, modify parameters and attributes, run simulations and many more. All of these methods have parameters and return values in plain old types for better interoperability with other languages, excepted for internal data usually handled as "external pointers" in bindings.

To use this header-only class

Example

{
public:
void printfOut(const char* fmt, ... ) const
{
va_list args;
va_start(args,fmt);
vprintf(fmt,args);
va_end(args);
}
void printfErr(const char* fmt, ... ) const
{
va_list args;
va_start(args,fmt);
vfprintf(stderr,fmt,args);
va_end(args);
}
};
// proceed here with the use of the binding class features

Member Function Documentation

◆ addExtraObserversPaths()

static void openfluid::utils::Binding::addExtraObserversPaths ( const char *  Paths)
inlinestatic

Add supplementary paths to search for observers when running simulations

Parameters
[in]Pathsthe paths to add using the path separator used on the current system
See also
openfluid::base::Environment::addExtraObserversDirs

◆ addExtraSimulatorsPaths()

static void openfluid::utils::Binding::addExtraSimulatorsPaths ( const char *  Paths)
inlinestatic

Add supplementary paths to search for simulators when running simulations

Parameters
[in]PathsThe paths to add using the path separator used on the current system
See also
openfluid::base::Environment::addExtraSimulatorsDirs

◆ addVariablesExportAsCSV()

void openfluid::utils::Binding::addVariablesExportAsCSV ( const char *  BindingName,
const char *  UnitsClass,
const char *  UnitsIDs,
const char *  VarName,
int  Precision 
)
inline

Adds simulation variable to be automatically exported using CSV format.

Parameters
[in]BindingNameThe name used as an identifier in output files names
[in]UnitsClassThe name of the spatial units class
[in]UnitsIDsThe semicolon separated list of spatial units IDs, can be '*' for all spatial units
[in]VarNameThe name of the variable
[in]PrecisionThe floating precision to use for floating point representation, default precision is used if this parameter is less or equal to 0

◆ createAttribute()

void openfluid::utils::Binding::createAttribute ( const char *  UnitsClass,
const char *  AttrName,
const char *  AttrVal 
)
inline

Creates an attribute for all spatial units of a given class, with a default value for this attribute.

Parameters
[in]UnitsClassThe spatial units class
[in]AttrNameThe name of the attribute
[in]AttrValThe default value for this attribute

◆ destroy()

static void openfluid::utils::Binding::destroy ( Binding B)
inlinestatic

Deletes a given instance

Parameters
[in]BThe instance to delete

◆ getAttribute()

const char* openfluid::utils::Binding::getAttribute ( const char *  UnitsClass,
int  UnitID,
const char *  AttrName 
)
inline

Returns the value of an attribute of a spatial unit.

Parameters
[in]UnitsClassThe spatial units class
[in]UnitIDThe spatial unit ID
[in]AttrNameThe name of the attribute
Returns
The value of the attribute, as a string

◆ getAttributesNames()

const char* openfluid::utils::Binding::getAttributesNames ( const char *  UnitsClass)
inline

Returns the list of the attributes names for a given spatial units class, as a semicolon separated list.

Parameters
[in]UnitsClassThe units class
Returns
The list of attributes names

◆ getDefaultDeltaT()

int openfluid::utils::Binding::getDefaultDeltaT ( )
inline

Returns the default delta T for the current simulation

Returns
The delta T

◆ getExtraObserversPaths()

static char** openfluid::utils::Binding::getExtraObserversPaths ( )
inlinestatic

Returns the supplementary paths to search for observers

Returns
The paths list

◆ getExtraObserversPathsCount()

static unsigned int openfluid::utils::Binding::getExtraObserversPathsCount ( )
inlinestatic

Returns the number of supplementary paths to search for observers

Returns
The number of paths

◆ getExtraSimulatorsPaths()

static char** openfluid::utils::Binding::getExtraSimulatorsPaths ( )
inlinestatic

Returns the supplementary paths to search for simulators

Returns
the paths list

◆ getExtraSimulatorsPathsCount()

static unsigned int openfluid::utils::Binding::getExtraSimulatorsPathsCount ( )
inlinestatic

Returns the number of supplementary paths to search for simulators

Returns
the number of paths

◆ getGeneratorParam()

const char* openfluid::utils::Binding::getGeneratorParam ( const char *  UnitsClass,
const char *  VarName,
const char *  ParamName 
)
inline

Returns the value of a given generator parameter, an empty string if not found.

Parameters
[in]UnitsClassThe name of the spatial units class
[in]VarNameThe name of the generated variable
[in]ParamNameThe name of the parameter
Returns
The value of the parameter, as a string

◆ getGeneratorParamNames()

const char* openfluid::utils::Binding::getGeneratorParamNames ( const char *  UnitsClass,
const char *  VarName 
)
inline

Returns the list of the parameters names for a given generator, as a semicolon separated list.

Parameters
[in]UnitsClassThe name of the spatial units class
[in]VarNameThe name of the generated variable
Returns
The list of parameters names

◆ getGeneratorsVarNames()

const char* openfluid::utils::Binding::getGeneratorsVarNames ( const char *  UnitsClass)
inline

Returns the list of the variables produced by generators on a given spatial units class, as a semicolon separated list.

Parameters
[in]UnitsClassThe spatial units class
Returns
The list of produced variables

◆ getLastError()

static const char* openfluid::utils::Binding::getLastError ( )
inlinestatic

Returns the last error message

◆ getModelGlobalParam()

const char* openfluid::utils::Binding::getModelGlobalParam ( const char *  ParamName)
inline

Returns the value of a given global parameter for the current model.

Parameters
[in]ParamNameThe name of the parameter
Returns
The value of the parameter, as a string

◆ getModelGlobalParamNames()

const char* openfluid::utils::Binding::getModelGlobalParamNames ( )
inline

Returns the list of the global parameters for the current model, as a semicolon separated list.

Returns
The list of parameters names

◆ getObserverParam()

const char* openfluid::utils::Binding::getObserverParam ( const char *  ObsID,
const char *  ParamName 
)
inline

Returns the value of a given observer parameter, an empty string if not found.

Parameters
[in]ObsIDThe ID of the observer
[in]ParamNameThe name of the parameter
Returns
The value of the parameter, as a string

◆ getObserverParamNames()

const char* openfluid::utils::Binding::getObserverParamNames ( const char *  ObsID)
inline

Returns the list of the parameters names for a given observer, as a semicolon separated list.

Parameters
[in]ObsIDThe ID of the observer
Returns
The list of parameters names

◆ getObserversIDs()

const char* openfluid::utils::Binding::getObserversIDs ( )
inline

Returns the IDs list of the observers used in the current model, as a semicolon separated list.

Returns
The list of IDs

◆ getObserversPaths()

static char** openfluid::utils::Binding::getObserversPaths ( )
inlinestatic

Returns the default paths to search for observers

Returns
The paths list

◆ getObserversPathsCount()

static unsigned int openfluid::utils::Binding::getObserversPathsCount ( )
inlinestatic

Returns the number of default paths to search for observers

Returns
The number of paths

◆ getPeriodBeginDate()

const char* openfluid::utils::Binding::getPeriodBeginDate ( )
inline

Returns the begin date for the simulation period, as an ISO date-time string (with a space instead of a T letter, e.g. : 2008-01-02 11:13:00)

Returns
The begin date as a string

◆ getPeriodEndDate()

const char* openfluid::utils::Binding::getPeriodEndDate ( )
inline

Returns the end date for the simulation period, as an ISO date-time string (with a space instead of a T letter, e.g. : 2011-08-06 15:00:00)

Returns
The end date as a string

◆ getSimulationOutputDir()

const char* openfluid::utils::Binding::getSimulationOutputDir ( )
inline

Returns the simulation output directory

Returns
The path to the output directory

◆ getSimulatorParam()

const char* openfluid::utils::Binding::getSimulatorParam ( const char *  SimID,
const char *  ParamName 
)
inline

Returns the value of a given simulator parameter, an empty string if not found.

Parameters
[in]SimIDThe ID of the simulator
[in]ParamNameThe name of the parameter
Returns
The value of the parameter, as a string

◆ getSimulatorParamNames()

const char* openfluid::utils::Binding::getSimulatorParamNames ( const char *  SimID)
inline

Returns the list of the parameters names for a given simulator, as a semicolon separated list.

Parameters
[in]SimIDThe ID of the simulator
Returns
The list of parameters names

◆ getSimulatorsIDs()

const char* openfluid::utils::Binding::getSimulatorsIDs ( )
inline

Returns the IDs list of the simulators used in the current model, as a semicolon separated list.

Returns
The list of IDs

◆ getSimulatorsPaths()

static char** openfluid::utils::Binding::getSimulatorsPaths ( )
inlinestatic

Returns the default paths to search for simulators

Returns
the paths list

◆ getSimulatorsPathsCount()

static unsigned int openfluid::utils::Binding::getSimulatorsPathsCount ( )
inlinestatic

Returns the number of default paths to search for simulators

Returns
the number of paths

◆ getUnitsClasses()

char** openfluid::utils::Binding::getUnitsClasses ( )
inline

Returns the spatial units classes names as a list of strings.

Returns
The list of spatial units classes

◆ getUnitsClassesCount()

unsigned int openfluid::utils::Binding::getUnitsClassesCount ( )
inline

Returns the number of spatial units classes names.

Returns
The number of spatial units classes

◆ getUnitsIDs()

int* openfluid::utils::Binding::getUnitsIDs ( const char *  UnitsClass)
inline

Returns the spatial units IDs for a given spatial units class, as a list of integers.

Returns
The list of spatial units IDs

◆ getUnitsIDsCount()

unsigned int openfluid::utils::Binding::getUnitsIDsCount ( const char *  UnitsClass)
inline

Returns the number of spatial units IDs for a given spatial units class.

Returns
The number of spatial units IDs

◆ getVersion()

static const char* openfluid::utils::Binding::getVersion ( )
inlinestatic

Returns the OpenFLUID version

◆ init()

static void openfluid::utils::Binding::init ( )
inlinestatic

Static initialization of the binding. Muste be called at least once.

◆ make()

static Binding* openfluid::utils::Binding::make ( )
inlinestatic

Returns a new instance

Returns
The newly created instance

◆ openDataset()

static Binding* openfluid::utils::Binding::openDataset ( const char *  Path)
inlinestatic

Opens an OpenFLUID dataset given by its path

Parameters
[in]PathThe path to the dataset
Returns
an instance of the Binding for the opened dataset, NULL if an error occured

◆ openProject()

static Binding* openfluid::utils::Binding::openProject ( const char *  Path)
inlinestatic

Opens an OpenFLUID project given by its path

Parameters
[in]PathThe path to the project
Returns
an instance of the Binding for the opened project, NULL if an error occured

◆ printSimulationInfo()

void openfluid::utils::Binding::printSimulationInfo ( )
inline

Prints informations about simulation configuration (spatial domain, processes model, ...)

◆ removeAttribute()

void openfluid::utils::Binding::removeAttribute ( const char *  UnitsClass,
const char *  AttrName 
)
inline

Removes an attribute for all spatial units of a given class.

Parameters
[in]UnitsClassThe spatial units class
[in]AttrNameThe name of the attribute

◆ removeModelGlobalParam()

void openfluid::utils::Binding::removeModelGlobalParam ( const char *  ParamName)
inline

Removes a given global parameter for the current model.

Parameters
[in]ParamNameThe name of the parameter

◆ removeObserverParam()

void openfluid::utils::Binding::removeObserverParam ( const char *  ObsID,
const char *  ParamName 
)
inline

Removes a given observer parameter.

Parameters
[in]ObsIDThe ID of the observer
[in]ParamNameThe name of the parameter

◆ removeSimulatorParam()

void openfluid::utils::Binding::removeSimulatorParam ( const char *  SimID,
const char *  ParamName 
)
inline

Removes a given simulator parameter.

Parameters
[in]SimIDThe ID of the simulator
[in]ParamNameThe name of the parameter

◆ resetExtraObserversPaths()

static void openfluid::utils::Binding::resetExtraObserversPaths ( )
inlinestatic

Resets the list of supplementary paths to search for observers

◆ resetExtraSimulatorsPaths()

static void openfluid::utils::Binding::resetExtraSimulatorsPaths ( )
inlinestatic

Resets the list of supplementary paths to search for simulators

◆ runSimulation()

unsigned short int openfluid::utils::Binding::runSimulation ( int  IsVerbose = false)
inline

Runs a simulation based on the current configuration for simulation.

Parameters
[in]IsVerboseSet to true to enable verbosity (false by default).

◆ setAttribute()

void openfluid::utils::Binding::setAttribute ( const char *  UnitsClass,
int  UnitID,
const char *  AttrName,
const char *  AttrVal 
)
inline

Sets an attribute value for a given spatial unit.

Parameters
[in]UnitsClassThe spatial units class
[in]UnitIDThe spatial unit ID
[in]AttrNameThe name of the attribute
[in]AttrValThe new value for this attribute

◆ setCurrentOutputDir()

static void openfluid::utils::Binding::setCurrentOutputDir ( const char *  Path)
inlinestatic

Sets the current output path used by default

Parameters
[in]PathThe output path to use

◆ setDefaultDeltaT()

void openfluid::utils::Binding::setDefaultDeltaT ( int  DeltaT)
inline

Sets the default delta T for the current simulation

Parameters
[in]DeltaTThe delta T to set

◆ setGeneratorParam()

void openfluid::utils::Binding::setGeneratorParam ( const char *  UnitsClass,
const char *  VarName,
const char *  ParamName,
const char *  ParamVal 
)
inline

Sets the value for a given generator parameter, an empty string if not found.

Parameters
[in]UnitsClassThe name of the spatial units class
[in]VarNameThe name of the generated variable
[in]ParamNameThe name of the parameter
[in]ParamValThe new value for the parameter

◆ setModelGlobalParam()

void openfluid::utils::Binding::setModelGlobalParam ( const char *  ParamName,
const char *  ParamVal 
)
inline

Sets the value of a given global parameter for the current model.

Parameters
[in]ParamNameThe name of the parameter
[in]ParamValThe new value for the parameter

◆ setObserverParam()

void openfluid::utils::Binding::setObserverParam ( const char *  ObsID,
const char *  ParamName,
const char *  ParamVal 
)
inline

Sets the value of a given observer parameter.

Parameters
[in]ObsIDThe ID of the observer
[in]ParamNameThe name of the parameter
[in]ParamValThe new value for the parameter

◆ setPeriod()

void openfluid::utils::Binding::setPeriod ( const char *  BeginDate,
const char *  EndDate 
)
inline

Sets the simulation period with begin and end dates. The dates are given as ISO date-time strings (with a space instead of a T letter, e.g. : 2008-01-02 11:13:00, 2011-08-06 15:00:00)

Parameters
[in]BeginDateThe begin date as a string
[in]EndDateThe end date as a string

◆ setSimulatorParam()

void openfluid::utils::Binding::setSimulatorParam ( const char *  SimID,
const char *  ParamName,
const char *  ParamVal 
)
inline

Sets the value of a given simulator parameter.

Parameters
[in]SimIDThe ID of the simulator
[in]ParamNameThe name of the parameter
[in]ParamValThe new value for the parameter

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