souffle  2.0.2-371-g6315b36
Public Member Functions | Private Attributes
souffle::interpreter::ProgInterface Class Reference

Implementation of SouffleProgram interface for an interpreter instance. More...

#include <ProgInterface.h>

Inheritance diagram for souffle::interpreter::ProgInterface:
Inheritance graph
Collaboration diagram for souffle::interpreter::ProgInterface:
Collaboration graph

Public Member Functions

void dumpInputs () override
 Dump inputs: not implemented. More...
 
void dumpOutputs () override
 Dump outputs: not implemented. More...
 
void executeSubroutine (std::string name, const std::vector< RamDomain > &args, std::vector< RamDomain > &ret) override
 Run subroutine. More...
 
RecordTablegetRecordTable () override
 Get the record table of the program. More...
 
SymbolTablegetSymbolTable () override
 Get symbol table. More...
 
void loadAll (std::string) override
 Load input data: not implemented. More...
 
void printAll (std::string) override
 Print output data: not implemented. More...
 
 ProgInterface (Engine &interp)
 
void run () override
 Run program instance: not implemented. More...
 
void runAll (std::string, std::string) override
 Load data, run program instance, store data: not implemented. More...
 
 ~ProgInterface () override
 
- Public Member Functions inherited from souffle::SouffleProgram
template<typename... Args>
bool contains (const std::tuple< Args... > &t, Relation *relation)
 Contains function with std::tuple as input (wrapper) 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...
 
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...
 
template<typename... Args>
void insert (const std::tuple< Args... > &t, Relation *relation)
 Insert function with std::tuple as input (wrapper) 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...
 
void setNumThreads (std::size_t numThreadsValue)
 Set the number of threads to be used. More...
 
virtual ~SouffleProgram ()=default
 Destructor. More...
 

Private Attributes

Engineexec
 
std::vector< RelInterface * > interfaces
 
const ram::Programprog
 
RecordTablerecordTable
 
SymbolTablesymTable
 

Additional Inherited Members

- Protected Member Functions inherited from souffle::SouffleProgram
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)
 

Detailed Description

Implementation of SouffleProgram interface for an interpreter instance.

Definition at line 214 of file ProgInterface.h.

Constructor & Destructor Documentation

◆ ProgInterface()

souffle::interpreter::ProgInterface::ProgInterface ( Engine interp)
inlineexplicit

Definition at line 216 of file ProgInterface.h.

217  { map[rel.getName()] = &rel; });
218 
219  // Build wrapper relations for Souffle's interface
220  for (auto& relHandler : exec.getRelationMap()) {
221  if (relHandler == nullptr) {
222  // Skip droped relation.
223  continue;
224  }
225  auto& interpreterRel = **relHandler;
226  auto& name = interpreterRel.getName();
227  assert(map[name]);
228  const ram::Relation& rel = *map[name];
229 
230  // construct types and names vectors
231  std::vector<std::string> types = rel.getAttributeTypes();
232  std::vector<std::string> attrNames = rel.getAttributeNames();
233 
234  auto* interface = new RelInterface(interpreterRel, symTable, rel.getName(), types, attrNames, id);
235  interfaces.push_back(interface);
236  bool input = false;
237  bool output = false;
238  visitDepthFirst(prog, [&](const ram::IO& io) {
239  if (map[io.getRelation()] == &rel) {
240  const std::string& op = io.get("operation");
241  if (op == "input") {
242  input = true;
243  } else if (op == "output" || op == "printsize") {
244  output = true;
245  } else {
246  assert("wrong i/o operation");
247  }
248  }
249  });
250  addRelation(rel.getName(), *interface, input, output);
251  id++;
252  }
253  }
254  ~ProgInterface() override {
255  for (auto* interface : interfaces) {
256  delete interface;
257  }
258  }
259 

References souffle::map(), and rel().

Here is the call graph for this function:

◆ ~ProgInterface()

souffle::interpreter::ProgInterface::~ProgInterface ( )
inlineoverride

Definition at line 260 of file ProgInterface.h.

261  {}
262 
263  /** Load data, run program instance, store data: not implemented */
264  void runAll(std::string, std::string) override {}

Member Function Documentation

◆ dumpInputs()

void souffle::interpreter::ProgInterface::dumpInputs ( )
inlineoverridevirtual

Dump inputs: not implemented.

Implements souffle::SouffleProgram.

Definition at line 279 of file ProgInterface.h.

◆ dumpOutputs()

void souffle::interpreter::ProgInterface::dumpOutputs ( )
inlineoverridevirtual

