Class OpRegistry

Class Documentation

class OpRegistry

A Registry for MBPT Operators.

A registry that keeps track of MBPT operators by their labels and properties.

Copy semantics is shallow (operator map shared via std::shared_ptr), allowing multiple mbpt::Context objects to share operator definitions. Use OpRegistry::clone() for deep copies.

Public Functions

inline OpRegistry()

default constructor, creates an empty registry

inline OpRegistry(std::shared_ptr<container::map<std::wstring, OpClass>> ops)

constructs an OpRegistry from an existing map of operators and their classes

inline OpRegistry(const OpRegistry &other)

copy constructor

inline OpRegistry(OpRegistry &&other) noexcept

move constructor

OpRegistry &operator=(const OpRegistry &other)

copy assignment operator

OpRegistry &operator=(OpRegistry &&other) noexcept

move assignment operator

inline decltype(auto) begin() const

const iterator to beginning of registry

inline decltype(auto) end() const

const iterator to end of registry

OpRegistry clone() const

clones this OpRegistry, creates a copy of ops_

OpRegistry &add(const std::wstring &op, OpClass action)

Adds a new operator to the registry.

Parameters:
  • op – the operator label

  • action – the class of the operator

OpRegistry &remove(const std::wstring &op)

Removes an operator from the registry.

bool contains(const std::wstring &op) const

Checks if the registry contains an operator with the given label.

Parameters:

op – the operator label

Returns:

true if the operator exists, false otherwise

OpClass to_class(const std::wstring &op) const

Returns the class of the operator corresponding to the given label if it exists.

Parameters:

op – the operator label

Returns:

the class of the operator

inline auto ops() const

returns a view of registered operator labels

inline void purge()

clears all registered operators