47#ifndef __SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
48#define __SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
66#if __cplusplus >= 201103L
69using std::remove_const;
75template<
bool Cond,
typename T=
void>
96template <
typename T,
typename U>
99 static const bool value =
false;
120template <
typename CT,
typename T>
142#define SC_RPTYPE_(Type) \
143 ::sc_gem5::remove_special_fptr< \
144 ::sc_gem5::special_result & (*) Type>::type::value
146#define SC_ENABLE_IF_(Cond) \
147 typename ::sc_gem5::enable_if<SC_RPTYPE_(Cond)>::type * = NULL
154template <
typename T,
typename MT>
155class sc_vector_assembly;
160template <
typename T,
typename MT>
171 virtual const char *
kind()
const {
return "sc_vector"; }
194 void reportEmpty(
const char *kind_,
bool empty_dest)
const;
203template <
typename Element>
218 template <
typename U>
234template <
typename Element,
typename Access>
238 template <
typename,
typename>
261template <
typename Element,
267 typedef typename AccessPolicy::Policy
Policy;
278 template <
typename,
typename>
280 template <
typename,
typename>
287 template <
typename U>
292 template <
typename U>
317 using pointer =
typename AccessPolicy::Type *;
322 template <
typename It>
451 template <
typename Creator>
455 init(_size, creator);
470 template <
typename Creator>
494 return *
static_cast<const T *
>(
objs[index]);
501 return *
static_cast<T *
>(
objs[index]);
507 return *
static_cast<const T *
>(
objs[index]);
517 template <
typename ContainerType,
typename ArgumentType>
521 return bind(
c.begin(),
c.end());
524 template <
typename BindableContainer>
528 return bind(
c.begin(),
c.end());
531 template <
typename BindableIterator>
533 bind(BindableIterator first, BindableIterator last)
538 template <
typename BindableIterator>
542 if (!
size() || from ==
end() || first == last)
545 while (from !=
end() && first != last)
546 (*from++).
bind(*first++);
550 template <
typename ContainerType,
typename ArgumentType>
554 return (*
this)(
c.begin(),
c.end());
557 template <
typename ArgumentContainer>
561 return (*
this)(
c.begin(),
c.end());
564 template <
typename ArgumentIterator>
568 return (*
this)(first, last, this->
begin());
571 template <
typename ArgumentIterator>
575 if (!
size() || from ==
end() || first == last)
578 while (from !=
end() && first != last)
592 delete static_cast<T *
>(obj);
595 template <
typename,
typename>
605template <
typename T,
typename MT>
654 sc_object *obj_ptr =
vec_->objectCast(
const_cast<MT *
>(&*it));
657 ret.push_back(obj_ptr);
684 template <
typename ContainerType,
typename ArgumentType>
688 return bind(
c.begin(),
c.end());
691 template <
typename BindableContainer>
695 return bind(
c.begin(),
c.end());
698 template <
typename BindableIterator>
700 bind(BindableIterator first, BindableIterator last)
705 template <
typename BindableIterator>
709 if (!
size() || from ==
end() || first == last)
710 vec_->reportEmpty(
"sc_vector_assembly", from ==
end());
712 while (from !=
end() && first != last)
713 (*from++).
bind(*first++);
717 template <
typename BindableIterator>
719 bind(BindableIterator first, BindableIterator last,
725 template <
typename ContainerType,
typename ArgumentType>
729 return (*
this)(
c.begin(),
c.end());
732 template <
typename ArgumentContainer>
736 return (*
this)(
c.begin(),
c.end());
739 template <
typename ArgumentIterator>
743 return (*
this)(first, last, this->
begin());
746 template <
typename ArgumentIterator>
750 if (!
size() || from ==
end() || first == last)
751 vec_->reportEmpty(
"sc_vector_assembly", from ==
end());
753 while (from !=
end() && first != last)
758 template <
typename ArgumentIterator>
775template <
typename T,
typename MT>
sc_direct_access(const U &, SC_ENABLE_IF_((sc_gem5::is_more_const< ElementType, typename U::Policy::ElementType >)))
sc_gem5::remove_const< ElementType >::type PlainType
sc_direct_access(const NonConstPolicy &)
sc_direct_access< ElementType > Policy
sc_direct_access< PlainType > NonConstPolicy
sc_direct_access< const PlainType > ConstPolicy
ElementType * get(ElementType *this_) const
AccessTypeElementType::* MemberType
sc_member_access(const NonConstPolicy &other)
sc_member_access< ElementType, AccessType > Policy
sc_member_access< PlainElemType, PlainType > NonConstPolicy
sc_gem5::remove_const< ElementType >::type PlainElemType
sc_member_access< const PlainElemType, const PlainType > ConstPolicy
sc_gem5::remove_const< AccessType >::type PlainType
sc_member_access(MemberType ptr)
AccessType * get(ElementType *this_) const
const char * name() const
const char * basename() const
iterator bind(sc_vector_assembly< ContainerType, ArgumentType > c)
const_iterator cbegin() const
iterator bind(BindableContainer &c)
iterator operator()(sc_vector_assembly< ContainerType, ArgumentType > c)
iterator bind(BindableIterator first, BindableIterator last, iterator from)
const_iterator cend() const
sc_vector_assembly(sc_vector< T > &v, MemberType ptr)
iterator bind(BindableIterator first, BindableIterator last, typename sc_vector< T >::iterator from)
sc_vector_iter< const T, sc_member_access< const T, const MT > > const_iterator
const_iterator end() const
iterator::reference operator[](size_type i)
friend sc_vector_assembly< T, MT > sc_assemble_vector(sc_vector< T > &, MT(T::*))
iterator::reference at(size_type i)
const_iterator::reference at(size_type i) const
iterator bind(BindableIterator first, BindableIterator last)
const_iterator begin() const
sc_vector_iter< T, sc_member_access< T, MT > > iterator
std::vector< sc_object * > get_elements() const
sc_vector_assembly(const sc_vector_assembly &other)
virtual sc_object * objectCast(void *) const =0
sc_vector_base(const char *_name)
void unforceParent() const
sc_object * implicitCast(sc_object *p) const
virtual const char * kind() const
void reportEmpty(const char *kind_, bool empty_dest) const
std::vector< void * > objs
void checkIndex(size_type index) const
const std::vector< sc_object * > & get_elements() const
std::vector< sc_object * > elements
sc_object * implicitCast(...) const
sc_vector_iter(const It &it, SC_ENABLE_IF_((sc_gem5::is_more_const< ElementType, typename It::Policy::ElementType >)))
const PlainType ConstPlainType
typename AccessPolicy::Type value_type
sc_vector_iter< ConstPlainType, ConstDirectPolicy > ConstDirectIterator
sc_vector< PlainType > VectorType
Policy const & get_policy() const
reference operator[](difference_type n) const
bool operator<(const ConstDirectIterator &other) const
std::random_access_iterator_tag iterator_category
bool operator>(const ConstDirectIterator &other) const
pointer operator->() const
std::vector< void * > StorageType
ThisType & operator-=(difference_type n)
SelectIter< ElementType >::type RawIterator
sc_vector_iter(RawIterator it, Policy acc=Policy())
AccessPolicy::Policy Policy
typename AccessPolicy::Type & reference
ThisType operator+(difference_type n) const
ThisType operator-(difference_type n) const
sc_gem5::remove_const< ElementType >::type PlainType
bool operator<=(const ConstDirectIterator &other) const
std::ptrdiff_t difference_type
ThisType & operator+=(difference_type n)
AccessPolicy::NonConstPolicy NonConstPolicy
bool operator>=(const ConstDirectIterator &other) const
bool operator!=(const ConstDirectIterator &other) const
sc_vector_iter< ConstPlainType, ConstPolicy > ConstIterator
sc_direct_access< PlainType >::ConstPolicy ConstDirectPolicy
AccessPolicy::ConstPolicy ConstPolicy
bool operator==(const ConstDirectIterator &other) const
typename AccessPolicy::Type * pointer
reference operator*() const
sc_vector(const char *_name, size_type _size, Creator creator)
iterator bind(BindableIterator first, BindableIterator last, iterator from)
sc_object * objectCast(void *ptr) const
iterator bind(sc_vector_assembly< ContainerType, ArgumentType > c)
sc_vector & operator=(const sc_vector &)
const_iterator cbegin() const
void init(size_type _size)
sc_vector(const char *_name, size_type _size)
static T * create_element(const char *_name, size_type index)
iterator bind(BindableContainer &c)
T & operator[](size_type index)
void init(size_type _size, Creator creator)
sc_vector_iter< T > iterator
const T & at(size_type index) const
iterator bind(BindableIterator first, BindableIterator last)
sc_vector_iter< const T > const_iterator
const_iterator end() const
const_iterator begin() const
const_iterator cend() const
sc_vector(const sc_vector &)
iterator operator()(sc_vector_assembly< ContainerType, ArgumentType > c)
sc_vector(const char *_name)
sc_vector_assembly< T, MT > sc_assemble_vector(sc_vector< T > &, MT(T::*member_ptr))
const char * sc_gen_unique_name(const char *seed)
#define SC_REPORT_ERROR(msg_type, msg)
#define SC_ENABLE_IF_(Cond)
std::vector< void * >::const_iterator type
std::vector< void * >::iterator type