g2o
Loading...
Searching...
No Matches
g2o::Factory Class Reference

create vertices and edges based on TAGs in, for example, a file More...

#include <factory.h>

Classes

class  CreatorInformation

Public Member Functions

 Factory (Factory const &)=delete
Factory & operator= (Factory const &)=delete
void registerType (const std::string &tag, const std::shared_ptr< AbstractHyperGraphElementCreator > &c)
void unregisterType (const std::string &tag)
HyperGraph::HyperGraphElement * construct (const std::string &tag) const
HyperGraph::HyperGraphElement * construct (const std::string &tag, const HyperGraph::GraphElemBitset &elemsToConstruct) const
bool knowsTag (const std::string &tag, int *elementType=0) const
const std::string & tag (const HyperGraph::HyperGraphElement *v) const
 return the TAG given a vertex
void fillKnownTypes (std::vector< std::string > &types) const
void printRegisteredTypes (std::ostream &os, bool comment=false) const

Static Public Member Functions

static Factory * instance ()
 return the instance
static void destroy ()
 free the instance

Protected Types

typedef std::map< std::string, std::unique_ptr< CreatorInformation > > CreatorMap
typedef std::map< std::string, std::string > TagLookup

Protected Member Functions

 Factory ()=default

Protected Attributes

CreatorMap _creator
 look-up map for the existing creators
TagLookup _tagLookup
 reverse look-up, class name to tag

Static Private Attributes

static std::unique_ptr< Factory > factoryInstance

Detailed Description

create vertices and edges based on TAGs in, for example, a file

Definition at line 48 of file factory.h.

Member Typedef Documentation

◆ CreatorMap

typedef std::map<std::string, std::unique_ptr<CreatorInformation> > g2o::Factory::CreatorMap
protected

Definition at line 109 of file factory.h.

◆ TagLookup

typedef std::map<std::string, std::string> g2o::Factory::TagLookup
protected

Definition at line 110 of file factory.h.

Constructor & Destructor Documentation

◆ Factory() [1/2]

g2o::Factory::Factory ( Factory const & )
delete

References Factory().

Referenced by Factory(), instance(), and operator=().

◆ Factory() [2/2]

g2o::Factory::Factory ( )
protecteddefault

Member Function Documentation

◆ construct() [1/2]

HyperGraph::HyperGraphElement * g2o::Factory::construct ( const std::string & tag) const

construct a graph element based on its tag

Definition at line 129 of file factory.cpp.

References _creator, and tag().

Referenced by construct(), g2o::CacheContainer::createCache(), g2o::EdgeCreator::createEdge(), operator=(), and g2o::ParameterContainer::read().

◆ construct() [2/2]

HyperGraph::HyperGraphElement * g2o::Factory::construct ( const std::string & tag,
const HyperGraph::GraphElemBitset & elemsToConstruct ) const

construct a graph element based on its tag, but only if it's type (a bitmask) matches. A bitmask without any bit set will construct any item. Otherwise a bit has to be set to allow construction of a graph element.

Definition at line 177 of file factory.cpp.

References _creator, construct(), and tag().

◆ destroy()

void g2o::Factory::destroy ( )
static

free the instance

Definition at line 162 of file factory.cpp.

References factoryInstance.

Referenced by operator=().

◆ fillKnownTypes()

void g2o::Factory::fillKnownTypes ( std::vector< std::string > & types) const

get a list of all known types

Definition at line 145 of file factory.cpp.

References _creator.

Referenced by operator=().

◆ instance()

◆ knowsTag()

bool g2o::Factory::knowsTag ( const std::string & tag,
int * elementType = 0 ) const

return whether the factory knows this tag or not

Definition at line 152 of file factory.cpp.

References _creator, and tag().

Referenced by operator=(), and g2o::OptimizableGraph::setRenamedTypesFromString().

◆ operator=()

◆ printRegisteredTypes()

void g2o::Factory::printRegisteredTypes ( std::ostream & os,
bool comment = false ) const

print a list of the known registered types to the given stream

Definition at line 167 of file factory.cpp.

References _creator.

Referenced by main(), and operator=().

◆ registerType()

void g2o::Factory::registerType ( const std::string & tag,
const std::shared_ptr< AbstractHyperGraphElementCreator > & c )

◆ tag()

◆ unregisterType()

void g2o::Factory::unregisterType ( const std::string & tag)

unregister a tag for a specific creator

Definition at line 113 of file factory.cpp.

References _creator, _tagLookup, and tag().

Referenced by operator=().

Member Data Documentation

◆ _creator

CreatorMap g2o::Factory::_creator
protected

look-up map for the existing creators

Definition at line 113 of file factory.h.

Referenced by construct(), construct(), fillKnownTypes(), knowsTag(), printRegisteredTypes(), registerType(), and unregisterType().

◆ _tagLookup

TagLookup g2o::Factory::_tagLookup
protected

reverse look-up, class name to tag

Definition at line 114 of file factory.h.

Referenced by registerType(), tag(), and unregisterType().

◆ factoryInstance

std::unique_ptr< Factory > g2o::Factory::factoryInstance
staticprivate

Definition at line 117 of file factory.h.

Referenced by destroy(), and instance().


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