LIBINT  2.1.0-stable
task.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 #ifndef _libint2_src_bin_libint_task_h_
21 #define _libint2_src_bin_libint_task_h_
22 
23 #include <string>
24 #include <vector>
25 #include <list>
26 #include <map>
27 #include <rr.h>
28 #include <default_params.h>
29 
30 namespace libint2 {
31 
32  class TaskExternSymbols;
33 
44  class LibraryTask {
45  public:
46  LibraryTask(const std::string& l, const SafePtr<TaskParameters>& p, const SafePtr<TaskExternSymbols>& s) :
47  label_(l), params_(p), symbols_(s) {
48  }
49  ~LibraryTask() {
50  }
51  const std::string& label() const { return label_; }
52  const SafePtr<TaskParameters>& params() const { return params_; }
53  const SafePtr<TaskExternSymbols>& symbols() const { return symbols_; }
54 
55  private:
56  std::string label_;
57  SafePtr<TaskParameters> params_;
58  SafePtr<TaskExternSymbols> symbols_;
59  };
60 
63  typedef std::vector<LibraryTask> Tasks;
64  typedef Tasks::const_iterator tasks_citer;
65 
66  public:
67  typedef Tasks::const_iterator TasksCIter;
68  typedef Tasks::iterator TasksIter;
69 
71  static LibraryTaskManager& Instance();
72  ~LibraryTaskManager() {}
73 
75  unsigned int ntask() const { return tasks_.size(); }
77  TasksCIter first() const { return tasks_.begin(); }
79  TasksCIter plast() const { return tasks_.end(); }
81  LibraryTask& task(unsigned int i) { return tasks_.at(i); }
83  void add(const std::string& task_label);
85  TasksCIter find(const std::string& task_label) const;
87  void current(const std::string& task_label);
89  LibraryTask& current();
90 
91  private:
92 
94  Tasks tasks_;
95  int current_;
96 
97  static LibraryTaskManager LTM_obj_;
98  };
99 
105  public:
106  typedef std::list<std::string> SymbolList;
108  typedef RRStack::InstanceID RRid;
109  typedef std::list<RRid> RRList;
110 
111  TaskExternSymbols() {}
112  ~TaskExternSymbols() {}
113 
115  void add(const SymbolList& symbols);
118  const SymbolList& symbols() const;
120  void add(const RRList& rrlist);
122  bool find(const RRid& rrid) const;
124  RRList rrlist() const;
125 
126  private:
127  // Maintain symbols as a map since each symbol only needs to appear once
128  typedef std::map<std::string,bool> Symbols;
129  Symbols symbols_;
130  mutable SymbolList symbollist_; // only used to return a list
131 
132  // Maintain RR list as a map, although RRStack already handles them that way -- hopefully this will speed up searching somewhat
133  typedef std::map<RRid,bool> RRmap;
134  RRmap rrmap_;
135 
136  };
137 
138 };
139 
140 #endif // header guard
TasksCIter first() const
returns iterator to the first task
Definition: task.h:77
RRStack::InstanceID RRid
Recurrence relations are maintained by RRStack and characterized by their unique numeric ID...
Definition: task.h:108
LibraryTask & task(unsigned int i)
i-th tasks
Definition: task.h:81
Manages tasks. This is a Singleton.
Definition: task.h:62
TasksCIter plast() const
returns iterator to past the last task
Definition: task.h:79
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:23
A key idea introduced here is that of "task".
Definition: task.h:44
unsigned int ntask() const
Number of tasks.
Definition: task.h:75
This class maintains code symbols provided by the user, e.g.
Definition: task.h:104