souffle  2.0.2-371-g6315b36
Data Structures | Public Member Functions | Protected Member Functions | Private Attributes
souffle::SouffleProgram Class Referenceabstract

Abstract base class for generated Datalog programs. More...

#include <SouffleInterface.h>

Inheritance diagram for souffle::SouffleProgram:
Inheritance graph
Collaboration diagram for souffle::SouffleProgram:
Collaboration graph

Data Structures

struct  tuple_insert
 Helper function for the wrapper function Relation::insert() and Relation::contains(). More...
 
struct  tuple_insert< Tuple, 1 >
 Helper function for the wrapper function Relation::insert() and Relation::contains() for the first element of the tuple. More...
 

Public Member Functions

template<typename... Args>
bool contains (const std::tuple< Args... > &t, Relation *relation)
 Contains function with std::tuple as input (wrapper) More...
 
virtual void dumpInputs ()=0
 Output all the input relations in stdout, without generating any files. More...
 
virtual void dumpOutputs ()=0
 Output all the output relations in stdout, without generating any files. More...
 
virtual void executeSubroutine (std::string, const std::vector< RamDomain > &, std::vector< RamDomain > &)
 Execute a subroutine. More...
 
std::vector< Relation * > getAllRelations () const
 Getter of allRelations, which this vector structure contains all relations. More...
 
std::vector< Relation * > getInputRelations () const
 Getter of inputRelations, which this vector structure contains all input relations. More...
 
std::vector< Relation * > getInternalRelations () const
 Getter of internalRelations, which this vector structure contains all relations that are neither an input relation or an output relation. More...
 
std::size_t getNumThreads ()
 Get the number of threads to be used. More...
 
std::vector< Relation * > getOutputRelations () const
 Getter of outputRelations, which this vector structure contains all output relations. More...
 
virtual RecordTablegetRecordTable ()=0
 Get the record table of the program. More...
 
RelationgetRelation (const std::string &name) const
 Get Relation by its name from relationMap, if relation not found, return a nullptr. More...
 
std::string getRelationName (const std::string &name) const
 Return the name of the target relation from relationMap. More...
 
std::size_t getRelationSize (const std::string &name) const
 Return the size of the target relation from relationMap. More...
 
virtual SymbolTablegetSymbolTable ()=0
 Get the symbol table of the program. More...
 
template<typename... Args>
void insert (const std::tuple< Args... > &t, Relation *relation)
 Insert function with std::tuple as input (wrapper) More...
 
virtual void loadAll (std::string inputDirectory="")=0
 Read all input relations. More...
 
virtual void printAll (std::string outputDirectory="")=0
 Store all output relations. More...
 
void purgeInputRelations ()
 Remove all the tuples from the inputRelations, calling the purge method of each. More...
 
void purgeInternalRelations ()
 Remove all the tuples from the internalRelations, calling the purge method of each. More...
 
void purgeOutputRelations ()
 Remove all the tuples from the outputRelations, calling the purge method of each. More...
 
virtual void run ()
 Execute the souffle program, without any loads or stores. More...
 
virtual void runAll (std::string inputDirectory="", std::string outputDirectory="")=0
 Execute program, loading inputs and storing outputs as required. More...
 
void setNumThreads (std::size_t numThreadsValue)
 Set the number of threads to be used. More...
 
virtual ~SouffleProgram ()=default
 Destructor. More...
 

Protected Member Functions

void addRelation (const std::string &name, Relation &rel, bool isInput, bool isOutput)
 Add the relation to relationMap (with its name) and allRelations, depends on the properties of the relation, if the relation is an input relation, it will be added to inputRelations, else if the relation is an output relation, it will be added to outputRelations, otherwise will add to internalRelations. More...
 
void addRelation (const std::string &name, Relation *rel, bool isInput, bool isOutput)
 

Private Attributes

std::vector< Relation * > allRelations
 allRelations store all the relation in a vector. More...
 
std::vector< Relation * > inputRelations
 inputRelations stores all the input relation in a vector. More...
 
std::vector< Relation * > internalRelations
 internalRelation stores all the relation in a vector that are neither an input or an output. More...
 
std::size_t numThreads = 1
 The number of threads used by OpenMP. More...
 
std::vector< Relation * > outputRelations
 outputRelations stores all the output relation in a vector. More...
 
