OpenVDB  9.0.1
Classes | Public Types | Public Member Functions | List of all members
FunctionRegistry Class Reference

The function registry which is used for function code generation. Each time a function is visited within the AST, its identifier is used as a key into this registry for the corresponding function retrieval and execution. Functions can be inserted into the registry using insert() with a given identifier and pointer. More...

#include <openvdb_ax/codegen/FunctionRegistry.h>

Classes

struct  RegisteredFunction
 An object to represent a registered function, storing its constructor, a pointer to the function definition and whether it should only be available internally (i.e. to a developer, not a user) More...
 

Public Types

using ConstructorT = FunctionGroup::UniquePtr(*)(const FunctionOptions &)
 
using Ptr = std::shared_ptr< FunctionRegistry >
 
using UniquePtr = std::unique_ptr< FunctionRegistry >
 
using RegistryMap = std::unordered_map< std::string, RegisteredFunction >
 

Public Member Functions

void insert (const std::string &identifier, const ConstructorT creator, const bool internal=false)
 Insert and register a function object to a function identifier. More...
 
void insertAndCreate (const std::string &identifier, const ConstructorT creator, const FunctionOptions &op, const bool internal=false)
 Insert and register a function object to a function identifier. More...
 
const FunctionGroupgetOrInsert (const std::string &identifier, const FunctionOptions &op, const bool allowInternalAccess)
 Return the corresponding function from a provided function identifier. More...
 
const FunctionGroupget (const std::string &identifier, const bool allowInternalAccess) const
 Return the corresponding function from a provided function identifier. More...
 
void createAll (const FunctionOptions &op, const bool verify=false)
 Force the (re)creations of all function objects for all registered functions. More...
 
const RegistryMapmap () const
 Return a const reference to the current registry map. More...
 
bool empty () const
 Return whether or not the registry is empty. More...
 
void clear ()
 Clear the underlying function registry. More...
 

Detailed Description

The function registry which is used for function code generation. Each time a function is visited within the AST, its identifier is used as a key into this registry for the corresponding function retrieval and execution. Functions can be inserted into the registry using insert() with a given identifier and pointer.

Member Typedef Documentation

using Ptr = std::shared_ptr<FunctionRegistry>
using RegistryMap = std::unordered_map<std::string, RegisteredFunction>
using UniquePtr = std::unique_ptr<FunctionRegistry>

Member Function Documentation

void clear ( )
inline

Clear the underlying function registry.

void createAll ( const FunctionOptions op,
const bool  verify = false 
)

Force the (re)creations of all function objects for all registered functions.

Parameters
opThe current function options
verifyChecks functions are created and have valid identifiers/symbols
bool empty ( ) const
inline

Return whether or not the registry is empty.

const FunctionGroup* get ( const std::string &  identifier,
const bool  allowInternalAccess 
) const

Return the corresponding function from a provided function identifier.

Note
Returns a nullptr if no such function identifier has been registered or if the function is marked as internal
Parameters
identifierThe function identifier
allowInternalAccessWhether to look in the 'internal' functions
const FunctionGroup* getOrInsert ( const std::string &  identifier,
const FunctionOptions op,
const bool  allowInternalAccess 
)

Return the corresponding function from a provided function identifier.

Note
Returns a nullptr if no such function identifier has been registered or if the function is marked as internal
Parameters
identifierThe function identifier
opFunctionOptions to pass the function constructor
allowInternalAccessWhether to look in the 'internal' functions
void insert ( const std::string &  identifier,
const ConstructorT  creator,
const bool  internal = false 
)

Insert and register a function object to a function identifier.

Note
Throws if the identifier is already registered
Parameters
identifierThe function identifier to register
creatorThe function to link to the provided identifier
internalWhether to mark the function as only internally accessible
void insertAndCreate ( const std::string &  identifier,
const ConstructorT  creator,
const FunctionOptions op,
const bool  internal = false 
)

Insert and register a function object to a function identifier.

Note
Throws if the identifier is already registered
Parameters
identifierThe function identifier to register
creatorThe function to link to the provided identifier
opFunctionOptions to pass the function constructor
internalWhether to mark the function as only internally accessible
const RegistryMap& map ( ) const
inline

Return a const reference to the current registry map.