ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
GenericCircuit.cpp
Go to the documentation of this file.
1/**
2 * @file GenericCircuit.cpp
3 * @brief GenericCircuit method implementations.
4 *
5 * Implements the virtual methods of @c GenericCircuit that override the
6 * @c Circuit<gate_type> base class:
7 * - @c addGate(): allocates a new gate and extends the @c prob vector.
8 * - @c setGate(gate_type): creates a new gate, registering it as an
9 * input gate when the type is @c gate_input or @c gate_update.
10 * - @c setGate(const uuid&, gate_type): same with UUID binding.
11 *
12 * The template method @c evaluate() is defined in @c GenericCircuit.hpp.
13 */
14#include "GenericCircuit.h"
15
17{
18 auto id = Circuit::setGate(type);
19 if(type == gate_input || type==gate_update) {
20 inputs.insert(id);
21 }
22 return id;
23}
24
26{
27 auto id = Circuit::setGate(u, type);
28 if(type == gate_input || type==gate_update) {
29 inputs.insert(id);
30 }
31 return id;
32}
33
35{
36 auto id=Circuit::addGate();
37 prob.push_back(1);
38 return id;
39}
gate_t
Strongly-typed gate identifier.
Definition Circuit.h:48
Semiring-agnostic in-memory provenance circuit.
virtual gate_t setGate(const uuid &u, gateType type)
Create or update the gate associated with UUID u.
Definition Circuit.hpp:73
virtual gate_t addGate()
Allocate a new gate with a default-initialised type.
Definition Circuit.hpp:56
gate_t addGate() override
Allocate a new gate with a default-initialised type.
std::set< gate_t > inputs
Set of input (leaf) gate IDs.
std::vector< double > prob
Per-gate probability values.
gate_t setGate(gate_type type) override
Allocate a new gate with type type and no UUID.
gate_type
Possible gate type in the provenance circuit.
@ gate_update
Update operation.
@ gate_input
Input (variable) gate of the circuit.