std::map< std::string, Relation * > relationMap
 Define a relation map for external access, when getRelation(name) is called, the relation with the given name will be returned from this map, relationMap stores all the relations in a map with its name as the key and relation as the value. More...
 

Detailed Description

Abstract base class for generated Datalog programs.

Definition at line 693 of file SouffleInterface.h.

Constructor & Destructor Documentation

◆ ~SouffleProgram()

virtual souffle::SouffleProgram::~SouffleProgram ( )
virtualdefault

Destructor.

Destructor of SouffleProgram.

Member Function Documentation

◆ addRelation() [1/2]

void souffle::SouffleProgram::addRelation ( const std::string &  name,
Relation rel,
bool  isInput,
bool  isOutput 
)
inlineprotected

Add the relation to relationMap (with its name) and allRelations, depends on the properties of the relation, if the relation is an input relation, it will be added to inputRelations, else if the relation is an output relation, it will be added to outputRelations, otherwise will add to internalRelations.

(a relation could be both input and output at the same time.)

Parameters
namethe name of the relation (std::string)
rela reference to the relation
isInputa bool argument, true if the relation is a input relation, else false (bool)
isOnputa bool argument, true if the relation is a ouput relation, else false (bool)

Definition at line 739 of file SouffleInterface.h.

739  {
740  outputRelations.push_back(&rel);
741  }
742  if (!isInput && !isOutput) {
743  internalRelations.push_back(&rel);
744  }
745  }
746 
747  [[deprecated("pass `rel` by reference; `rel` may not be null"), maybe_unused]] void addRelation(
748  const std::string& name, Relation* rel, bool isInput, bool isOutput) {
749  assert(rel && "`rel` may not be null");
750  addRelation(name, *rel, isInput, isOutput);
751  }

References outputRelations, and rel().

Here is the call graph for this function:

◆ addRelation() [2/2]

void souffle::SouffleProgram::addRelation ( const std::string &  name,
Relation rel,
bool  isInput,
bool  isOutput 
)
inlineprotected

Definition at line 753 of file SouffleInterface.h.

