Libpf::User Namespace Reference

Classes

class  CallBack
 To define a call-back to be invoked when the asynchronous Case operations finish. More...
 
class  Case
 An instance of a model - knows about variables, can be calculated and can export data to various formats. More...
 
class  CaseDescriptor
 Extends Defaults to include the name of the type and a list of quantities. More...
 
class  Handle
 Opaque pointer to a server-side resource i.e. a Case object. More...
 
struct  KernelImplementation
 Describes the capabilities of a service / standalone kernel for a specific simulation domain. More...
 

Enumerations

enum  ErrorCode { ERROR_OK = 0 , ERROR_COMMUNICATION = -91 , ERROR_ARGUMENT = -92 , ERROR_SERVER = -93 }
 

Functions

void initializeKernel (void)
 
void uninitializeKernel (void)
 
void addLocale (const std::string &locale)
 
void addEnumerator (const Libpf::Utility::EnumeratorInterface &ei)
 
const std::string & name (void)
 
const std::string & uuid (void)
 
const std::string & description (void)
 
const std::string & license (void)
 
const std::string & version (void)
 
const std::string & apiVersion (int &error)
 query the Model User API version More...
 
const std::string & defaultType (void)
 query the default type More...
 
const std::vector< std::string > & supportedLocales (int &error)
 query the locales supported by the server side derived classes can re-implement this method to override the default list provided by the library More...
 
int setLocale (const std::string &locale)
 sets the locale for internationalization; the default value is en More...
 
int activate (void)
 performs activation of the server side More...
 
const std::vector< Libpf::Persistency::TypeDescriptor > & listTypes (int &error)
 queries the available types More...
 
std::string jsonListTypes (int &error)
 queries the available types More...
 
const std::vector< Libpf::Core::Enumerator > & listEnumerators (int &error)
 queries the available enumerators More...
 
std::string jsonListEnumerators (int &error)
 
const Libpf::Persistency::TypeDescriptor * typeDescriptor (std::string name, int &error)
 
std::string jsonTypeDescriptor (std::string name, int &error)
 queries a specific type More...
 
const Libpf::Core::Enumerator * enumerator (const std::string &name, int &error)
 queries a specific enumerator More...
 
Libpf::User::Handle createCase (const std::string &type, const std::string &tag, const std::string &description, const std::map< std::string, std::string > &stringOptions, const std::map< std::string, int > &integerOptions, int &error)
 creates a new case instance More...
 
Libpf::User::Handle createCase (const std::string &jcd, int &error)
 creates a new case instance More...
 
Libpf::User::Handle createCase (const std::string &type, const std::string &tag, const std::string &description, const std::string &jcd, int &error)
 creates a new case instance More...
 
int remove (Libpf::User::Handle handle)
 remove an existing case instance More...
 
Libpf::User::Handle duplicate (Libpf::User::Handle handle, const std::string &tag, const std::string &description, int &error)
 duplicate an existing case instance More...
 
int purge (void)
 remove all existing case instances More...
 
std::string errorMessage (int error)
 
void setVerbosityGlobal (int verbosity)
 
int main (int argc, char *argv[])
 Implements the LIBPF Model User API. More...
 

Enumeration Type Documentation

◆ ErrorCode

Enumerator
ERROR_OK 

no error

ERROR_COMMUNICATION 

communication problem

ERROR_ARGUMENT 

supplied argument is not valid

ERROR_SERVER 

server-side error while performing the operation

Function Documentation

◆ activate()

int Libpf::User::activate ( void  )

performs activation of the server side

Returns
one of ERROR_OK, ERROR_COMMUNICATION, ERROR_SERVER

◆ addEnumerator()

void Libpf::User::addEnumerator ( const Libpf::Utility::EnumeratorInterface &  ei)

◆ addLocale()

void Libpf::User::addLocale ( const std::string &  locale)

◆ apiVersion()

const std::string & Libpf::User::apiVersion ( int &  error)

query the Model User API version

Parameters
[out]errorone of ERROR_OK, ERROR_COMMUNICATION
Returns
the version of the API supported by the server side
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=apiVersion

◆ createCase() [1/3]

Libpf::User::Handle Libpf::User::createCase ( const std::string &  jcd,
int &  error 
)

creates a new case instance

CaseDescriptor cd("jasper","case123","jasper case with 1=2 3 times");
cd.addIntegerOption("a", 1);
cd.addStringOption("b", "c");
cd.addQuantity("d", 11.0);
std::string jcd = cd.json();
Libpf::User::Handle caseHandle = kernel.createCase(jcd,error);
Libpf::User::Case myCase(caseHandle);
Extends Defaults to include the name of the type and a list of quantities.
Definition: CaseDescriptor.h:40
An instance of a model - knows about variables, can be calculated and can export data to various form...
Definition: Case.h:59
Opaque pointer to a server-side resource i.e. a Case object.
Definition: Handle.h:43
Returns
a valid, persistent Case handle on success, or an invalid Handle if there was an error the returned Handle can be used as part of the URN for the case, within the case: namespace
Parameters
[in]jcdUTF-8 encoded, JSON-serialized CaseDescriptor object
[out]errorone of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT, ERROR_SERVER
Remarks
does not calculate the case !
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=createCase;jcd=...

