souffle  2.0.2-371-g6315b36
Analysis.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2018, 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 Analysis.h
12  *
13  * Defines an interface for RAM analysis
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include <ostream>
20 #include <string>
21 
22 namespace souffle::ram {
23 
24 class TranslationUnit;
25 
26 namespace analysis {
27 
28 /**
29  * @class Analysis
30  * @brief Abstract class for a RAM Analysis.
31  */
32 class Analysis {
33 public:
34  Analysis(const char* id) : identifier(id) {}
35  virtual ~Analysis() = default;
36 
37  /** @brief get name of the analysis */
38  virtual const std::string& getName() const {
39  return identifier;
40  }
41 
42  /** @brief Run analysis for a RAM translation unit */
43  virtual void run(const TranslationUnit& translationUnit) = 0;
44 
45  /** @brief Print the analysis result in HTML format */
46  virtual void print(std::ostream& /* os */) const {}
47 
48  /** @brief define output stream operator */
49  friend std::ostream& operator<<(std::ostream& out, const Analysis& other) {
50  other.print(out);
51  return out;
52  }
53 
54 protected:
55  /** @brief name of analysis instance */
56  std::string identifier;
57 };
58 
59 } // namespace analysis
60 } // namespace souffle::ram
souffle::ram::analysis::Analysis::getName
virtual const std::string & getName() const
get name of the analysis
Definition: Analysis.h:44
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::TranslationUnit
Translating a RAM program.
Definition: TranslationUnit.h:55
souffle::ram::analysis::Analysis::operator<<
friend std::ostream & operator<<(std::ostream &out, const Analysis &other)
define output stream operator
Definition: Analysis.h:55
souffle::ram::analysis::Analysis::Analysis
Analysis(const char *id)
Definition: Analysis.h:40
souffle::ram::analysis::Analysis::run
virtual void run(const TranslationUnit &translationUnit)=0
Run analysis for a RAM translation unit.
souffle::ram::analysis::Analysis::identifier
std::string identifier
name of analysis instance
Definition: Analysis.h:62
souffle::ram::analysis::Analysis::print
virtual void print(std::ostream &) const
Print the analysis result in HTML format.
Definition: Analysis.h:52
souffle::ram::analysis::Analysis
Abstract class for a RAM Analysis.
Definition: Analysis.h:38
souffle::ram::analysis::Analysis::~Analysis
virtual ~Analysis()=default