23#include <polyconstr.h>
28#ifndef _libint2_src_bin_libint_iter_h_
29#define _libint2_src_bin_libint_iter_h_
53 virtual operator int()
const = 0;
72template <
class T,
template <
class>
class Tr = Policy>
75 typedef typename T::iter_type iter_type;
76 typedef Tr<T> TPolicy;
77 typedef typename TPolicy::obj_stype tref;
78 typedef typename TPolicy::subobj_stype iref;
85 const iref&
elem()
const;
91 unsigned int num_iter()
const override;
98 operator int()
const override;
102 std::vector<iref> subobj_;
115 void delete_subobj();
117 void delete_subobj();
120 template <
typename X,
bool return_smart_ptr>
122 template <
typename X>
123 struct PElemImpl<X, true> {
125 std::shared_ptr<ConstructablePolymorphically> elem_cast =
126 std::dynamic_pointer_cast<ConstructablePolymorphically, X>(
elem);
127 return *(elem_cast.get());
130 template <
typename X>
131 struct PElemImpl<X, false> {
136template <
class T,
template <
class>
class P>
137SubIteratorBase<T, P>::SubIteratorBase(
const tref& obj)
138 : obj_(obj), subobj_(0), iter_(0) {
139#ifdef ALLOW_PARTIALLY_SPECIALIZED_NESTED_TEMPLATES
146template <
class T,
template <
class>
class P>
147SubIteratorBase<T, P>::~SubIteratorBase() {
148#ifdef ALLOW_PARTIALLY_SPECIALIZED_NESTED_TEMPLATES
155template <
class T,
template <
class>
class P>
157 return subobj_.size();
160template <
class T,
template <
class>
class P>
163 return subobj_.at(iter_);
166template <
class T,
template <
class>
class P>
169 return PElemImpl<iter_type, detail::IsSharedPtr<iref>::value>::pelem(elem());
173 template <
class T,
template <
class>
class P>
174 const std::shared_ptr<ConstructablePolymorphically>
177 return std::dynamic_pointer_cast<ConstructablePolymorphically,iter_type>(elem());
181template <
class T,
template <
class>
class P>
186template <
class T,
template <
class>
class P>
192template <
class T,
template <
class>
class P>
194 return (iter_ < num_iter()) ? 1 : 0;
197template <
class T,
template <
class>
class P>
199 P<T>::init_subobj(obj_, subobj_);
202template <
class T,
template <
class>
class P>
203void SubIteratorBase<T, P>::delete_subobj() {
204 P<T>::dealloc_subobj(subobj_);
ConstructablePolymorphically is a base for all objects which can be constructed using a std::shared_p...
Definition polyconstr.h:30
SubIteratorBase<T> provides a base class for a sub-iterator class for T.
Definition iter.h:73
void init() override
Initializes the iterator.
Definition iter.h:182
cp_rettype pelem() const override
Returns current element. Implements SubIterator's pelem().
Definition iter.h:167
const ConstructablePolymorphically & cp_rettype
Return reference to ConstructablePolymorphically as object of this type.
Definition iter.h:80
const iref & elem() const
Returns current element.
Definition iter.h:161
unsigned int num_iter() const override
Returns a number of iterations (number of elements in a set over which to iterate).
Definition iter.h:156
SubIterator & operator++() override
Iterates to the next element. Only prefix form is provided.
Definition iter.h:187
Iterator provides a base class for all object iterator classes.
Definition iter.h:43
virtual const ConstructablePolymorphically & pelem() const
Return current element via base class.
Definition iter.cc:33
virtual SubIterator & operator++()=0
Iterates to the next element. Only prefix form is provided.
virtual unsigned int num_iter() const =0
Returns a number of iterations (number of elements in a set over which to iterate).
virtual void init()=0
Initializes the iterator.
Defaults definitions for various parameters assumed by Libint.
Definition algebra.cc:24