◆ createCase() [2/3]

Libpf::User::Handle Libpf::User::createCase ( const std::string &  type,
const std::string &  tag,
const std::string &  description,
const std::map< std::string, std::string > &  stringOptions,
const std::map< std::string, int > &  integerOptions,
int &  error 
)

creates a new case instance

std::map<std::string, std::string> stringOptions;
std::map<std::string, int> integerOptions;
std::map<std::string, double> quantities;
int error(0);
Libpf::User::Handle caseHandle = kernel.createCase("jasper","case123","jasper case with 1=2 3 times",stringOptions,integerOptions,quantities,error);
Libpf::User::Case myCase(caseHandle);
Returns
a valid, persistent Case handle on success, or an invalid Handle if there was an error the returned Handle can be used as part of the URN for the case, within the case: namespace
Parameters
[in]typeunique type identifier, UTF-8 encoded string
[in]tagtag string, UTF-8 encoded string
[in]descriptiondescription string, UTF-8 encoded string
[in]stringOptionsmap of UTF-8 encoded string over UTF-8 encoded string
[in]integerOptionsmap of UTF-8 encoded string over ints
[out]errorone of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT, ERROR_SERVER
Remarks
does not calculate the case !

◆ createCase() [3/3]

Libpf::User::Handle Libpf::User::createCase ( const std::string &  type,
const std::string &  tag,
const std::string &  description,
const std::string &  jcd,
int &  error 
)

creates a new case instance

Libpf::User::Handle caseHandle = kernel.createCase("jasper","case123","jasper case with 1=2 3 times","{stringOptions:[{a:b},{c:d},{e:f}],integerOptions:[{g:1},{h:2}]}", error);
Libpf::User::Case myCase(caseHandle);
Returns
a valid, persistent Case handle on success, or an invalid Handle if there was an error the returned Handle can be used as part of the URN for the case, within the case: namespace
Parameters
[in]typeunique type identifier, UTF-8 encoded string
[in]tagtag string, UTF-8 encoded string
[in]descriptiondescription string, UTF-8 encoded string
[in]jcdUTF-8 encoded, JSON-serialized CaseDescriptor object containing only stringOptions and integerOptions fields
[out]errorone of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT, ERROR_SERVER
Remarks
does not calculate the case !
this variant also dumps all model objects as tiny SVGs

◆ defaultType()

const std::string & Libpf::User::defaultType ( void  )

query the default type

Returns
the default type

◆ description()

const std::string & Libpf::User::description ( void  )
Returns
the kernel description as an UTF-8 encoded string

◆ duplicate()

Libpf::User::Handle Libpf::User::duplicate ( Libpf::User::Handle  handle,
const std::string &  tag,
const std::string &  description,
int &  error 
)

duplicate an existing case instance

Parameters
[in]handlethe existing case handle
[in]tagtag string for the new Case instance, UTF-8 encoded string
[in]descriptiondescription string for the new Case instance, UTF-8 encoded string
[out]errorone of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT, ERROR_SERVER
Returns
the new case instance handle, or an invalid Handle in case of error
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;handle=1234567-aaaaa-cccc;method=duplicate

◆ enumerator()

const Libpf::Core::Enumerator * Libpf::User::enumerator ( const std::string &  name,
int &  error 
)

queries a specific enumerator

Returns
a pointer to data structure representing the specified enumerator, or the nullptr if there was an error
Parameters
[in]namethe name of the Enumerator
[out]errorone of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT

◆ errorMessage()

std::string Libpf::User::errorMessage ( int  error)
Parameters
errorone of the values of the ErrorCode enum
Returns
the textual representation of the error

◆ initializeKernel()

void Libpf::User::initializeKernel ( void  )

initializes the library and the kernel, executes only once discarding subsequent calls in detail:

  • sets verbosityGlobal to 2
  • initializes several internal LIBPF global data structures
  • fills in the component list
  • registers the kernel as a product
  • registers the kernel-supplied enumerators and types
  • prints the startup banner
    Remarks
    should be implemented in the driver

◆ jsonListEnumerators()

std::string Libpf::User::jsonListEnumerators ( int &  error)
Returns
UTF-8 encoded string with the JSON-serialized list of Enumerator objects, or an empty JSON object if there was a problem

◆ jsonListTypes()

std::string Libpf::User::jsonListTypes ( int &  error)

queries the available types

