souffle  2.0.2-371-g6315b36
SwigInterface.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2019, The Souffle Developers. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file SwigInterface.h
12  *
13  * Header file for SWIG to invoke functions in souffle::SouffleProgram
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
20 #include <iostream>
21 #include <string>
22 
23 /**
24  * Abstract base class for generated Datalog programs
25  */
27  /**
28  * pointer to SouffleProgram to invoke functions from SouffleInterface.h
29  */
31 
32 public:
34 
35  virtual ~SWIGSouffleProgram() {
36  delete program;
37  }
38 
39  /**
40  * Calls the corresponding method souffle::SouffleProgram::run in SouffleInterface.h
41  */
42  void run() {
43  program->run();
44  }
45 
46  /**
47  * Calls the corresponding method souffle::SouffleProgram::runAll in SouffleInterface.h
48  */
49  void runAll(const std::string& inputDirectory, const std::string& outputDirectory) {
50  program->runAll(inputDirectory, outputDirectory);
51  }
52 
53  /**
54  * Calls the corresponding method souffle::SouffleProgram::loadAll in SouffleInterface.h
55  */
56  void loadAll(const std::string& inputDirectory) {
57  program->loadAll(inputDirectory);
58  }
59 
60  /**
61  * Calls the corresponding method souffle::SouffleProgram::printAll in SouffleInterface.h
62  */
63  void printAll(const std::string& outputDirectory) {
64  program->printAll(outputDirectory);
65  }
66 
67  /**
68  * Calls the corresponding method souffle::SouffleProgram::dumpInputs in SouffleInterface.h
69  */
70  void dumpInputs() {
72  }
73 
74  /**
75  * Calls the corresponding method souffle::SouffleProgram::dumpOutputs in SouffleInterface.h
76  */
77  void dumpOutputs() {
79  }
80 };
81 
82 /**
83  * Creates an instance of a SWIG souffle::SouffleProgram that can be called within a program of a supported
84  * language for the SWIG option specified in main.cpp. This enables the program to use this instance and call
85  * the supported souffle::SouffleProgram methods.
86  * @param name Name of the datalog file/ instance to be created
87  */
88 SWIGSouffleProgram* newInstance(const std::string& name) {
89  auto* prog = souffle::ProgramFactory::newInstance(name);
90  return new SWIGSouffleProgram(prog);
91 }
newInstance
SWIGSouffleProgram * newInstance(const std::string &name)
Creates an instance of a SWIG souffle::SouffleProgram that can be called within a program of a suppor...
Definition: SwigInterface.h:88
souffle::ProgramFactory::newInstance
virtual SouffleProgram * newInstance()=0
Create new instance (abstract).
SWIGSouffleProgram::SWIGSouffleProgram
SWIGSouffleProgram(souffle::SouffleProgram *program)
Definition: SwigInterface.h:39
souffle::SouffleProgram::runAll
virtual void runAll(std::string inputDirectory="", std::string outputDirectory="")=0
Execute program, loading inputs and storing outputs as required.
SWIGSouffleProgram::runAll
void runAll(const std::string &inputDirectory, const std::string &outputDirectory)
Calls the corresponding method souffle::SouffleProgram::runAll in SouffleInterface....
Definition: SwigInterface.h:55
SWIGSouffleProgram::loadAll
void loadAll(const std::string &inputDirectory)
Calls the corresponding method souffle::SouffleProgram::loadAll in SouffleInterface....
Definition: SwigInterface.h:62
souffle::SouffleProgram::printAll
virtual void printAll(std::string outputDirectory="")=0
Store all output relations.
souffle::SouffleProgram
Abstract base class for generated Datalog programs.
Definition: SouffleInterface.h:693
souffle::SouffleProgram::run
virtual void run()
Execute the souffle program, without any loads or stores.
Definition: SouffleInterface.h:770
souffle::SouffleProgram::dumpOutputs
virtual void dumpOutputs()=0
Output all the output relations in stdout, without generating any files.
SWIGSouffleProgram::run
void run()
Calls the corresponding method souffle::SouffleProgram::run in SouffleInterface.h.
Definition: SwigInterface.h:48
SWIGSouffleProgram::printAll
void printAll(const std::string &outputDirectory)
Calls the corresponding method souffle::SouffleProgram::printAll in SouffleInterface....
Definition: SwigInterface.h:69
souffle::SouffleProgram::dumpInputs
virtual void dumpInputs()=0
Output all the input relations in stdout, without generating any files.
SWIGSouffleProgram::program
souffle::SouffleProgram * program
pointer to SouffleProgram to invoke functions from SouffleInterface.h
Definition: SwigInterface.h:36
SWIGSouffleProgram::dumpInputs
void dumpInputs()
Calls the corresponding method souffle::SouffleProgram::dumpInputs in SouffleInterface....
Definition: SwigInterface.h:76
souffle::SouffleProgram::loadAll
virtual void loadAll(std::string inputDirectory="")=0
Read all input relations.
SWIGSouffleProgram::~SWIGSouffleProgram
virtual ~SWIGSouffleProgram()
Definition: SwigInterface.h:41
SWIGSouffleProgram::dumpOutputs
void dumpOutputs()
Calls the corresponding method souffle::SouffleProgram::dumpOutputs in SouffleInterface....
Definition: SwigInterface.h:83
SouffleInterface.h
SWIGSouffleProgram
Abstract base class for generated Datalog programs.
Definition: SwigInterface.h:26