LIBINT 2.7.2
codeblock.h
1/*
2 * Copyright (C) 2004-2021 Edward F. Valeev
3 *
4 * This file is part of Libint.
5 *
6 * Libint is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Libint is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Libint. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <string>
22#include <entity.h>
23
24#ifndef _libint2_src_bin_libint_codeblock_h_
25#define _libint2_src_bin_libint_codeblock_h_
26
27namespace libint2 {
28
29 class CodeContext;
30
31 class CodeBlock {
32 public:
33 CodeBlock(const SafePtr<CodeContext>& context) :
34 context_(context) {}
35 virtual ~CodeBlock() {}
36
37 SafePtr<CodeContext> context() const { return context_; }
38
40 virtual std::string open() =0;
42 virtual std::string close() =0;
43
44 private:
45 SafePtr<CodeContext> context_;
46 };
47
48 class ForLoop : public CodeBlock {
49 public:
50 ForLoop(const SafePtr<CodeContext>& context, std::string& varname,
51 const SafePtr<Entity>& less_than, const SafePtr<Entity>& start_at);
52 virtual ~ForLoop();
53
55 std::string open() override;
57 std::string close() override;
58
59 private:
60 std::string varname_;
61 SafePtr<Entity> less_than_;
62 SafePtr<Entity> start_at_;
63
64 // checks less_than_ and start_at_ and initializes
65 // lt_expr_, sa_expr_, and dummy_loop_
66 void init_();
67 // string representations of less_than_ and start_at_
68 std::string lt_expr_;
69 std::string sa_expr_;
70 // dummy_loop_ is true if the loop is guaranteed to iterate once
71 // i.e. can replace the loop with a constant variable definition
72 bool dummy_loop_;
73
74 };
75
76};
77
78#endif
79
Definition: codeblock.h:31
virtual std::string close()=0
Close a code block.
virtual std::string open()=0
Opens a code block.
Definition: codeblock.h:48
std::string close() override
Implementation of CodeBlock::close()
Definition: codeblock.cc:94
std::string open() override
Implementation of CodeBlock::open()
Definition: codeblock.cc:76
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24