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::Persistency::IntegerOption > &integerOptions={ }, const std::vector< Libpf::Persistency::StringOption > &stringOptions={ }, const std::vector< Libpf::Persistency::QuantityOption > &quantityOptions={ }, std::string icon="", double width=100.0, double heigth=100.0)
 
void registerAlias (std::string baseType, std::string type, std::string description, Libpf::Persistency::Defaults defaults, std::string icon="", double width=100.0, double heigth=100.0)
 
Nodecreate (std::string type, Libpf::Persistency::Defaults defaults=Libpf::Persistency::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::Persistency::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::Persistency::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::Persistency::TypeDescriptor > * types_
 internal data structure to keep the list of supported types More...
 
static std::map< std::string, Libpf::Persistency::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::Persistency::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

◆ F

typedef Node *(* NodeFactory::F) (Libpf::Persistency::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.

◆ Map

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

◆ clear()

void NodeFactory::clear ( void  )

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

◆ create()

Node * NodeFactory::create ( std::string  type,
Libpf::Persistency::Defaults  defaults = Libpf::Persistency::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

◆ dump()

void NodeFactory::dump ( void  ) const

write to std::cout the list of supported types

◆ icon()

const Icon & NodeFactory::icon ( std::string  type) const
Returns
the default icon for the supplied type
Parameters
typetype unique identifier

◆ registerAlias()

void NodeFactory::registerAlias ( std::string  baseType,
std::string  type,
std::string  description,
Libpf::Persistency::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

◆ registerType()

template<typename C >
void NodeFactory::registerType ( std::string  type,
std::string  description,
std::string  category,
bool  instantiatable,
const std::vector< Libpf::Persistency::IntegerOption > &  integerOptions = { },
const std::vector< Libpf::Persistency::StringOption > &  stringOptions = { },
const std::vector< Libpf::Persistency::QuantityOption > &  quantityOptions = { },
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

◆ size()

int NodeFactory::size ( void  )
inline

Returns the number of registrered objects of the NodeFactory.

◆ typeDescriptor()

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

Friends And Related Function Documentation

◆ initializeLibpf

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

◆ Libpf::User::listTypes

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

◆ NodeFactoryInitializer

friend class NodeFactoryInitializer
friend

Member Data Documentation

◆ builtin_

int* NodeFactory::builtin_
staticprotected

the count of builtin types

◆ creators_

Map* NodeFactory::creators_
staticprotected

◆ defaults_

std::map<std::string, Libpf::Persistency::Defaults>* NodeFactory::defaults_
staticprotected

internal data structure to keep the defaults for aliases

◆ icons_

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

a register for Icons

◆ types_

std::vector<Libpf::Persistency::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: