OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ot::GraphicsItemFactory Class Reference

The GraphicsItemFactory is used to create graphics items from their factory name or from a GraphicsItemCfg. More...

#include "GraphicsItemFactory.h"

Inheritance diagram for ot::GraphicsItemFactory:
ot::FactoryTemplate< GraphicsItem >

Static Public Member Functions

static GraphicsItemFactoryinstance (void)
 
static ot::GraphicsItemcreate (const ConstJsonObject &_configObject, bool _isRoot=false)
 Will create the configuration from the provided json object and then create the item using the created configuration.
 
static ot::GraphicsItemitemFromConfig (const ot::GraphicsItemCfg *_config, bool _isRoot=false)
 Creates a graphics item from the provided configuration. The graphics item will be created according to the graphics item cfg name. If the created item is the root item finalizeGraphicsItem() will be called.
 

Additional Inherited Members

- Public Types inherited from ot::FactoryTemplate< GraphicsItem >
typedef std::function< GraphicsItem *()> ConstructorFunctionType
 Constructor type definition.
 
- Public Member Functions inherited from ot::FactoryTemplate< GraphicsItem >
void registerConstructor (const std::string &_key, ConstructorFunctionType _constructor)
 Will register the prvided constructor under the given key. If a constructor for the given key already exists a warning log will be generated and the request will be ignored.
 
void deregisterConstructor (const std::string &_key)
 Remove the constructor for the given key.
 
GraphicsItemcreateFromKey (const std::string &_key)
 Call the constructor for the given key and return the created instance.
 
GraphicsItemcreateFromJSON (const ConstJsonObject &_jsonObject, const char *_typeKey)
 Creates an instance according to the key in the provided JSON object. If the key is empty the request will be ignored. If the created instance inherits from Serializable the setFromJsonObject method will be called.
 
GraphicsItemcreateFromJSON (const ConstJsonObject &_jsonObject, const std::string &_typeKey)
 [/ref ValueType* createFromJSON(const ConstJsonObject& _jsonObject, const char* _typeKey) "x"].
 
- Protected Member Functions inherited from ot::FactoryTemplate< GraphicsItem >
 FactoryTemplate ()
 Protected constructor.
 
 ~FactoryTemplate ()
 Protected destructor.
 

Detailed Description

The GraphicsItemFactory is used to create graphics items from their factory name or from a GraphicsItemCfg.

Note
Note that items that register at this factory must register with the same key as their configuration equivalents.

Member Function Documentation

◆ create()

ot::GraphicsItem * ot::GraphicsItemFactory::create ( const ConstJsonObject & _configObject,
bool _isRoot = false )
static

Will create the configuration from the provided json object and then create the item using the created configuration.

Parameters
_configObjectThe JSON object containing the GraphicsItemCfg.

◆ instance()

ot::GraphicsItemFactory & ot::GraphicsItemFactory::instance ( void )
static

◆ itemFromConfig()

ot::GraphicsItem * ot::GraphicsItemFactory::itemFromConfig ( const ot::GraphicsItemCfg * _config,
bool _isRoot = false )
static

Creates a graphics item from the provided configuration. The graphics item will be created according to the graphics item cfg name. If the created item is the root item finalizeGraphicsItem() will be called.

Parameters
_configThe graphics item configuration.
_isRootIf true, the item will be added to a stack with a highlight item on top. The highlight item will be set to the root item.

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