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 (std::span< const std::shared_ptr< Node > > 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 41 of file ContractRegistry.h.