47 #ifndef __SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
48 #define __SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
56 #include "../core/sc_module.hh"
57 #include "../core/sc_object.hh"
65 #if __cplusplus >= 201103L
68 using std::remove_const;
74 template<
bool Cond,
typename T=
void>
95 template <
typename T,
typename U>
98 static const bool value =
false;
100 template <
typename T>
106 template <
typename T>
111 template <
typename T>
119 template <
typename CT,
typename T>
131 template <
typename T>
135 template <
typename T>
141 #define SC_RPTYPE_(Type) \
142 ::sc_gem5::remove_special_fptr< \
143 ::sc_gem5::special_result & (*) Type>::type::value
145 #define SC_ENABLE_IF_(Cond) \
146 typename ::sc_gem5::enable_if<SC_RPTYPE_(Cond)>::type * = NULL
153 template <
typename T,
typename MT>
154 class sc_vector_assembly;
156 template <
typename T>
159 template <
typename T,
typename MT>
170 virtual const char *
kind()
const {
return "sc_vector"; }
193 void reportEmpty(
const char *kind_,
bool empty_dest)
const;
202 template <
typename Element>
217 template <
typename U>
233 template <
typename Element,
typename Access>
237 template <
typename,
typename>
260 template <
typename Element,
263 public std::iterator<std::random_access_iterator_tag,
264 typename AccessPolicy::Type>,
269 typedef typename AccessPolicy::Policy
Policy;
280 template <
typename,
typename>
282 template <
typename,
typename>
285 typedef std::iterator<std::random_access_iterator_tag, AccessType>
291 template <
typename U>
296 template <
typename U>
324 template <
typename It>
439 template <
typename T>
453 template <
typename Creator>
457 init(_size, creator);
472 template <
typename Creator>
496 return *
static_cast<const T *
>(
objs[
index]);
509 return *
static_cast<const T *
>(
objs[
index]);
519 template <
typename ContainerType,
typename ArgumentType>
523 return bind(
c.begin(),
c.end());
526 template <
typename BindableContainer>
530 return bind(
c.begin(),
c.end());
533 template <
typename BindableIterator>
535 bind(BindableIterator first, BindableIterator last)
540 template <
typename BindableIterator>
544 if (!
size() || from ==
end() || first == last)
547 while (from !=
end() && first != last)
548 (*from++).
bind(*first++);
552 template <
typename ContainerType,
typename ArgumentType>
556 return (*
this)(
c.begin(),
c.end());
559 template <
typename ArgumentContainer>
563 return (*
this)(
c.begin(),
c.end());
566 template <
typename ArgumentIterator>
570 return (*
this)(first, last, this->
begin());
573 template <
typename ArgumentIterator>
577 if (!
size() || from ==
end() || first == last)
580 while (from !=
end() && first != last)
594 delete static_cast<T *
>(obj);
597 template <
typename,
typename>
607 template <
typename T,
typename MT>
656 sc_object *obj_ptr =
vec_->objectCast(
const_cast<MT *
>(&*it));
659 ret.push_back(obj_ptr);
686 template <
typename ContainerType,
typename ArgumentType>
690 return bind(
c.begin(),
c.end());
693 template <
typename BindableContainer>
697 return bind(
c.begin(),
c.end());
700 template <
typename BindableIterator>
702 bind(BindableIterator first, BindableIterator last)
707 template <
typename BindableIterator>
711 if (!
size() || from ==
end() || first == last)
712 vec_->reportEmpty(
"sc_vector_assembly", from ==
end());
714 while (from !=
end() && first != last)
715 (*from++).
bind(*first++);
719 template <
typename BindableIterator>
721 bind(BindableIterator first, BindableIterator last,
727 template <
typename ContainerType,
typename ArgumentType>
731 return (*
this)(
c.begin(),
c.end());
734 template <
typename ArgumentContainer>
738 return (*
this)(
c.begin(),
c.end());
741 template <
typename ArgumentIterator>
745 return (*
this)(first, last, this->
begin());
748 template <
typename ArgumentIterator>
752 if (!
size() || from ==
end() || first == last)
753 vec_->reportEmpty(
"sc_vector_assembly", from ==
end());
755 while (from !=
end() && first != last)
760 template <
typename ArgumentIterator>
777 template <
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
ElementType * get(ElementType *this_) const
sc_direct_access< PlainType > NonConstPolicy
sc_direct_access< const PlainType > ConstPolicy
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)
iterator::reference at(size_type i)
const_iterator::reference at(size_type i) const
std::vector< sc_object * > get_elements() const
iterator bind(BindableIterator first, BindableIterator last)
const_iterator begin() const
sc_vector_iter< T, sc_member_access< T, MT > > iterator
sc_vector_assembly(const sc_vector_assembly &other)
sc_object * implicitCast(...) const
virtual sc_object * objectCast(void *) const =0
sc_vector_base(const char *_name)
void unforceParent() 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
sc_object * implicitCast(sc_object *p) const
std::vector< sc_object * > elements
virtual const char * kind() const
sc_vector_iter(const It &it, SC_ENABLE_IF_((sc_gem5::is_more_const< ElementType, typename It::Policy::ElementType >)))
const PlainType ConstPlainType
BaseType::reference reference
sc_vector_iter< ConstPlainType, ConstDirectPolicy > ConstDirectIterator
sc_vector< PlainType > VectorType
reference operator[](difference_type n) const
bool operator<(const ConstDirectIterator &other) const
bool operator>(const ConstDirectIterator &other) const
std::iterator< std::random_access_iterator_tag, AccessType > BaseType
pointer operator->() const
BaseType::difference_type difference_type
std::vector< void * > StorageType
SelectIter< ElementType >::type RawIterator
sc_vector_iter(RawIterator it, Policy acc=Policy())
AccessPolicy::Policy Policy
ThisType operator+(difference_type n) const
ThisType & operator-=(difference_type n)
ThisType operator-(difference_type n) const
sc_gem5::remove_const< ElementType >::type PlainType
bool operator<=(const ConstDirectIterator &other) const
AccessPolicy::NonConstPolicy NonConstPolicy
bool operator>=(const ConstDirectIterator &other) const
bool operator!=(const ConstDirectIterator &other) const
Policy const & get_policy() const
BaseType::pointer pointer
sc_vector_iter< ConstPlainType, ConstPolicy > ConstIterator
ThisType & operator+=(difference_type n)
sc_direct_access< PlainType >::ConstPolicy ConstDirectPolicy
AccessPolicy::ConstPolicy ConstPolicy
bool operator==(const ConstDirectIterator &other) const
reference operator*() const
sc_vector & operator=(const sc_vector &)
sc_vector(const char *_name, size_type _size, Creator creator)
iterator bind(BindableIterator first, BindableIterator last, iterator from)
iterator bind(sc_vector_assembly< ContainerType, ArgumentType > c)
static T * create_element(const char *_name, size_type index)
const_iterator cbegin() const
void init(size_type _size)
sc_vector(const char *_name, size_type _size)
sc_object * objectCast(void *ptr) const
iterator bind(BindableContainer &c)
const T & at(size_type index) const
void init(size_type _size, Creator creator)
sc_vector_iter< T > iterator
T & operator[](size_type index)
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)
const char SC_ID_VECTOR_NONOBJECT_ELEMENTS_[]
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