LIBINT  2.6.0
codeblock.h
1 /*
2  * Copyright (C) 2004-2019 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 
27 using namespace std;
28 
29 namespace libint2 {
30 
31  class CodeContext;
32 
33  class CodeBlock {
34  public:
35  CodeBlock(const SafePtr<CodeContext>& context) :
36  context_(context) {}
37  virtual ~CodeBlock() {}
38 
39  SafePtr<CodeContext> context() const { return context_; }
40 
42  virtual std::string open() =0;
44  virtual std::string close() =0;
45 
46  private:
47  SafePtr<CodeContext> context_;
48  };
49 
50  class ForLoop : public CodeBlock {
51  public:
52  ForLoop(const SafePtr<CodeContext>& context, std::string& varname,
53  const SafePtr<Entity>& less_than, const SafePtr<Entity>& start_at);
54  virtual ~ForLoop();
55 
57  std::string open();
59  std::string close();
60 
61  private:
62  std::string varname_;
63  SafePtr<Entity> less_than_;
64  SafePtr<Entity> start_at_;
65 
66  // checks less_than_ and start_at_ and initializes
67  // lt_expr_, sa_expr_, and dummy_loop_
68  void init_();
69  // string representations of less_than_ and start_at_
70  std::string lt_expr_;
71  std::string sa_expr_;
72  // dummy_loop_ is true if the loop is guaranteed to iterate once
73  // i.e. can replace the loop with a constant variable definition
74  bool dummy_loop_;
75 
76  };
77 
78 };
79 
80 #endif
81 
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
Definition: codeblock.h:33
Definition: codeblock.h:50