ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
DotCircuit Class Reference

Circuit specialisation for GraphViz DOT rendering. More...

#include "DotCircuit.h"

Inheritance diagram for DotCircuit:
Collaboration diagram for DotCircuit:

Public Member Functions

gate_t addGate () override
 Allocate a new gate with a default-initialised type.
 
gate_t setGate (const uuid &u, DotGate type) override
 Create or update the gate associated with UUID u.
 
gate_t setGate (const uuid &u, DotGate t, std::string d)
 Create (or update) a gate with a UUID, type, and description.
 
std::string render () const
 Render the entire circuit as a GraphViz DOT digraph string.
 
virtual std::string toString (gate_t g) const override
 Return a textual description of gate g for debugging.
 
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.
 
- Public Member Functions inherited from Circuit< DotGate >
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.
 
DotGate 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.
 
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).
 

Private Attributes

std::set< gate_tinputs
 Input gate IDs (rendered as leaf nodes)
 
std::vector< std::string > desc
 Per-gate label strings (indexed by gate ID)
 

Additional Inherited Members

- Public Types inherited from Circuit< DotGate >
using uuid = std::string
 UUID type used in this circuit (always std::string).
 
- Protected Member Functions inherited from Circuit< DotGate >
void setGateType (gate_t g, DotGate t)
 Update the type of an existing gate.
 
- Protected Attributes inherited from Circuit< DotGate >
std::unordered_map< uuid, gate_tuuid2id
 UUID string → gate index.
 
std::unordered_map< gate_t, uuidid2uuid
 Gate index → UUID string.
 
std::vector< DotGategates
 Gate type for each gate.
 
std::vector< std::vector< gate_t > > wires
 Child wire lists for each gate.
 

Detailed Description

Circuit specialisation for GraphViz DOT rendering.

Extends Circuit<DotGate> with per-gate description strings and a render() method that produces a complete DOT digraph.

Definition at line 61 of file DotCircuit.h.

Member Function Documentation

◆ addGate()

gate_t DotCircuit::addGate ( )
overridevirtual

Allocate a new gate with a default-initialised type.

Derived classes override this to perform additional initialisation (e.g. resizing auxiliary vectors).

Returns
The gate_t identifier of the newly created gate.

Reimplemented from Circuit< DotGate >.

Definition at line 46 of file DotCircuit.cpp.

Here is the call graph for this function:

◆ render()

std::string DotCircuit::render ( ) const

Render the entire circuit as a GraphViz DOT digraph string.

The returned string can be written to a file and processed with dot, neato, or graph-easy.

Returns
DOT representation of the circuit.

Definition at line 144 of file DotCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGate() [1/4]

gate_t DotCircuit::setGate ( const uuid u,
DotGate  t,
std::string  d 
)

Create (or update) a gate with a UUID, type, and description.

The d string is used as the node label in the DOT output.

Parameters
uUUID of the gate.
tGate type.
dDescription / label string for this gate.
Returns
Gate identifier.

Definition at line 39 of file DotCircuit.cpp.

Here is the call graph for this function:

◆ setGate() [2/4]

gate_t DotCircuit::setGate ( const uuid u,
DotGate  type 
)
override

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.

Parameters
uUUID string to associate with the gate.
typeGate type.
Returns
Gate identifier.

Definition at line 31 of file DotCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGate() [3/4]

gate_t Circuit< gateType >::setGate ( const uuid u,
gateType  type 
)
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.

Parameters
uUUID string to associate with the gate.
typeGate type.
Returns
Gate identifier.

Reimplemented from Circuit< DotGate >.

Definition at line 164 of file Circuit.hpp.

◆ setGate() [4/4]

gate_t Circuit< gateType >::setGate ( gateType  type)
virtual

Allocate a new gate with type type and no UUID.

Parameters
typeGate type.
Returns
Gate identifier.

Reimplemented from Circuit< DotGate >.

Definition at line 171 of file Circuit.hpp.

◆ toString()

std::string DotCircuit::toString ( gate_t  g) const
overridevirtual

Return a textual description of gate g for debugging.

Pure virtual; each concrete circuit class provides its own formatting.

Parameters
gGate to describe.
Returns
Human-readable string.

Implements Circuit< DotGate >.

Definition at line 54 of file DotCircuit.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ desc

std::vector<std::string> DotCircuit::desc
private

Per-gate label strings (indexed by gate ID)

Definition at line 64 of file DotCircuit.h.

◆ inputs

std::set<gate_t> DotCircuit::inputs
private

Input gate IDs (rendered as leaf nodes)

Definition at line 63 of file DotCircuit.h.


The documentation for this class was generated from the following files: