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.

Note

the operator’s Hermiticity defaults to default_hermiticity(action)

Parameters:
  • op – the operator label

  • action – the class of the operator

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

Adds a new operator to the registry with an explicit Hermiticity.

Parameters:
  • op – the operator label

  • action – the class of the operator

  • hermiticity – the operator’s Hermiticity (overrides the default implied by action)

OpRegistry &set_hermiticity(const std::wstring &op, Hermiticity hermiticity)

Overrides the Hermiticity of an already-registered operator.

Parameters:
  • op – the operator label (must already be registered)

  • hermiticity – the operator’s Hermiticity

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

Hermiticity hermiticity(const std::wstring &op) const

Returns the Hermiticity of the operator with the given label.

Parameters:

op – the operator label

Returns:

the operator’s Hermiticity (the per-operator override if set, else default_hermiticity(to_class(op)))

inline auto ops() const

returns a view of registered operator labels

inline void purge()

clears all registered operators (and their Hermiticity overrides)