LIBINT 2.9.0
task.h
1/*
2 * Copyright (C) 2004-2024 Edward F. Valeev
3 *
4 * This file is part of Libint compiler.
5 *
6 * Libint compiler 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 compiler 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 compiler. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#ifndef _libint2_src_bin_libint_task_h_
22#define _libint2_src_bin_libint_task_h_
23
24#include <default_params.h>
25#include <rr.h>
26
27#include <list>
28#include <map>
29#include <string>
30#include <vector>
31
32namespace libint2 {
33
34class TaskExternSymbols;
35
49 public:
50 LibraryTask(const std::string& l, const std::shared_ptr<TaskParameters>& p,
51 const std::shared_ptr<TaskExternSymbols>& s)
52 : label_(l), params_(p), symbols_(s) {}
53 ~LibraryTask() {}
54 const std::string& label() const { return label_; }
55 const std::shared_ptr<TaskParameters>& params() const { return params_; }
56 const std::shared_ptr<TaskExternSymbols>& symbols() const { return symbols_; }
57
58 private:
59 std::string label_;
60 std::shared_ptr<TaskParameters> params_;
61 std::shared_ptr<TaskExternSymbols> symbols_;
62};
63
66 typedef std::vector<LibraryTask> Tasks;
67 typedef Tasks::const_iterator tasks_citer;
68
69 public:
70 typedef Tasks::const_iterator TasksCIter;
71 typedef Tasks::iterator TasksIter;
72
76
78 unsigned int ntask() const { return tasks_.size(); }
80 TasksCIter first() const { return tasks_.begin(); }
82 TasksCIter plast() const { return tasks_.end(); }
84 LibraryTask& task(unsigned int i) { return tasks_.at(i); }
86 void add(const std::string& task_label);
88 bool exists(const std::string& task_label) const;
91 TasksCIter find(const std::string& task_label) const;
93 void current(const std::string& task_label);
96
97 private:
99 Tasks tasks_;
100 int current_;
101
102 static LibraryTaskManager LTM_obj_;
103};
104
112 public:
113 typedef std::list<std::string> SymbolList;
116 typedef RRStack::InstanceID RRid;
117 typedef std::list<RRid> RRList;
118
121
123 void add(const SymbolList& symbols);
126 const SymbolList& symbols() const;
128 void add(const RRList& rrlist);
130 bool find(const RRid& rrid) const;
132 RRList rrlist() const;
133
134 private:
135 // Maintain symbols as a map since each symbol only needs to appear once
136 typedef std::map<std::string, bool> Symbols;
137 Symbols symbols_;
138 mutable SymbolList symbollist_; // only used to return a list
139
140 // Maintain RR list as a map, although RRStack already handles them that way
141 // -- hopefully this will speed up searching somewhat
142 typedef std::map<RRid, bool> RRmap;
143 RRmap rrmap_;
144};
145
146}; // namespace libint2
147
148#endif // header guard
Manages tasks. This is a Singleton.
Definition task.h:65
TasksCIter find(const std::string &task_label) const
Find the task by name and return the iterator pointing to it.
Definition task.cc:54
TasksCIter first() const
returns iterator to the first task
Definition task.h:80
TasksCIter plast() const
returns iterator to past the last task
Definition task.h:82
bool exists(const std::string &task_label) const
Definition task.cc:46
void add(const std::string &task_label)
Adds a new task. Do nothing if the task exists already.
Definition task.cc:34
static LibraryTaskManager & Instance()
LibraryTaskManager is a Singleton.
Definition task.cc:32
LibraryTask & task(unsigned int i)
i-th tasks
Definition task.h:84
unsigned int ntask() const
Number of tasks.
Definition task.h:78
LibraryTask & current()
Returns the current task.
Definition task.cc:74
A key idea introduced here is that of "task".
Definition task.h:48
This class maintains code symbols provided by the user, e.g.
Definition task.h:111
RRStack::InstanceID RRid
Recurrence relations are maintained by RRStack and characterized by their unique numeric ID.
Definition task.h:116
bool find(const RRid &rrid) const
Is this RR found in the list?
Definition task.cc:111
const SymbolList & symbols() const
Return the symbols.
Definition task.cc:100
RRList rrlist() const
Definition task.cc:117
void add(const SymbolList &symbols)
Add the symbols.
Definition task.cc:84
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24