Loading...
Searching...
No Matches
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.
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.
const FunctionGroup * | getOrInsert (const std::string &identifier, const FunctionOptions &op, const bool allowInternalAccess)
| Return the corresponding function from a provided function identifier.
const FunctionGroup * | get (const std::string &identifier, const bool allowInternalAccess) const
| Return the corresponding function from a provided function identifier.
void | createAll (const FunctionOptions &op, const bool verify=false)
| Force the (re)creations of all function objects for all registered functions.
const RegistryMap & | map () const
| Return a const reference to the current registry map.
bool | empty () const
| Return whether or not the registry is empty.
void | clear ()
| Clear the underlying function registry.

## 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

## ConstructorT

using ConstructorT = FunctionGroup::UniquePtr(*)(const FunctionOptions&)

## Ptr

using Ptr = std::shared_ptr<FunctionRegistry>

## RegistryMap

using RegistryMap = std::unordered_map<std::string, RegisteredFunction>

## UniquePtr

using UniquePtr = std::unique_ptr<FunctionRegistry>

## Member Function Documentation

## clear()

void clear | ( |  | ) |

inline

Clear the underlying function registry.

## createAll()

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

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

Parameters

  op | The current function options
  verify | Checks functions are created and have valid identifiers/symbols

## empty()

bool empty | ( |  | ) | const

inline

Return whether or not the registry is empty.

## get()

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

  identifier | The function identifier
  allowInternalAccess | Whether to look in the 'internal' functions

## getOrInsert()

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

  identifier | The function identifier
  op | FunctionOptions to pass the function constructor
  allowInternalAccess | Whether to look in the 'internal' functions

## insert()

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

  identifier | The function identifier to register
  creator | The function to link to the provided identifier
  internal | Whether to mark the function as only internally accessible

## insertAndCreate()

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

  identifier | The function identifier to register
  creator | The function to link to the provided identifier
  op | FunctionOptions to pass the function constructor
  internal | Whether to mark the function as only internally accessible

## map()

const RegistryMap & map | ( |  | ) | const

inline

Return a const reference to the current registry map.