LIBINT 2.9.0
purgeable.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_purgeable_h_
22#define _libint2_src_bin_libint_purgeable_h_
23
24#include <dgvertex.h>
25
26#include <boost/type_traits.hpp>
27#include <vector>
28
29namespace libint2 {
30
34template <typename T>
37 static bool purgeable() {
38 bool result = false;
39
40 if (boost::is_base_of<DGVertex,
41 T>::value) { // can only purge DGVertex objects
42 result = true;
43 }
44
45 return result;
46 }
47
49 static bool purge(const T* ref) {
50 bool result = false;
51
52 try {
53 const DGVertex* dgv_ptr = dynamic_cast<const DGVertex*>(ref);
54 if (dgv_ptr->dg() == 0) result = true;
55 } catch (...) {
56 }
57
58 return result;
59 }
60};
61
66 public:
67 virtual ~AbstractPurgeableStack() {}
68 virtual void purge() = 0;
69};
70
75template <typename T, typename Policy = DefaultPurgingPolicy<T> >
77 protected:
78 typedef Policy PurgingPolicy;
79
80 virtual ~PurgeableStack() {}
81};
82
85 public:
88
89 static this_type* Instance();
90
91 void purge();
92 void register_stack(stack_type* stack);
93
94 private:
96 static this_type* instance_;
97 std::vector<stack_type*> stacks_;
98};
99
100}; // namespace libint2
101
102#endif
PurgeableStack is a container that can be purged by calling purge() method.
Definition purgeable.h:65
This is a vertex of a Directed Graph (DG)
Definition dgvertex.h:44
const DirectedGraph * dg() const
Returns pointer to the DirectedGraph to which this DGVertex belongs to.
Definition dgvertex.h:167
PurgeableStack is an AbstractPurgeableStack that contains objects of type T.
Definition purgeable.h:76
Collection of AbstractPurgeableStack objects.
Definition purgeable.h:84
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24
Determines whether an object should be purged from a stack.
Definition purgeable.h:35
static bool purge(const T *ref)
returns true if obj should be purged
Definition purgeable.h:49
static bool purgeable()
returns true if objects of this type can be purged
Definition purgeable.h:37