1 #ifndef CASM_RandomAccessEnumerator
2 #define CASM_RandomAccessEnumerator
11 template <
typename ValueType,
bool IsConst>
12 class RandomAccessEnumIterator;
14 template <
typename ValueType,
bool IsConst>
15 class RandomAccessEnumeratorBase;
17 template <
typename ValueType,
bool IsConst>
18 class RandomAccessEnumerator;
30 template <
typename ValueType,
bool IsConst = true>
71 std::unique_ptr<RandomAccessEnumIteratorBase>
clone()
const {
72 return std::unique_ptr<RandomAccessEnumIteratorBase>(this->
_clone());
83 return _enum().current();
122 template <
typename ValueType,
bool IsConst = true>
125 public boost::iterator_facade<RandomAccessEnumIterator<ValueType, IsConst>,
126 ValueType, boost::random_access_traversal_tag,
127 CASM_TMP::ConstSwitch<IsConst, ValueType> &,
151 std::unique_ptr<RandomAccessEnumIterator>
clone()
const {
152 return std::unique_ptr<RandomAccessEnumIterator>(this->
_clone());
156 friend boost::iterator_core_access;
250 template <
typename ValueType,
bool IsConst = true>
337 if (this->
step() == n) {
341 if (n >= 0 && n < this->
size()) {
359 template <
typename ValueType,
bool IsConst = true>
376 :
ptr(e.release()) {}
401 std::string
name()
const {
return ptr->name(); }
403 std::unique_ptr<RandomAccessEnumeratorBase<ValueType, IsConst> >
ptr;
EnumeratorBase::step_type step_type
void _validate()
Used if random access enumerator step is moved into valid range.
RandomAccessEnumIterator implemenation.
void decrement()
boost::iterator_facade implementation
RandomAccessEnumIteratorBase()
difference_type distance_to(const RandomAccessEnumIteratorBase &B) const
boost::iterator_facade implementation
step_type step() const override
RandomAccessEnumeratorBase< ValueType, IsConst > & _enum() const
static_cast enumerator pointer to RandomAccessEnumeratorBase&
bool is_end() const override
void increment() override
boost::iterator_facade implementation
void advance(step_type n)
boost::iterator_facade implementation
reference dereference() const override
boost::iterator_facade implementation
std::unique_ptr< RandomAccessEnumIteratorBase > clone() const
RandomAccessEnumIteratorBase(RandomAccessEnumeratorBase< ValueType, IsConst > &enumerator, bool is_end)
step_type difference_type
RandomAccessEnumIteratorBase< ValueType, IsConst > * _clone() const override
clone implementation
RandomAccessEnumeratorBase< ValueType, IsConst > & _enum()
static_cast enumerator pointer to RandomAccessEnumeratorBase&
The iterator type for RandomAccessEnumerator.
notstd::cloneable_ptr< RandomAccessEnumIteratorBase< ValueType, IsConst > > m_ptr
void advance(step_type n)
std::unique_ptr< RandomAccessEnumIterator > clone() const
bool equal(const RandomAccessEnumIterator &B) const
boost::iterator_facade implementation
reference dereference() const
RandomAccessEnumIterator(const RandomAccessEnumIteratorBase< ValueType, IsConst > &it)
Construct iterator.
jsonParser source() const
RandomAccessEnumIteratorBase< ValueType, IsConst >::step_type step_type
RandomAccessEnumIterator()
Default constructor.
RandomAccessEnumIterator * _clone() const
clone implementation
RandomAccessEnumIteratorBase< ValueType, IsConst >::reference reference
step_type difference_type
difference_type distance_to(const RandomAccessEnumIterator &B) const
Base class for implementing specialized random access enumerators.
reference front()
Reference to first element in enumerator.
reference operator[](size_type n)
Reference an element in enumerator.
RandomAccessEnumIterator< ValueType, IsConst > iterator
virtual ~RandomAccessEnumeratorBase()
std::reverse_iterator< iterator > reverse_iterator
void _set_size(size_type val)
Set size value.
reverse_iterator rbegin()
friend RandomAccessEnumIteratorBase< ValueType, IsConst >
virtual CASM_TMP::ConstSwitch< IsConst, value_type > * at_step(step_type n)=0
void goto_step(step_type n)
size_type size() const
Number of elements in enumerator.
reference initial()
Reference to first element in enumerator.
void increment() override
RandomAccessEnumeratorBase(size_type size=0)
reference back()
Reference to last element in enumerator.
Generic random access enumerator.
bool valid() const
Returns false if enumeration is complete.
std::unique_ptr< RandomAccessEnumeratorBase< ValueType, IsConst > > ptr
RandomAccessEnumerator(std::unique_ptr< RandomAccessEnumeratorBase< ValueType, IsConst > > e)
reverse_iterator rbegin()
RandomAccessEnumerator(const RandomAccessEnumerator &)=delete
RandomAccessEnumeratorBase< ValueType, IsConst >::size_type size_type
RandomAccessEnumeratorBase< ValueType, IsConst >::step_type step_type
RandomAccessEnumeratorBase< ValueType, IsConst >::reference reference
std::reverse_iterator< iterator > reverse_iterator
reference current() const
Access the current ObjectType by reference.
std::string name() const
Derived enumerators must implement name.
RandomAccessEnumerator & operator=(const RandomAccessEnumerator &)=delete
jsonParser source(step_type step) const
step_type step() const
Increments with each enumerated object.
RandomAccessEnumIterator< ValueType, IsConst > iterator
EnumeratorBase * _enum_ptr()
ValEnumerator< ValueType, IsConst >::reference reference
void _set_current_ptr(CASM_TMP::ConstSwitch< IsConst, value_type > *_new)
Change the pointer.
reference current() const
Access the current ObjectType by reference.
void _invalidate()
Call if enumeration complete.
step_type step() const
Increments with each enumerated object.
CASM_TMP::ConstSwitch< IsConst, ValueType > & reference
void _set_step(step_type val)
Set current step value.
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
typename std::conditional< IsConst, const T, T >::type ConstSwitch
Non-std smart pointer classes and functions.