Parameters
[out]errorone of ERROR_OK, ERROR_COMMUNICATION
{
"types": [
{
"name": "chiller",
"description": "packaged chiller unit",
"category": "flowsheet",
"instantiable": true,
"integerOptions": [
{
"name": "stages",
"value": 2,
"min": 1,
"max": 10
}
],
"stringOptions": [
{
"name": "type",
"value": "scroll",
"enumerator": "compressorType"
}
]
}
]
}
Returns
UTF-8 encoded string with the JSON-serialized list of TypeDescriptor objects, or an empty JSON object if there was a problem
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=listTypes

◆ jsonTypeDescriptor()

std::string Libpf::User::jsonTypeDescriptor ( std::string  name,
int &  error 
)

queries a specific type

Parameters
[in]namethe name of the type to query
[out]errorone of ERROR_OK, ERROR_COMMUNICATION
{
"name": "chiller",
"description": "packaged chiller unit",
"category": "flowsheet",
"instantiable": true,
"integerOptions": [
{
"name": "stages",
"value": 2,
"min": 1,
"max": 10
}
],
"stringOptions": [
{
"name": "type",
"value": "scroll",
"enumerator": "compressorType"
}
]
}
Returns
UTF-8 encoded string with the JSON-serialized TypeDescriptor object, or an empty JSON object if there was a problem
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=listTypes

◆ license()

const std::string & Libpf::User::license ( void  )
Returns
the kernel license as an UTF-8 encoded string

◆ listEnumerators()

const std::vector< Libpf::Core::Enumerator > & Libpf::User::listEnumerators ( int &  error)

queries the available enumerators

Parameters
[out]errorone of ERROR_OK, ERROR_COMMUNICATION
Returns
a data structure representing the enumerators

◆ listTypes()

const std::vector< Libpf::Persistency::TypeDescriptor > & Libpf::User::listTypes ( int &  error)

queries the available types

Parameters
[out]errorone of ERROR_OK, ERROR_COMMUNICATION
Returns
a data structure representing the type hierarchy
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=listTypes

◆ main()

int Libpf::User::main ( int  argc,
char *  argv[] 
)

Implements the LIBPF Model User API.

Parameters
[in]argcnumber of arguments passed to the program from the Operating System
[in]argvPointer to the first element of an array of pointers to the arguments passed to the program by the Operating System
Returns
exit status that can be returned to the Operating System

◆ name()

const std::string & Libpf::User::name ( void  )
Returns
the kernel name as an UTF-8 encoded string

◆ purge()

int Libpf::User::purge ( void  )

remove all existing case instances

Returns
one of ERROR_OK, ERROR_COMMUNICATION, ERROR_SERVER
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=purge

◆ remove()

int Libpf::User::remove ( Libpf::User::Handle  handle)

remove an existing case instance

Parameters
[in]handlethe case handle
Returns
one of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT, ERROR_SERVER
Remarks
RESTful API: http://cloud.libpf.com/case?handle=1234567-aaaaa-cccc;method=remove

◆ setLocale()

int Libpf::User::setLocale ( const std::string &  locale)

sets the locale for internationalization; the default value is en

Parameters
localea two-character, UTF-8 encoded string with the ISO 639-1:2002 two-letter language code
Returns
one of ERROR_OK, ERROR_COMMUNICATION, ERROR_ARGUMENT, ERROR_SERVER
See also
http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=setLocale;locale=en

◆ setVerbosityGlobal()

void Libpf::User::setVerbosityGlobal ( int  verbosity)
Parameters
verbosityglobal verbosity level
  • 0 for high-priority messages
  • 1 for informational messages
  • 2 for function and member function entry/exit
  • 3 for detailed diagnostic

◆ supportedLocales()

const std::vector< std::string > & Libpf::User::supportedLocales ( int &  error)

query the locales supported by the server side derived classes can re-implement this method to override the default list provided by the library

Parameters
[out]errorone of ERROR_OK, ERROR_COMMUNICATION
Returns
the supported locales; at least one locale must be supported: en;
Remarks
RESTful API: http://cloud.libpf.com/kernel?name=sale_pepe;method=supportedLocales

◆ typeDescriptor()

const Libpf::Persistency::TypeDescriptor * Libpf::User::typeDescriptor ( std::string  name,
int &  error 
)
Returns
a pointer to the type descriptor associated with type name, or the nullptr if there was an error
Parameters
namethe type unique identifier
[out]errorone of ERROR_OK, ERROR_COMMUNICATION

◆ uninitializeKernel()

void Libpf::User::uninitializeKernel ( void  )
Remarks
should be implemented in the driver

◆ uuid()

const std::string & Libpf::User::uuid ( void  )
Returns
the UUID (Universally Unique Identifier) that uniquely identifies a specific service + service version

based on UUID Version 4 as defined by RFC 4122 in its canonical form represented with a 36-character string containing 32 lowercase hexadecimal digits displayed in five groups separated by hyphens, in the form 8-4-4-4-12

◆ version()

const std::string & Libpf::User::version ( void  )
Returns
the kernel version as an UTF-8 encoded string