souffle  2.0.2-371-g6315b36
Extend.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 Extend.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 Extend
30  * @brief Extend equivalence relation.
31  *
32  * The following example merges A into B:
33  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
34  * EXTEND B WITH A
35  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
36  */
37 class Extend : public BinRelationStatement {
38 public:
39  Extend(std::string tRef, const std::string& sRef) : BinRelationStatement(sRef, tRef) {}
40 
41  /** @brief Get source relation */
42  const std::string& getSourceRelation() const {
43  return getFirstRelation();
44  }
45 
46  /** @brief Get target relation */
47  const std::string& getTargetRelation() const {
48  return getSecondRelation();
49  }
50 
51  Extend* clone() const override {
52  auto* res = new Extend(second, first);
53  return res;
54  }
55 
56 protected:
57  void print(std::ostream& os, int tabpos) const override {
58  os << times(" ", tabpos);
59  os << "EXTEND " << getTargetRelation() << " WITH " << getSourceRelation();
60  os << std::endl;
61  }
62 };
63 
64 } // namespace souffle::ram
souffle::ram::Extend::clone
Extend * clone() const override
Create a clone (i.e.
Definition: Extend.h:55
souffle::ram::Extend
Extend equivalence relation.
Definition: Extend.h:41
MiscUtil.h
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
souffle::ram::Extend::getTargetRelation
const std::string & getTargetRelation() const
Get target relation.
Definition: Extend.h:51
Relation.h
souffle::ram::BinRelationStatement::getSecondRelation
const std::string & getSecondRelation() const
Get second relation.
Definition: BinRelationStatement.h:51
souffle::ram::Extend::getSourceRelation
const std::string & getSourceRelation() const
Get source relation.
Definition: Extend.h:46
BinRelationStatement.h
souffle::ram::Extend::Extend
Extend(std::string tRef, const std::string &sRef)
Definition: Extend.h:43
StreamUtil.h
souffle::ram::Extend::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: Extend.h:61
souffle::ram::BinRelationStatement::getFirstRelation
const std::string & getFirstRelation() const
Get first relation.
Definition: BinRelationStatement.h:46
souffle::ram::BinRelationStatement::second
const std::string second
Second relation.
Definition: BinRelationStatement.h:66