souffle  2.0.2-371-g6315b36
Filter.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 Filter.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
18 #include "ram/Condition.h"
19 #include "ram/NestedOperation.h"
20 #include "ram/Node.h"
21 #include "ram/Operation.h"
24 #include <iosfwd>
25 #include <memory>
26 #include <ostream>
27 #include <string>
28 #include <utility>
29 
30 namespace souffle::ram {
31 
32 /**
33  * @class Filter
34  * @brief Checks whether a given condition holds
35  *
36  * The Filter is essentially an "if" statement.
37  *
38  * The following example checks that both C1 and C2 hold
39  * before proceeding deeper in the loop nest:
40  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
41  * IF C1 AND C2
42  * ...
43  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~
44  */
45 class Filter : public AbstractConditional {
46 public:
47  Filter(Own<Condition> cond, Own<Operation> nested, std::string profileText = "")
48  : AbstractConditional(std::move(cond), std::move(nested), std::move(profileText)) {}
49 
50  Filter* clone() const override {
52  }
53 
54 protected:
55  void print(std::ostream& os, int tabpos) const override {
56  os << times(" ", tabpos);
57  os << "IF " << getCondition() << std::endl;
58  NestedOperation::print(os, tabpos + 1);
59  }
60 };
61 
62 } // namespace souffle::ram
souffle::ram::NestedOperation::profileText
const std::string profileText
Text used by the profiler.
Definition: NestedOperation.h:93
NestedOperation.h
souffle::ram::AbstractConditional::AbstractConditional
AbstractConditional(Own< Condition > cond, Own< Operation > nested, std::string profileText="")
Definition: AbstractConditional.h:41
souffle::ram::NestedOperation::getOperation
Operation & getOperation() const
Get nested operation.
Definition: NestedOperation.h:62
MiscUtil.h
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::Filter
Checks whether a given condition holds.
Definition: Filter.h:49
souffle::clone
auto clone(const std::vector< A * > &xs)
Definition: ContainerUtil.h:172
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::NestedOperation::getProfileText
const std::string & getProfileText() const
Get profile text.
Definition: NestedOperation.h:67
Condition.h
souffle::ram::Filter::Filter
Filter(Own< Condition > cond, Own< Operation > nested, std::string profileText="")
Definition: Filter.h:51
souffle::ram::Filter::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: Filter.h:59
souffle::ram::AbstractConditional::getCondition
const Condition & getCondition() const
Get condition that must be satisfied.
Definition: AbstractConditional.h:49
souffle::ram::Filter::clone
Filter * clone() const override
Create a clone (i.e.
Definition: Filter.h:54
Node.h
std
Definition: Brie.h:3053
Operation.h
StreamUtil.h
AbstractConditional.h
souffle::ram::AbstractConditional::condition
Own< Condition > condition
Condition.
Definition: AbstractConditional.h:72
souffle::ram::NestedOperation::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: NestedOperation.h:80