Dump outputs: not implemented.

Implements souffle::SouffleProgram.

Definition at line 282 of file ProgInterface.h.

285 {

◆ executeSubroutine()

void souffle::interpreter::ProgInterface::executeSubroutine ( std::string  name,
const std::vector< RamDomain > &  args,
std::vector< RamDomain > &  ret 
)
inlineoverridevirtual

Run subroutine.

Reimplemented from souffle::SouffleProgram.

Definition at line 285 of file ProgInterface.h.

285  {
286  return symTable;
287  }
288 

◆ getRecordTable()

RecordTable& souffle::interpreter::ProgInterface::getRecordTable ( )
inlineoverridevirtual

Get the record table of the program.

Implements souffle::SouffleProgram.

Definition at line 295 of file ProgInterface.h.

◆ getSymbolTable()

SymbolTable& souffle::interpreter::ProgInterface::getSymbolTable ( )
inlineoverridevirtual

Get symbol table.

Implements souffle::SouffleProgram.

Definition at line 291 of file ProgInterface.h.

293  :
294  const ram::Program& prog;

◆ loadAll()

void souffle::interpreter::ProgInterface::loadAll ( std::string  )
inlineoverridevirtual

Load input data: not implemented.

Implements souffle::SouffleProgram.

Definition at line 273 of file ProgInterface.h.

273 {}

◆ printAll()

void souffle::interpreter::ProgInterface::printAll ( std::string  )
inlineoverridevirtual

Print output data: not implemented.

Implements souffle::SouffleProgram.

Definition at line 276 of file ProgInterface.h.

276 {}

◆ run()

void souffle::interpreter::ProgInterface::run ( )
inlineoverridevirtual

Run program instance: not implemented.

Reimplemented from souffle::SouffleProgram.

Definition at line 267 of file ProgInterface.h.

267 {}

◆ runAll()

void souffle::interpreter::ProgInterface::runAll ( std::string  ,
std::string   
)
inlineoverridevirtual

Load data, run program instance, store data: not implemented.

Implements souffle::SouffleProgram.

Definition at line 270 of file ProgInterface.h.

270 {}

Field Documentation

◆ exec

Engine& souffle::interpreter::ProgInterface::exec
private

Definition at line 301 of file ProgInterface.h.

◆ interfaces

std::vector<RelInterface*> souffle::interpreter::ProgInterface::interfaces
private

Definition at line 304 of file ProgInterface.h.

◆ prog

const ram::Program& souffle::interpreter::ProgInterface::prog
private

Definition at line 300 of file ProgInterface.h.

◆ recordTable

RecordTable& souffle::interpreter::ProgInterface::recordTable
private

Definition at line 303 of file ProgInterface.h.

◆ symTable

SymbolTable& souffle::interpreter::ProgInterface::symTable
private

Definition at line 302 of file ProgInterface.h.


The documentation for this class was generated from the following file:
souffle::interpreter::ProgInterface::symTable
SymbolTable & symTable
Definition: ProgInterface.h:302
souffle::interpreter::ProgInterface::interfaces
std::vector< RelInterface * > interfaces
Definition: ProgInterface.h:304
types
std::vector< Own< ast::Type > > types
Definition: ComponentInstantiation.cpp:64
souffle::map
auto map(const std::vector< A > &xs, F &&f)
Applies a function to each element of a vector and returns the results.
Definition: ContainerUtil.h:158
souffle::interpreter::ProgInterface::runAll
void runAll(std::string, std::string) override
Load data, run program instance, store data: not implemented.
Definition: ProgInterface.h:270
souffle::interpreter::ProgInterface::prog
const ram::Program & prog
Definition: ProgInterface.h:300
souffle::interpreter::ProgInterface::~ProgInterface
~ProgInterface() override
Definition: ProgInterface.h:260
souffle::interpreter::Engine::getRelationMap
VecOwn< RelationHandle > & getRelationMap()
Return the relation map.
Definition: Engine.cpp:194
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
souffle::ast::DirectiveType::input
@ input
souffle::ast::DirectiveType::output
@ output
souffle::ast::visitDepthFirst
void visitDepthFirst(const Node &root, Visitor< R, Ps... > &visitor, Args &... args)
A utility function visiting all nodes within the ast rooted by the given node recursively in a depth-...
Definition: Visitor.h:273
souffle::interpreter::ProgInterface::exec
Engine & exec
Definition: ProgInterface.h:301
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
id
void id(std::string col)
Definition: Tui.h:1124