![]() |
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 | |
| Circuit ()=default | |
| Circuit (const Circuit &)=default | |
| Circuit (Circuit &&)=default | |
| Circuit & | operator= (const Circuit &)=default |
| Circuit & | operator= (Circuit &&)=default |
| 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. | |
| gate_t | getGate (const gate_uuid &u) |
Return (or create) the gate associated with UUID u. | |
| std::pair< gate_t, bool > | findOrAddGate (const gate_uuid &u) |
Return (or create) the gate associated with UUID u, and whether it was created. | |
| uuid | getUUID (gate_t g) const |
Return the UUID string associated with gate g. | |
| bool | getUUID (gate_t g, gate_uuid &u) const |
Read the UUID of gate g into u. | |
| 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. | |
| bool | hasGate (const gate_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 Types | |
| enum | : unsigned char { NO_NAME , UUID_NAME , OTHER_NAME } |
What a gate is named by, in name_kind. More... | |
Protected Member Functions | |
| unsigned char | nameKind (gate_t g) const |
What gate g is named by. | |
| void | bindName (gate_t g, const gate_uuid &u) |
Name gate g by the UUID u. | |
| void | bindName (gate_t g, const uuid &u) |
Name gate g by u, a UUID in its text form or another string. | |
| void | pointName (gate_t g, gate_t target) |
Make the name of gate g, if any, name gate target. | |
| void | dropName (gate_t g) |
Remove the name of gate g, if any. | |
| void | moveName (gate_t from, gate_t to) |
Give the name of gate from, if any, to gate to. | |
| 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< gate_uuid, gate_t, gate_uuid_hash > | uuid2id |
| UUID → gate index. | |
| std::vector< gate_uuid > | id2uuid |
UUID of each gate (if UUID_NAME). | |
| std::vector< unsigned char > | name_kind |
| What each gate is named by. | |
| std::unordered_map< std::string, gate_t > | name2id |
| Other name → gate index. | |
| std::unordered_map< gate_t, std::string > | id2name |
| Gate index → other name. | |
| 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 |
|
protected |
|
default |



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 168 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 195 of file Circuit.hpp.


|
protected |
Name gate g by the UUID u.
Definition at line 78 of file Circuit.hpp.

Name gate g by u, a UUID in its text form or another string.
Definition at line 93 of file Circuit.hpp.

Remove the name of gate g, if any.
Definition at line 127 of file Circuit.hpp.


| std::pair< gate_t, bool > Circuit< gateType >::findOrAddGate | ( | const gate_uuid & | u | ) |
Return (or create) the gate associated with UUID u, and whether it was created.
Definition at line 39 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 50 of file Circuit.hpp.


Return the UUID string associated with gate g.
| g | Gate identifier. |
g has no UUID. Definition at line 65 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 30 of file Circuit.hpp.


Give the name of gate from, if any, to gate to.
Definition at line 145 of file Circuit.hpp.

|
default |

|
default |

Make the name of gate g, if any, name gate target.
Definition at line 111 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 187 of file Circuit.hpp.


Allocate a new gate with type type and no UUID.
| type | Gate type. |
Definition at line 179 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 |
|
protected |
|
protected |