Node factory. More...

#include <NodeFactory.h>

Public Member Functions

template<typename C >
void registerType (std::string type, std::string description, std::string category, bool instantiatable, const std::vector< Libpf::User::IntegerOption > &integerOptions={}, const std::vector< Libpf::User::StringOption > &stringOptions={}, std::string icon="", double width=100.0, double heigth=100.0)
 
void registerAlias (std::string baseType, std::string type, std::string description, Libpf::User::Defaults defaults, std::string icon="", double width=100.0, double heigth=100.0)
 
Nodecreate (std::string type, Libpf::User::Defaults defaults=Libpf::User::Defaults(), uint32_t id=0, Persistency *persistency=nullptr, Persistent *parent=nullptr, Persistent *root=nullptr)
 
int size (void)
 Returns the number of registrered objects of the NodeFactory. More...
 
void dump (void) const
 write to std::cout the list of supported types More...
 
const Libpf::User::TypeDescriptortypeDescriptor (std::string name) const
 
void clear (void)
 remove any user-defined type (but the builtin types will stay) More...
 
const Iconicon (std::string type) const
 

Protected Types

typedef Node *(* F )(Libpf::User::Defaults defaults, uint32_t, Persistency *persistency, Persistent *, Persistent *)
 F is a function pointer to a function that calls the main constructor: create a new node. More...
 
typedef std::map< std::string, FMap
 internal data structure to keep the association between the unique identifiers and the function pointers More...
 

Static Protected Attributes

static Mapcreators_
 
static std::vector
< Libpf::User::TypeDescriptor > * 
types_
 internal data structure to keep the list of supported types More...
 
static std::map< std::string,
Libpf::User::Defaults > * 
defaults_
 internal data structure to keep the defaults for aliases More...
 
static int * builtin_
 the count of builtin types More...
 
static std::map< std::string,
Icon > * 
icons_
 a register for Icons More...
 

Friends

class NodeFactoryInitializer
 
const std::vector
< Libpf::User::TypeDescriptor > & 
Libpf::User::listTypes (int &error)
 
bool initializeLibpf (void)
 

Detailed Description

Node factory.

See also
Registrar.h

#include <libpf/persistency/NodeFactory.h>

Member Typedef Documentation

typedef Node*(* NodeFactory::F)(Libpf::User::Defaults defaults, uint32_t, Persistency *persistency, Persistent *, Persistent *)
protected

F is a function pointer to a function that calls the main constructor: create a new node.

typedef std::map<std::string, F> NodeFactory::Map
protected

internal data structure to keep the association between the unique identifiers and the function pointers

Member Function Documentation

void NodeFactory::clear ( void  )

remove any user-defined type (but the builtin types will stay)

Node* NodeFactory::create ( std::string  type,
Libpf::User::Defaults  defaults = Libpf::User::Defaults(),
uint32_t  id = 0,
Persistency persistency = nullptr,
Persistent parent = nullptr,
Persistent root = nullptr 
)

Creates a new object of type and returns a pointer to it; if persistency is non-null, restores from persistency database; if persistency is null, creates a brand new object with the supplied defaults and id

Parameters
typetype unique identifier
defaultsdefault informations to build and configure the Node and its descendants
idinteger identifier in the database; defaults to 0
persistencydatabase connection; defaults to nullptr
parentpointer to the parent Node; set to nullptr if Node is self-standing or the root Node in a tree; defaults to nullptr
rootpointer to the root Node; set to nullptr if Node is self-standing or the root Node in a tree; defaults to nullptr
void NodeFactory::dump ( void  ) const

write to std::cout the list of supported types

const Icon& NodeFactory::icon ( std::string  type) const
Returns
the default icon for the supplied type
Parameters
typetype unique identifier
void NodeFactory::registerAlias ( std::string  baseType,
std::string  type,
std::string  description,
Libpf::User::Defaults  defaults,
std::string  icon = "",
double  width = 100.0,
double  heigth = 100.0 
)

Registers an alias with its unique id and a set of default options

Parameters
baseTypethe base type of the alias
typeunique type id of the alias
descriptionUTF-8 encoded string
iconUTF-8 encoded string with the icon name, without extension
widththe width in px of the icon; the default is 80.0
heigththe heigth in px of the SVG icon; the default is 80.0
defaultsthe default options of the alias
template<typename C >
void NodeFactory::registerType ( std::string  type,
std::string  description,
std::string  category,
bool  instantiatable,
const std::vector< Libpf::User::IntegerOption > &  integerOptions = { },
const std::vector< Libpf::User::StringOption > &  stringOptions = { },
std::string  icon = "",
double  width = 100.0,
double  heigth = 100.0 
)

Registers a C object with its unique id

Parameters
typeunique type id
descriptionUTF-8 encoded string
categoryone of: phase, stream, unit, flowsheet or option
iconUTF-8 encoded string with the icon name, without extension
widththe width in px of the icon; the default is 80.0
heigththe heigth in px of the SVG icon; the default is 80.0
instantiatabletrue if type is instantiable
integerOptionssupported integer options
stringOptionssupported string options
int NodeFactory::size ( void  )
inline

Returns the number of registrered objects of the NodeFactory.

const Libpf::User::TypeDescriptor& NodeFactory::typeDescriptor ( std::string  name) const

Friends And Related Function Documentation

bool initializeLibpf ( void  )
friend

initialize library, executes only once discarding subsequent calls in detail:

  • sets verbosityGlobal to 2
  • calls rollContext
  • prints the startup banner
  • sets strict_ro to true
    Returns
    true if the library has actually been initialized
const std::vector<Libpf::User::TypeDescriptor>& Libpf::User::listTypes ( int &  error)
friend
friend class NodeFactoryInitializer
friend

Member Data Documentation

int* NodeFactory::builtin_
staticprotected

the count of builtin types

Map* NodeFactory::creators_
staticprotected
std::map<std::string, Libpf::User::Defaults>* NodeFactory::defaults_
staticprotected

internal data structure to keep the defaults for aliases

std::map<std::string, Icon>* NodeFactory::icons_
staticprotected

a register for Icons

std::vector<Libpf::User::TypeDescriptor>* NodeFactory::types_
staticprotected

internal data structure to keep the list of supported types


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