22 #include <smart_ptr.h> 24 #include <polyconstr.h> 25 #include <exception.h> 27 #ifndef _libint2_src_bin_libint_iter_h_ 28 #define _libint2_src_bin_libint_iter_h_ 49 virtual unsigned int num_iter()
const =0;
51 virtual void init() =0;
55 virtual operator int()
const =0;
76 typedef typename T::iter_type iter_type;
77 typedef Tr<T> TPolicy;
78 typedef typename TPolicy::obj_stype tref;
79 typedef typename TPolicy::subobj_stype iref;
86 const iref& elem()
const;
91 unsigned int num_iter()
const;
101 vector<iref> subobj_;
110 template <
class X>
void init_subobj();
111 template <
class X>
void delete_subobj();
113 void delete_subobj();
116 template <
typename X,
bool return_smart_ptr>
119 template <
typename X>
120 struct PElemImpl<X,true> {
121 static cp_rettype pelem(
const iref& elem) {
122 SafePtr<ConstructablePolymorphically> elem_cast = dynamic_pointer_cast<ConstructablePolymorphically,X>(elem);
123 return *(elem_cast.get());
126 template <
typename X>
127 struct PElemImpl<X,false> {
128 static cp_rettype pelem(
const iref& elem) {
135 template <
class T,
template <
class>
class P>
136 SubIteratorBase<T,P>::SubIteratorBase(
const tref& obj) :
137 obj_(obj), subobj_(0), iter_(0)
139 #ifdef ALLOW_PARTIALLY_SPECIALIZED_NESTED_TEMPLATES 146 template <
class T,
template <
class>
class P>
147 SubIteratorBase<T,P>::~SubIteratorBase()
149 #ifdef ALLOW_PARTIALLY_SPECIALIZED_NESTED_TEMPLATES 156 template <
class T,
template <
class>
class P>
160 return subobj_.size();
163 template <
class T,
template <
class>
class P>
164 const typename SubIteratorBase<T,P>::iref&
167 return subobj_.at(iter_);
170 template <
class T,
template <
class>
class P>
174 return PElemImpl<iter_type,detail::IsSafePtr<iref>::result>::pelem(elem());
178 template <
class T,
template <
class>
class P>
179 const SafePtr<ConstructablePolymorphically>
182 return dynamic_pointer_cast<ConstructablePolymorphically,iter_type>(elem());
186 template <
class T,
template <
class>
class P>
193 template <
class T,
template <
class>
class P>
201 template <
class T,
template <
class>
class P>
204 return (iter_ < num_iter()) ? 1 : 0;
207 template <
class T,
template <
class>
class P>
211 P<T>::init_subobj(obj_,subobj_);
214 template <
class T,
template <
class>
class P>
216 SubIteratorBase<T,P>::delete_subobj()
218 P<T>::dealloc_subobj(subobj_);
unsigned int num_iter() const
Returns a number of iterations (number of elements in a set over which to iterate).
Definition: iter.h:158
ConstructablePolymorphically is a base for all objects which can be constructed using a SafePtr to a ...
Definition: polyconstr.h:31
const ConstructablePolymorphically & cp_rettype
Return reference to ConstructablePolymorphically as object of this type.
Definition: iter.h:81
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
void init()
Initializes the iterator.
Definition: iter.h:188
SubIteratorBase<T> provides a base class for a sub-iterator class for T.
Definition: iter.h:73
SubIterator & operator++()
Iterates to the next element. Only prefix form is provided.
Definition: iter.h:195
Iterator provides a base class for all object iterator classes.
Definition: iter.h:45
const iref & elem() const
Returns current element.
Definition: iter.h:165
cp_rettype pelem() const
Returns current element. Implements SubIterator's pelem().
Definition: iter.h:172