753  :
754  /**
755  * Destructor.
756  *
757  * Destructor of SouffleProgram.

◆ contains()

template<typename... Args>
bool souffle::SouffleProgram::contains ( const std::tuple< Args... > &  t,
Relation relation 
)
inline

Contains function with std::tuple as input (wrapper)

Parameters
tThe existence searching tuple (std::tuple)
relationThe relation that perform contains operation (Relation*)
Returns
A boolean value, return true if the tuple found, otherwise return false
See also
Relation::contains()

Definition at line 996 of file SouffleInterface.h.

1000  {

◆ dumpInputs()

virtual void souffle::SouffleProgram::dumpInputs ( )
pure virtual

Output all the input relations in stdout, without generating any files.

(for debug purposes).

Implemented in souffle::interpreter::ProgInterface.

Referenced by SWIGSouffleProgram::printAll().

◆ dumpOutputs()

virtual void souffle::SouffleProgram::dumpOutputs ( )
pure virtual

Output all the output relations in stdout, without generating any files.

(for debug purposes).

Implemented in souffle::interpreter::ProgInterface.

Referenced by SWIGSouffleProgram::dumpInputs().

◆ executeSubroutine()

virtual void souffle::SouffleProgram::executeSubroutine ( std::string  ,
const std::vector< RamDomain > &  ,
std::vector< RamDomain > &   
)
inlinevirtual

Execute a subroutine.

Parameters
nameName of a subroutine (std:string)
argArguments of the subroutine (std::vector<RamDomain>&)
retReturn values of the subroutine (std::vector<RamDomain>&)

Reimplemented in souffle::interpreter::ProgInterface.

Definition at line 903 of file SouffleInterface.h.

917  {

References outputRelations, and relation.

◆ getAllRelations()

std::vector<Relation*> souffle::SouffleProgram::getAllRelations ( ) const
inline

Getter of allRelations, which this vector structure contains all relations.

Returns
allRelations (std::vector)
See also
allRelations

Definition at line 893 of file SouffleInterface.h.

893  :string)
894  * @param arg Arguments of the subroutine (std::vector<RamDomain>&)
895  * @param ret Return values of the subroutine (std::vector<RamDomain>&)

References souffle::fatal().

Here is the call graph for this function:

◆ getInputRelations()

std::vector<Relation*> souffle::SouffleProgram::getInputRelations ( ) const
inline

Getter of inputRelations, which this vector structure contains all input relations.

Returns
intputRelations (std::vector)
See also
inputRelations

Definition at line 872 of file SouffleInterface.h.

References internalRelations.

◆ getInternalRelations()

std::vector<Relation*> souffle::SouffleProgram::getInternalRelations ( ) const
inline

Getter of internalRelations, which this vector structure contains all relations that are neither an input relation or an output relation.

Returns
internalRelations (std::vector)
See also
internalRelations

Definition at line 883 of file SouffleInterface.h.

References allRelations.

◆ getNumThreads()

std::size_t souffle::SouffleProgram::getNumThreads ( )
inline

Get the number of threads to be used.

Definition at line 817 of file SouffleInterface.h.

References relationMap.

◆ getOutputRelations()

std::vector<Relation*> souffle::SouffleProgram::getOutputRelations ( ) const
inline

Getter of outputRelations, which this vector structure contains all output relations.

Returns
outputRelations (std::vector)
See also
outputRelations

Definition at line 862 of file SouffleInterface.h.

References inputRelations.

◆ getRecordTable()

virtual RecordTable& souffle::SouffleProgram::getRecordTable ( )
pure virtual

Get the record table of the program.

Implemented in souffle::interpreter::ProgInterface.

◆ getRelation()

Relation* souffle::SouffleProgram::getRelation ( const std::string &  name) const
inline

Get Relation by its name from relationMap, if relation not found, return a nullptr.

Parameters
nameThe name of the target relation (const std::string)
Returns
The pointer of the target relation, or null pointer if the relation not found (Relation*)

Definition at line 827 of file SouffleInterface.h.

Referenced by getRelationSize().

◆ getRelationName()

std::string souffle::SouffleProgram::getRelationName ( const std::string &  name) const
inline

Return the name of the target relation from relationMap.

Parameters
nameThe name of the target relation (const std::string)
Returns
The name of the target relation (std::string)

Definition at line 852 of file SouffleInterface.h.

References outputRelations.

◆ getRelationSize()

std::size_t souffle::SouffleProgram::getRelationSize ( const std::string &  name) const
inline

Return the size of the target relation from relationMap.

Parameters
nameThe name of the target relation (const std::string)
Returns
The size of the target relation (std::size_t)

Definition at line 842 of file SouffleInterface.h.

References souffle::Relation::getName(), and getRelation().

Here is the call graph for this function:

◆ getSymbolTable()

virtual SymbolTable& souffle::SouffleProgram::getSymbolTable ( )
pure virtual

Get the symbol table of the program.

Implemented in souffle::interpreter::ProgInterface.

Referenced by souffle::RelationWrapper< RelType >::getArity().

◆ insert()

template<typename... Args>
void souffle::SouffleProgram::insert ( const std::tuple< Args... > &  t,
Relation relation 
)
inline

Insert function with std::tuple as input (wrapper)

Parameters
tThe insert tuple (std::tuple)
relationThe relation that perform insert operation (Relation*)
See also
Relation::insert()

Definition at line 981 of file SouffleInterface.h.

References relation.

◆ loadAll()

virtual void souffle::SouffleProgram::loadAll ( std::string  inputDirectory = "")
pure virtual

Read all input relations.

File IO types can use the given directory to find their input file.

Parameters
inputDirectoryIf non-empty, specifies the input directory

Implemented in souffle::interpreter::ProgInterface.

Referenced by SWIGSouffleProgram::runAll().

◆ printAll()

virtual void souffle::SouffleProgram::printAll ( std::string  outputDirectory = "")
pure virtual

Store all output relations.

File IO types can use the given directory to find their input file.

Parameters
outputDirectoryIf non-empty, specifies the output directory

Implemented in souffle::interpreter::ProgInterface.

Referenced by SWIGSouffleProgram::loadAll().

◆ purgeInputRelations()

void souffle::SouffleProgram::purgeInputRelations ( )
inline

Remove all the tuples from the inputRelations, calling the purge method of each.

See also
Relation::purge()

Definition at line 934 of file SouffleInterface.h.

939  {

References internalRelations, and relation.

◆ purgeInternalRelations()

void souffle::SouffleProgram::purgeInternalRelations ( )
inline

Remove all the tuples from the internalRelations, calling the purge method of each.

See also
Relation::purge()

Definition at line 945 of file SouffleInterface.h.

949  {

References souffle::SouffleProgram::tuple_insert< Tuple, N >::add(), and TCB_SPAN_NAMESPACE_NAME::get().

Here is the call graph for this function:

◆ purgeOutputRelations()

void souffle::SouffleProgram::purgeOutputRelations ( )
inline

Remove all the tuples from the outputRelations, calling the purge method of each.

See also
Relation::purge()

Definition at line 923 of file SouffleInterface.h.

928  {

References inputRelations, and relation.

◆ run()

virtual void souffle::SouffleProgram::run ( )
inlinevirtual

Execute the souffle program, without any loads or stores.

Reimplemented in souffle::interpreter::ProgInterface.

Definition at line 770 of file SouffleInterface.h.

Referenced by SWIGSouffleProgram::~SWIGSouffleProgram().

◆ runAll()

virtual void souffle::SouffleProgram::runAll ( std::string  inputDirectory = "",
std::string  outputDirectory = "" 
)
pure virtual

Execute program, loading inputs and storing outputs as required.

File IO types can use the given directories to find their input file.

Parameters
inputDirectoryIf non-empty, specifies the input directory
outputDirectoryIf non-empty, specifies the output directory

Implemented in souffle::interpreter::ProgInterface.

Referenced by SWIGSouffleProgram::run().

◆ setNumThreads()

void souffle::SouffleProgram::setNumThreads ( std::size_t  numThreadsValue)
inline

Set the number of threads to be used.

Definition at line 810 of file SouffleInterface.h.

811  {
812  return numThreads;

References numThreads.

Field Documentation

◆ allRelations

std::vector<Relation*> souffle::SouffleProgram::allRelations
private

allRelations store all the relation in a vector.

Definition at line 721 of file SouffleInterface.h.

Referenced by getInternalRelations().

◆ inputRelations

std::vector<Relation*> souffle::SouffleProgram::inputRelations
private

inputRelations stores all the input relation in a vector.

Definition at line 706 of file SouffleInterface.h.

Referenced by getOutputRelations(), and purgeOutputRelations().

◆ internalRelations

std::vector<Relation*> souffle::SouffleProgram::internalRelations
private

internalRelation stores all the relation in a vector that are neither an input or an output.

Definition at line 716 of file SouffleInterface.h.

Referenced by getInputRelations(), and purgeInputRelations().

◆ numThreads

std::size_t souffle::SouffleProgram::numThreads = 1
private

The number of threads used by OpenMP.

Definition at line 725 of file SouffleInterface.h.

Referenced by setNumThreads().

◆ outputRelations

std::vector<Relation*> souffle::SouffleProgram::outputRelations
private

outputRelations stores all the output relation in a vector.

Definition at line 711 of file SouffleInterface.h.

Referenced by addRelation(), executeSubroutine(), and getRelationName().

◆ relationMap

std::map<std::string, Relation*> souffle::SouffleProgram::relationMap
private

Define a relation map for external access, when getRelation(name) is called, the relation with the given name will be returned from this map, relationMap stores all the relations in a map with its name as the key and relation as the value.

Definition at line 701 of file SouffleInterface.h.

Referenced by getNumThreads().


The documentation for this class was generated from the following file:
souffle::SouffleProgram::outputRelations
std::vector< Relation * > outputRelations
outputRelations stores all the output relation in a vector.
Definition: SouffleInterface.h:711
souffle::SouffleProgram::internalRelations
std::vector< Relation * > internalRelations
internalRelation stores all the relation in a vector that are neither an input or an output.
Definition: SouffleInterface.h:716
souffle::SouffleProgram::numThreads
std::size_t numThreads
The number of threads used by OpenMP.
Definition: SouffleInterface.h:725
souffle::SouffleProgram::addRelation
void addRelation(const std::string &name, Relation &rel, bool isInput, bool isOutput)
Add the relation to relationMap (with its name) and allRelations, depends on the properties of the re...
Definition: SouffleInterface.h:739
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086