HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PDGT_TypeRegistry< EnumType, EnumSize > Class Template Reference

#include <PDGT_TypeRegistry.h>

+ Inheritance diagram for PDGT_TypeRegistry< EnumType, EnumSize >:

Public Types

using Self = PDGT_TypeRegistry< EnumType, EnumSize >
 Self type def. More...
 

Public Member Functions

virtual ~PDGT_TypeRegistry ()
 
bool standardInit (UT_WorkBuffer &errors, bool skip_python=false)
 
void clear ()
 Clears and deletes everything in the type registry. More...
 
void setRegistrationEnabled (bool enabled)
 Enables or disables custom type registration. More...
 
template<typename RegType , typename... Args>
RegType * registerType (UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
 
template<typename RegType , typename... Args>
RegType * registerFuncType (UT_WorkBuffer &errors, const UT_StringHolder &name, typename RegType::Function func, Args &&...args)
 
template<typename RegType , typename ClassType , typename... Args>
RegType * registerSimpleType (UT_WorkBuffer &errors, const UT_StringHolder &name, Args &&...args)
 
bool registerTypeAlias (EnumType type, const UT_StringHolder &name, const UT_StringHolder &alias, bool deprecated=false)
 Registers an alias for an existing type. More...
 
bool addParentTypes (BaseType *type, const UT_StringArray &parent_names, UT_WorkBuffer &errors)
 Adds parent types to the type object. More...
 
bool addParentType (BaseType *type, BaseType *parent, UT_WorkBuffer &errors)
 Directly adds a parent type, if it's valid. More...
 
bool registerDSOTypes (const UT_StringHolder &dso_path)
 Loads and registers types compiled as a shared library. More...
 
bool registerDSOTypes ()
 
bool registerPythonModules (UT_WorkBuffer &errors)
 Registers all Python types on the PDG/types search path. More...
 
bool registerPythonPath (const UT_StringHolder &path, UT_WorkBuffer &errors)
 Registers a Python module by absolute path. More...
 
bool reloadPythonModule (const UT_StringHolder &path, bool reregister, UT_WorkBuffer &errors)
 Reloads a Python module by name. More...
 
BaseTyperegisteredType (EnumType type, const UT_StringHolder &name) const
 Returns a generic type object for a given registered type and typename. More...
 
void deprecateType (EnumType type, const UT_StringHolder &name)
 Deprecated a type name, so that accessing it will issue an warning. More...
 
UT_StringArray typeNames (EnumType type, bool include_aliases=false) const
 Returns the set of all existing type names for registered type. More...
 

Protected Types

using BaseType = PDGT_BaseType< EnumType >
 PDGT_BaseType spiicalization for this type registry. More...
 
using pdg_BaseTypePtr = UT_SharedPtr< BaseType >
 Shared ptr to a registered PDG type. More...
 
using TypeMap = UT_StringMap< pdg_BaseTypePtr >
 Map of type name to shared ptr. More...
 

Protected Member Functions

 PDGT_TypeRegistry (const UT_StringHolder &dso_function, const UT_StringHolder &module_name)
 

Detailed Description

template<typename EnumType, int EnumSize>
class PDGT_TypeRegistry< EnumType, EnumSize >

Base class for a PDGT type system, which consists of a table of EnumType -> PDGT_Registered type. The number of entries in the table is defined by the number of distinct entries in the EnumType enumeration.

The type registry is the central place that holds the registered type objects, as well as logic needed to load them from shared libraries or Python definitions.

Definition at line 37 of file PDGT_TypeRegistry.h.

Member Typedef Documentation

template<typename EnumType, int EnumSize>
using PDGT_TypeRegistry< EnumType, EnumSize >::BaseType = PDGT_BaseType<EnumType>
protected

PDGT_BaseType spiicalization for this type registry.

Definition at line 45 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
using PDGT_TypeRegistry< EnumType, EnumSize >::pdg_BaseTypePtr = UT_SharedPtr<BaseType>
protected

Shared ptr to a registered PDG type.

Definition at line 48 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
using PDGT_TypeRegistry< EnumType, EnumSize >::Self = PDGT_TypeRegistry<EnumType, EnumSize>

Self type def.

Definition at line 41 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
using PDGT_TypeRegistry< EnumType, EnumSize >::TypeMap = UT_StringMap<pdg_BaseTypePtr>
protected

Map of type name to shared ptr.

Definition at line 51 of file PDGT_TypeRegistry.h.

Constructor & Destructor Documentation

template<typename EnumType, int EnumSize>
PDGT_TypeRegistry< EnumType, EnumSize >::PDGT_TypeRegistry ( const UT_StringHolder dso_function,
const UT_StringHolder module_name 
)
inlineprotected

Construct is protected since only this class and subclasses can create instances of itself.

Definition at line 57 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
virtual PDGT_TypeRegistry< EnumType, EnumSize >::~PDGT_TypeRegistry ( )
inlinevirtual

Definition at line 67 of file PDGT_TypeRegistry.h.

Member Function Documentation

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::addParentType ( BaseType type,
BaseType parent,
UT_WorkBuffer errors 
)
inline

Directly adds a parent type, if it's valid.

Definition at line 241 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::addParentTypes ( BaseType type,
const UT_StringArray parent_names,
UT_WorkBuffer errors 
)
inline

Adds parent types to the type object.

Definition at line 217 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
void PDGT_TypeRegistry< EnumType, EnumSize >::clear ( void  )
inline

Clears and deletes everything in the type registry.

Definition at line 91 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
void PDGT_TypeRegistry< EnumType, EnumSize >::deprecateType ( EnumType  type,
const UT_StringHolder name 
)
inline

Deprecated a type name, so that accessing it will issue an warning.

Definition at line 325 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::registerDSOTypes ( const UT_StringHolder dso_path)
inline

Loads and registers types compiled as a shared library.

Definition at line 267 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::registerDSOTypes ( )
inline

Loads and registers types that are in DSOs on the PDG shared library path, e.g. <dso_path>/pdg

Definition at line 275 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
BaseType* PDGT_TypeRegistry< EnumType, EnumSize >::registeredType ( EnumType  type,
const UT_StringHolder name 
) const
inline

Returns a generic type object for a given registered type and typename.

Definition at line 306 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
template<typename RegType , typename... Args>
RegType* PDGT_TypeRegistry< EnumType, EnumSize >::registerFuncType ( UT_WorkBuffer errors,
const UT_StringHolder name,
typename RegType::Function  func,
Args &&...  args 
)
inline

Registers a type that implements it's construction logic in a function, rather than a custom class

Definition at line 155 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::registerPythonModules ( UT_WorkBuffer errors)
inline

Registers all Python types on the PDG/types search path.

Definition at line 282 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::registerPythonPath ( const UT_StringHolder path,
UT_WorkBuffer errors 
)
inline

Registers a Python module by absolute path.

Definition at line 289 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
template<typename RegType , typename ClassType , typename... Args>
RegType* PDGT_TypeRegistry< EnumType, EnumSize >::registerSimpleType ( UT_WorkBuffer errors,
const UT_StringHolder name,
Args &&...  args 
)
inline

Registers a type that uses the simple built-in function, which creates and instance of the type using it's constructor and does no additional logic

Definition at line 174 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
template<typename RegType , typename... Args>
RegType* PDGT_TypeRegistry< EnumType, EnumSize >::registerType ( UT_WorkBuffer errors,
const UT_StringHolder name,
Args &&...  args 
)
inline

Registers a type using a pointer to the type object. Errors are returned in the error buffer parameter

Definition at line 106 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::registerTypeAlias ( EnumType  type,
const UT_StringHolder name,
const UT_StringHolder alias,
bool  deprecated = false 
)
inline

Registers an alias for an existing type.

Definition at line 186 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::reloadPythonModule ( const UT_StringHolder path,
bool  reregister,
UT_WorkBuffer errors 
)
inline

Reloads a Python module by name.

Definition at line 297 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
void PDGT_TypeRegistry< EnumType, EnumSize >::setRegistrationEnabled ( bool  enabled)
inline

Enables or disables custom type registration.

Definition at line 98 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
bool PDGT_TypeRegistry< EnumType, EnumSize >::standardInit ( UT_WorkBuffer errors,
bool  skip_python = false 
)
inline

Standard initialization of the types, which loads built in Python modules first, then user defined Python types, then C++ types. The reason for this being a method and not part of construction is there certain use cases that want to have an empty type table, for example unit testing or users with entirely custom nodes.

Definition at line 74 of file PDGT_TypeRegistry.h.

template<typename EnumType, int EnumSize>
UT_StringArray PDGT_TypeRegistry< EnumType, EnumSize >::typeNames ( EnumType  type,
bool  include_aliases = false 
) const
inline

Returns the set of all existing type names for registered type.

Definition at line 331 of file PDGT_TypeRegistry.h.


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