souffle  2.0.2-371-g6315b36
LogSize.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2017, 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 LogSize.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/Node.h"
18 #include "ram/Relation.h"
19 #include "ram/RelationStatement.h"
23 #include <memory>
24 #include <ostream>
25 #include <string>
26 #include <utility>
27 
28 namespace souffle::ram {
29 
30 /**
31  * @class LogSize
32  * @brief Log relation size and a logging message.
33  */
34 class LogSize : public RelationStatement {
35 public:
36  LogSize(std::string rel, std::string message) : RelationStatement(rel), message(std::move(message)) {}
37 
38  /** @brief Get logging message */
39  const std::string& getMessage() const {
40  return message;
41  }
42 
43  LogSize* clone() const override {
44  return new LogSize(relation, message);
45  }
46 
47 protected:
48  void print(std::ostream& os, int tabpos) const override {
49  os << times(" ", tabpos) << "LOGSIZE " << relation;
50  os << " TEXT "
51  << "\"" << stringify(message) << "\"";
52  os << std::endl;
53  }
54 
55  bool equal(const Node& node) const override {
56  const auto& other = static_cast<const LogSize&>(node);
57  return RelationStatement::equal(other) && message == other.message;
58  }
59 
60  /** Logging message */
61  const std::string message;
62 };
63 
64 } // namespace souffle::ram
souffle::ram::LogSize::LogSize
LogSize(std::string rel, std::string message)
Definition: LogSize.h:40
RelationStatement.h
souffle::ram::RelationStatement::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: RelationStatement.h:47
souffle::ram::RelationStatement::RelationStatement
RelationStatement(std::string rel)
Definition: RelationStatement.h:39
souffle::ram::RelationStatement::relation
std::string relation
Relation.
Definition: RelationStatement.h:54
MiscUtil.h
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::LogSize::clone
LogSize * clone() const override
Create a clone (i.e.
Definition: LogSize.h:47
souffle::ram::Node
Node is a superclass for all RAM IR classes.
Definition: Node.h:42
souffle::stringify
std::string stringify(const std::string &input)
Stringify a string using escapes for escape, newline, tab, double-quotes and semicolons.
Definition: StringUtil.h:334
souffle::ram::LogSize::getMessage
const std::string & getMessage() const
Get logging message.
Definition: LogSize.h:43
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
Relation.h
StringUtil.h
souffle::ram::LogSize::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: LogSize.h:59
souffle::ram::LogSize::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: LogSize.h:52
souffle::ram::LogSize::message
const std::string message
Logging message.
Definition: LogSize.h:65
Node.h
std
Definition: Brie.h:3053
StreamUtil.h
souffle::ram::LogSize
Log relation size and a logging message.
Definition: LogSize.h:38
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086