![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Generic template base class for provenance circuits. More...
#include "Circuit.h"
Public Types | |
| using | uuid = std::string |
UUID type used in this circuit (always std::string). | |
Public Member Functions | |
| virtual | ~Circuit () |
| std::vector< gate_t >::size_type | getNbGates () const |
| Return the total number of gates in the circuit. | |
| gate_t | getGate (const uuid &u) |
Return (or create) the gate associated with UUID u. | |
| uuid | getUUID (gate_t g) const |
Return the UUID string associated with gate g. | |
| gateType | getGateType (gate_t g) const |
Return the type of gate g. | |
| std::vector< gate_t > & | getWires (gate_t g) |
Return a mutable reference to the child-wire list of gate g. | |
| const std::vector< gate_t > & | getWires (gate_t g) const |
Return a const reference to the child-wire list of gate g. | |
| virtual gate_t | setGate (const uuid &u, gateType type) |
Create or update the gate associated with UUID u. | |
| virtual gate_t | setGate (gateType type) |
Allocate a new gate with type type and no UUID. | |
| bool | hasGate (const uuid &u) const |
Test whether a gate with UUID u exists. | |
| void | addWire (gate_t f, gate_t t) |
Add a directed wire from gate f (parent) to gate t (child). | |
| virtual std::string | toString (gate_t g) const =0 |
Return a textual description of gate g for debugging. | |
Protected Member Functions | |
| void | setGateType (gate_t g, gateType t) |
| Update the type of an existing gate. | |
| virtual gate_t | addGate () |
| Allocate a new gate with a default-initialised type. | |
Protected Attributes | |
| std::unordered_map< uuid, gate_t > | uuid2id |
| UUID string → gate index. | |
| std::unordered_map< gate_t, uuid > | id2uuid |
| Gate index → UUID string. | |
| std::vector< gateType > | gates |
| Gate type for each gate. | |
| std::vector< std::vector< gate_t > > | wires |
| Child wire lists for each gate. | |
Generic template base class for provenance circuits.
A Circuit stores:
gate_t.gate_t).gate_t IDs.| gateType | Enumeration of gate kinds for this circuit variant. |
| using Circuit< gateType >::uuid = std::string |
Allocate a new gate with a default-initialised type.
Derived classes override this to perform additional initialisation (e.g. resizing auxiliary vectors).
gate_t identifier of the newly created gate. Reimplemented in BooleanCircuit, DotCircuit, and GenericCircuit.
Definition at line 56 of file Circuit.hpp.

Add a directed wire from gate f (parent) to gate t (child).
| f | Source (parent) gate. |
| t | Target (child) gate. |
Definition at line 81 of file Circuit.hpp.

Return (or create) the gate associated with UUID u.
If no gate with this UUID exists yet a new gate is allocated via addGate() and the UUID mapping is recorded.
| u | UUID string. |
u. Definition at line 33 of file Circuit.hpp.

Return the UUID string associated with gate g.
| g | Gate identifier. |
g has no UUID. Definition at line 46 of file Circuit.hpp.

Test whether a gate with UUID u exists.
| u | UUID string. |
true if a gate with this UUID is present. Definition at line 27 of file Circuit.hpp.

|
virtual |
Create or update the gate associated with UUID u.
If the UUID is already mapped the existing gate's type is updated. Otherwise a new gate is allocated.
| u | UUID string to associate with the gate. |
| type | Gate type. |
Reimplemented in DotCircuit.
Definition at line 73 of file Circuit.hpp.

Allocate a new gate with type type and no UUID.
| type | Gate type. |
Reimplemented in DotCircuit.
Definition at line 65 of file Circuit.hpp.
|
pure virtual |
Return a textual description of gate g for debugging.
Pure virtual; each concrete circuit class provides its own formatting.
| g | Gate to describe. |
Implemented in BooleanCircuit, DotCircuit, GenericCircuit, and WhereCircuit.
|
protected |