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

Generic directed-acyclic-graph circuit template and gate identifier. More...

#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <set>
#include <vector>
#include <type_traits>
Include dependency graph for Circuit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Circuit< gateType >
 Generic template base class for provenance circuits. More...
 
class  CircuitException
 Exception type thrown by circuit operations on invalid input. More...
 

Enumerations

enum class  gate_t : size_t
 Strongly-typed gate identifier. More...
 

Functions

gate_toperator++ (gate_t &g)
 Pre-increment operator for gate_t.
 
bool operator< (gate_t t, std::vector< gate_t >::size_type u)
 Compare a gate_t against a std::vector size type.
 
std::string to_string (gate_t g)
 Convert a gate_t to its decimal string representation.
 
std::istream & operator>> (std::istream &i, gate_t &g)
 Read a gate_t from an input stream.
 
std::ostream & operator<< (std::ostream &o, gate_t g)
 Write a gate_t to an output stream as its decimal value.
 

Detailed Description

Generic directed-acyclic-graph circuit template and gate identifier.

This header provides two central abstractions:

@c gate_t

A strongly-typed wrapper around size_t used as a compact gate identifier within a circuit. Using a distinct type prevents accidental mixing of gate IDs with plain integers. Helper operators (increment, comparison, stream I/O, to_string) make it convenient to use in loops and containers.

@c Circuit<gateType>

A CRTP-style template base class for all circuit variants in ProvSQL (BooleanCircuit, GenericCircuit, DotCircuit, WhereCircuit). A circuit is a directed acyclic graph where:

  • Each gate has a type drawn from gateType (a user-supplied enum).
  • Wires are directed edges from parent gates to their children.
  • Each gate may optionally be associated with a UUID string, enabling round-tripping between the in-memory circuit and the persistent mmap representation.

Circuit.hpp (included by subclass headers) provides the out-of-line template method implementations.

@c CircuitException

Exception type thrown when a circuit operation fails (e.g. UUID not found, type mismatch).

Definition in file Circuit.h.

Enumeration Type Documentation

◆ gate_t

enum class gate_t : size_t
strong

Strongly-typed gate identifier.

Wraps a size_t so that gate IDs are not accidentally used as plain integers. The underlying value is a zero-based index into the circuit's gate and wire vectors.

Definition at line 48 of file Circuit.h.

Function Documentation

◆ operator++()

gate_t & operator++ ( gate_t g)
inline

Pre-increment operator for gate_t.

Parameters
gGate to increment.
Returns
Reference to the incremented gate.

Definition at line 229 of file Circuit.h.

◆ operator<()

bool operator< ( gate_t  t,
std::vector< gate_t >::size_type  u 
)
inline

Compare a gate_t against a std::vector size type.

Parameters
tGate identifier.
uVector size to compare against.
Returns
true if the underlying integer of t is less than u.

Definition at line 239 of file Circuit.h.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  o,
gate_t  g 
)
inline

Write a gate_t to an output stream as its decimal value.

Parameters
oOutput stream.
gGate identifier to write.
Returns
Reference to o.

Definition at line 273 of file Circuit.h.

◆ operator>>()

std::istream & operator>> ( std::istream &  i,
gate_t g 
)
inline

Read a gate_t from an input stream.

Parameters
iInput stream.
gGate to populate.
Returns
Reference to i.

Definition at line 259 of file Circuit.h.

◆ to_string()

std::string to_string ( gate_t  g)
inline

Convert a gate_t to its decimal string representation.

Parameters
gGate identifier.
Returns
Decimal string of the underlying integer.

Definition at line 249 of file Circuit.h.

Here is the caller graph for this function: