souffle  2.0.2-371-g6315b36
Swap.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 2014, Oracle and/or its affiliates. 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 Swap.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
18 #include "ram/Relation.h"
21 #include <memory>
22 #include <ostream>
23 #include <string>
24 #include <utility>
25 
26 namespace souffle::ram {
27 
28 /**
29  * @class Swap
30  * @brief Swap operation with respect to two relations
31  *
32  * Swaps the contents of the two relations
33  *
34  * For example:
35  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
36  * SWAP(A, B)
37  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
38  */
39 class Swap : public BinRelationStatement {
40 public:
41  Swap(std::string f, std::string s) : BinRelationStatement(f, s) {}
42 
43  Swap* clone() const override {
44  return new Swap(first, second);
45  }
46 
47 protected:
48  void print(std::ostream& os, int tabpos) const override {
49  os << times(" ", tabpos);
50  os << "SWAP (" << getFirstRelation() << ", " << getSecondRelation() << ")";
51  os << std::endl;
52  }
53 };
54 
55 } // namespace souffle::ram
souffle::ram::Swap
Swap operation with respect to two relations.
Definition: Swap.h:43
MiscUtil.h
souffle::ram::Swap::Swap
Swap(std::string f, std::string s)
Definition: Swap.h:45
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
souffle::ram::BinRelationStatement::first
const std::string first
First relation.
Definition: BinRelationStatement.h:63
souffle::ram::BinRelationStatement::BinRelationStatement
BinRelationStatement(std::string f, std::string s)
Definition: BinRelationStatement.h:43
Relation.h
souffle::ram::Swap::clone
Swap * clone() const override
Create a clone (i.e.
Definition: Swap.h:47
souffle::ram::BinRelationStatement::getSecondRelation
const std::string & getSecondRelation() const
Get second relation.
Definition: BinRelationStatement.h:51
BinRelationStatement.h
StreamUtil.h
souffle::ram::BinRelationStatement::getFirstRelation
const std::string & getFirstRelation() const
Get first relation.
Definition: BinRelationStatement.h:46
souffle::ram::Swap::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: Swap.h:52
souffle::ram::BinRelationStatement::second
const std::string second
Second relation.
Definition: BinRelationStatement.h:66