souffle  2.0.2-371-g6315b36
Counter.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 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 Counter.h
12  *
13  * Defines a counter functor class
14  *
15  ***********************************************************************/
16 
17 #pragma once
18 
19 #include "ast/Argument.h"
20 #include <ostream>
21 
22 namespace souffle::ast {
23 
24 /**
25  * @class Counter
26  * @brief counter functor (incrementing a value after each invocation)
27  */
28 class Counter : public Argument {
29 public:
30  using Argument::Argument;
31 
32  Counter* clone() const override {
33  return new Counter(getSrcLoc());
34  }
35 
36 protected:
37  void print(std::ostream& os) const override {
38  os << "$";
39  }
40 };
41 
42 } // namespace souffle::ast
souffle::ast::Counter::clone
Counter * clone() const override
Create clone.
Definition: Counter.h:38
Argument.h
souffle::ast::Node::getSrcLoc
const SrcLocation & getSrcLoc() const
Return source location of the Node.
Definition: Node.h:46
souffle::ast
Definition: Aggregator.h:35
souffle::ast::Counter::print
void print(std::ostream &os) const override
Output to a given output stream.
Definition: Counter.h:43