GEOS
Public Types | Public Member Functions | Static Public Member Functions | List of all members
geos::dataRepository::CatalogInterface< BASETYPE, ARGS > Class Template Referenceabstract

This class provides the base class/interface for the catalog value objects. More...

#include <ObjectCatalog.hpp>

Public Types

typedef std::unordered_map< std::string, std::unique_ptr< CatalogInterface< BASETYPE, ARGS... > > > CatalogType
 This is the type that will be used for the catalog. The catalog is actually instantiated in the BASETYPE.
 

Public Member Functions

 CatalogInterface ()
 Default constructor.
 
virtual ~CatalogInterface ()
 Default destructor.
 
 CatalogInterface (CatalogInterface const &)=default
 Copy constructor.
 
 CatalogInterface (CatalogInterface &&)=default
 Move constructor.
 
CatalogInterfaceoperator= (CatalogInterface const &)=default
 Copy assignment operator. More...
 
CatalogInterfaceoperator= (CatalogInterface &&)=default
 Move assignment operator. More...
 
virtual std::unique_ptr< BASETYPE > allocate (ARGS... args) const =0
 Create a new object that derives from BASETYPE. More...
 

Static Public Member Functions

static CatalogTypegetCatalog ()
 Get the catalog from that is stored in the target base class. More...
 
static bool hasKeyName (std::string const &objectTypeName)
 Check if catalog contains a given key. More...
 
static std::list< typename CatalogType::key_type > getKeys ()
 Returns the product keys of the catalog. Keys are sorted in alphabetical order, case insensitive. More...
 
static std::unique_ptr< BASETYPE > factory (std::string const &objectTypeName, DataContext const &context, ARGS... args)
 Static method to create a new object that derives from BASETYPE. More...
 
template<typename KEYS_CONTAINER_T >
static string unknownTypeError (string const &objectTypeName, DataContext const &context, KEYS_CONTAINER_T const &allowedKeys)
 
template<typename TYPE >
static TYPE & catalogCast (BASETYPE &object)
 Downcast base type reference to derived type. More...
 

Detailed Description

template<typename BASETYPE, typename ... ARGS>
class geos::dataRepository::CatalogInterface< BASETYPE, ARGS >

This class provides the base class/interface for the catalog value objects.

Template Parameters
BASETYPEbase class of the objects that the factory produces
ARGSvariadic template pack to hold the parameters needed for the constructor of the BASETYPE

Definition at line 68 of file ObjectCatalog.hpp.

Member Function Documentation

◆ allocate()

template<typename BASETYPE , typename ... ARGS>
virtual std::unique_ptr< BASETYPE > geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::allocate ( ARGS...  args) const
pure virtual

Create a new object that derives from BASETYPE.

Parameters
argsarguments to the constructor of the target type
Returns
a unique_ptr<BASETYPE> to the newly allocated class.

◆ catalogCast()

template<typename BASETYPE , typename ... ARGS>
template<typename TYPE >
static TYPE& geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::catalogCast ( BASETYPE &  object)
inlinestatic

Downcast base type reference to derived type.

Template Parameters
TYPEtype to cast to
Parameters
objectbase type reference to object
Returns
reference to the same object, cast to derived type

If OBJECTCATALOGVERBOSE is enabled, will check that runtime name of the object is the same as catalog name of the derived type. Therefore may fail for objects that have been assigned a different name (e.g. through XML "name" attribute).

Definition at line 228 of file ObjectCatalog.hpp.

◆ factory()

template<typename BASETYPE , typename ... ARGS>
static std::unique_ptr< BASETYPE > geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::factory ( std::string const &  objectTypeName,
DataContext const &  context,
ARGS...  args 
)
inlinestatic

Static method to create a new object that derives from BASETYPE.

Parameters
[in]objectTypeNamethe key to the catalog entry that is able to create the correct type.
contextThe data context of the Group for which we attempt to create a sub-group.
argsthese are the arguments to the constructor of the target type
Returns
passes a unique_ptr<BASETYPE> to the newly allocated class.
Note
Generate a fatal error:
  • if the object type to create is not found in this Catalog,
  • if the builder is not found.

Definition at line 183 of file ObjectCatalog.hpp.

◆ getCatalog()

template<typename BASETYPE , typename ... ARGS>
static CatalogType& geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::getCatalog ( )
inlinestatic

Get the catalog from that is stored in the target base class.

Returns
returns the catalog for this

Definition at line 124 of file ObjectCatalog.hpp.

◆ getKeys()

template<typename BASETYPE , typename ... ARGS>
static std::list< typename CatalogType::key_type > geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::getKeys ( )
inlinestatic

Returns the product keys of the catalog. Keys are sorted in alphabetical order, case insensitive.

Returns
An STL container.

Definition at line 155 of file ObjectCatalog.hpp.

◆ hasKeyName()

template<typename BASETYPE , typename ... ARGS>
static bool geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::hasKeyName ( std::string const &  objectTypeName)
inlinestatic

Check if catalog contains a given key.

Parameters
objectTypeNamename of the type tp look up
Returns
true if type has been registered with this catalog, false otherwise

Definition at line 146 of file ObjectCatalog.hpp.

◆ operator=() [1/2]

template<typename BASETYPE , typename ... ARGS>
CatalogInterface& geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::operator= ( CatalogInterface< BASETYPE, ARGS > &&  )
default

Move assignment operator.

Returns
reference to this object

◆ operator=() [2/2]

template<typename BASETYPE , typename ... ARGS>
CatalogInterface& geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::operator= ( CatalogInterface< BASETYPE, ARGS > const &  )
default

Copy assignment operator.

Returns
reference to this object

◆ unknownTypeError()

template<typename BASETYPE , typename ... ARGS>
template<typename KEYS_CONTAINER_T >
static string geos::dataRepository::CatalogInterface< BASETYPE, ARGS >::unknownTypeError ( string const &  objectTypeName,
DataContext const &  context,
KEYS_CONTAINER_T const &  allowedKeys 
)
inlinestatic
Returns
Generates a formatted error message for an unknown type for a catalog.
Parameters
objectTypeNameThe name of the object type that is invalid.
contextThe data context of the Group for which the erroneous type creation was attempted.
allowedKeysA container of allowed keys, which will be listed in the error message.
Template Parameters
KEYS_CONTAINER_TA container type holding the allowed keys.

Definition at line 208 of file ObjectCatalog.hpp.


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