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