ContractRegistry Class
Holds a set of Contracts and runs them to produce a ValidationReport. More...
Declaration
Included Headers
Public Member Typedefs Index
| using | ContractPtr = std::shared_ptr< Contract > |
Public Constructors Index
| ContractRegistry ()=default | |
|
Construct an empty registry. More... | |
Public Member Functions Index
| ContractRegistry & | add (ContractPtr c) |
|
Add or replace a contract (keyed by id()); returns *this for chaining. More... | |
template <class T, class... Args> | |
| ContractRegistry & | emplace (Args &&... args) |
|
Convenience: construct a contract of type T from args and add it. More... | |
| bool | remove (const std::string &id) |
|
Remove a contract by id. Returns true if removed. More... | |
| void | clear () |
|
Drop all contracts; the registry becomes empty. More... | |
| std::size_t | size () const noexcept |
|
Number of contracts currently registered. More... | |
| bool | empty () const noexcept |
|
True if no contracts are registered. More... | |
| ContractPtr | get (const std::string &id) const |
|
Get a contract by id (nullptr if missing). More... | |
| std::vector< std::string > | ids () const |
|
Deterministic list of ids in insertion order. More... | |
| ValidationReport | validate (const NodeGroup &nodes, const ValidationContext &ctx) const |
|
Run all contracts and return a ValidationReport. More... | |
Private Member Attributes Index
| std::unordered_map< std::string, ContractPtr > | by_id_ |
| std::vector< std::string > | order_ |
Description
Holds a set of Contracts and runs them to produce a ValidationReport.
Insertion order is preserved (and used as evaluation order). Adding a contract whose id() matches an existing one replaces the old contract in place. The registry is intentionally small and STL-only.
- See Also
- See Also
- See Also
Validators::DefaultRegistry
Definition at line 40 of file ContractRegistry.h.
Public Member Typedefs
ContractPtr
|
Shared-pointer alias for a Contract.
Definition at line 43 of file ContractRegistry.h.
Public Constructors
ContractRegistry()
| default |
Construct an empty registry.
Definition at line 46 of file ContractRegistry.h.
Public Member Functions
add()
| inline |
Add or replace a contract (keyed by id()); returns *this for chaining.
Definition at line 49 of file ContractRegistry.h.
clear()
| inline |
Drop all contracts; the registry becomes empty.
Definition at line 87 of file ContractRegistry.h.
emplace()
| inline |
Convenience: construct a contract of type T from args and add it.
Definition at line 65 of file ContractRegistry.h.
empty()
| inline noexcept |
True if no contracts are registered.
Definition at line 97 of file ContractRegistry.h.
get()
| inline |
Get a contract by id (nullptr if missing).
Definition at line 102 of file ContractRegistry.h.
ids()
| inline |
Deterministic list of ids in insertion order.
Definition at line 108 of file ContractRegistry.h.
remove()
| inline |
Remove a contract by id. Returns true if removed.
Definition at line 70 of file ContractRegistry.h.
size()
| inline noexcept |
Number of contracts currently registered.
Definition at line 93 of file ContractRegistry.h.
validate()
| inline |
Run all contracts and return a ValidationReport.
Defensive behavior:
- contract violations should be reported (not thrown)
- if a Contract throws, registry converts that into an internal ERROR issue
Definition at line 119 of file ContractRegistry.h.
Private Member Attributes
by_id_
|
Definition at line 155 of file ContractRegistry.h.
order_
|
Definition at line 156 of file ContractRegistry.h.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.