sc_vector.hh revision 12872
112852Sgabeblack@google.com/*
212852Sgabeblack@google.com * Copyright 2018 Google, Inc.
312852Sgabeblack@google.com *
412852Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512852Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612852Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712852Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812852Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912852Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012852Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112852Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212852Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312852Sgabeblack@google.com * this software without specific prior written permission.
1412852Sgabeblack@google.com *
1512852Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612852Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712852Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812852Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912852Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012852Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112852Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212852Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312852Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412852Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512852Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612852Sgabeblack@google.com *
2712852Sgabeblack@google.com * Authors: Gabe Black
2812852Sgabeblack@google.com */
2912852Sgabeblack@google.com
3012852Sgabeblack@google.com#ifndef __SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
3112852Sgabeblack@google.com#define __SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
3212852Sgabeblack@google.com
3312852Sgabeblack@google.com#include <stdint.h>
3412852Sgabeblack@google.com
3512852Sgabeblack@google.com#include <exception>
3612872Sgabeblack@google.com#include <iterator>
3712852Sgabeblack@google.com#include <vector>
3812852Sgabeblack@google.com
3912852Sgabeblack@google.com#include "../core/sc_object.hh"
4012852Sgabeblack@google.com#include "warn_unimpl.hh"
4112852Sgabeblack@google.com
4212872Sgabeblack@google.comnamespace sc_gem5
4312872Sgabeblack@google.com{
4412872Sgabeblack@google.com
4512872Sgabeblack@google.com// Goop for supporting sc_vector_iter, simplified from the Accellera version.
4612872Sgabeblack@google.com
4712872Sgabeblack@google.com#if __cplusplus >= 201103L
4812872Sgabeblack@google.com
4912872Sgabeblack@google.comusing std::enable_if;
5012872Sgabeblack@google.comusing std::remove_const;
5112872Sgabeblack@google.comusing std::is_same;
5212872Sgabeblack@google.comusing std::is_const;
5312872Sgabeblack@google.com
5412872Sgabeblack@google.com#else
5512872Sgabeblack@google.com
5612872Sgabeblack@google.comtemplate<bool Cond, typename T=void>
5712872Sgabeblack@google.comstruct enable_if
5812872Sgabeblack@google.com{};
5912872Sgabeblack@google.com
6012872Sgabeblack@google.comtemplate<typename T>
6112872Sgabeblack@google.comstruct enable_if<true, T>
6212872Sgabeblack@google.com{
6312872Sgabeblack@google.com    typedef T type;
6412872Sgabeblack@google.com};
6512872Sgabeblack@google.com
6612872Sgabeblack@google.comtemplate <typename T>
6712872Sgabeblack@google.comstruct remove_const
6812872Sgabeblack@google.com{
6912872Sgabeblack@google.com    typedef T type;
7012872Sgabeblack@google.com};
7112872Sgabeblack@google.comtemplate <typename T>
7212872Sgabeblack@google.comstruct remove_const<const T>
7312872Sgabeblack@google.com{
7412872Sgabeblack@google.com    typedef T type;
7512872Sgabeblack@google.com};
7612872Sgabeblack@google.com
7712872Sgabeblack@google.comtemplate <typename T, typename U>
7812872Sgabeblack@google.comstruct is_same
7912872Sgabeblack@google.com{
8012872Sgabeblack@google.com    static const bool value = false;
8112872Sgabeblack@google.com};
8212872Sgabeblack@google.comtemplate <typename T>
8312872Sgabeblack@google.comstruct is_same<T, T>
8412872Sgabeblack@google.com{
8512872Sgabeblack@google.com    static const bool value = true;
8612872Sgabeblack@google.com};
8712872Sgabeblack@google.com
8812872Sgabeblack@google.comtemplate <typename T>
8912872Sgabeblack@google.comstruct is_const
9012872Sgabeblack@google.com{
9112872Sgabeblack@google.com    static const bool value = false;
9212872Sgabeblack@google.com};
9312872Sgabeblack@google.comtemplate <typename T>
9412872Sgabeblack@google.comstruct is_const<const T>
9512872Sgabeblack@google.com{
9612872Sgabeblack@google.com    static const bool value = true;
9712872Sgabeblack@google.com};
9812872Sgabeblack@google.com
9912872Sgabeblack@google.com#endif
10012872Sgabeblack@google.com
10112872Sgabeblack@google.comtemplate <typename CT, typename T>
10212872Sgabeblack@google.comstruct is_more_const
10312872Sgabeblack@google.com{
10412872Sgabeblack@google.com    static const bool value =
10512872Sgabeblack@google.com        is_same<typename remove_const<CT>::type,
10612872Sgabeblack@google.com                typename remove_const<T>::type>::value &&
10712872Sgabeblack@google.com        is_const<CT>::value >= is_const<T>::value;
10812872Sgabeblack@google.com};
10912872Sgabeblack@google.com
11012872Sgabeblack@google.comstruct special_result
11112872Sgabeblack@google.com{};
11212872Sgabeblack@google.com
11312872Sgabeblack@google.comtemplate <typename T>
11412872Sgabeblack@google.comstruct remove_special_fptr
11512872Sgabeblack@google.com{};
11612872Sgabeblack@google.com
11712872Sgabeblack@google.comtemplate <typename T>
11812872Sgabeblack@google.comstruct remove_special_fptr<special_result & (*)(T)>
11912872Sgabeblack@google.com{
12012872Sgabeblack@google.com    typedef T type;
12112872Sgabeblack@google.com};
12212872Sgabeblack@google.com
12312872Sgabeblack@google.com#define SC_RPTYPE_(Type) \
12412872Sgabeblack@google.com    ::sc_gem5::remove_special_fptr< \
12512872Sgabeblack@google.com        ::sc_gem5::special_result & (*) Type>::type::value
12612872Sgabeblack@google.com
12712872Sgabeblack@google.com#define SC_ENABLE_IF_(Cond) \
12812872Sgabeblack@google.com    typename ::sc_gem5::enable_if<SC_RPTYPE_(Cond)>::type * = NULL
12912872Sgabeblack@google.com
13012872Sgabeblack@google.com} // namespace sc_gem5
13112872Sgabeblack@google.com
13212852Sgabeblack@google.comnamespace sc_core
13312852Sgabeblack@google.com{
13412852Sgabeblack@google.com
13512852Sgabeblack@google.comtemplate <typename T, typename MT>
13612852Sgabeblack@google.comclass sc_vector_assembly;
13712852Sgabeblack@google.com
13812852Sgabeblack@google.comtemplate <typename T>
13912852Sgabeblack@google.comclass sc_vector;
14012852Sgabeblack@google.com
14112852Sgabeblack@google.comtemplate <typename T, typename MT>
14212852Sgabeblack@google.comsc_vector_assembly<T, MT> sc_assemble_vector(
14312852Sgabeblack@google.com        sc_vector<T> &, MT(T::* member_ptr));
14412852Sgabeblack@google.com
14512852Sgabeblack@google.comclass sc_vector_base : public sc_object
14612852Sgabeblack@google.com{
14712852Sgabeblack@google.com  public:
14812852Sgabeblack@google.com    typedef size_t size_type;
14912852Sgabeblack@google.com
15012852Sgabeblack@google.com    virtual const char *kind() const { return "sc_vector"; }
15112852Sgabeblack@google.com    size_type size() const;
15212852Sgabeblack@google.com    const std::vector<sc_object *> &get_elements() const;
15312852Sgabeblack@google.com};
15412852Sgabeblack@google.com
15512872Sgabeblack@google.com
15612872Sgabeblack@google.com/*
15712872Sgabeblack@google.com * Non-standard iterator access adapters. Without using these, the classes as
15812872Sgabeblack@google.com * defined in the standard won't compile because of redundant bind() overloads.
15912872Sgabeblack@google.com */
16012872Sgabeblack@google.com
16112872Sgabeblack@google.comtemplate <typename Element>
16212872Sgabeblack@google.comclass sc_direct_access
16312872Sgabeblack@google.com{
16412872Sgabeblack@google.com  public:
16512872Sgabeblack@google.com    typedef Element ElementType;
16612872Sgabeblack@google.com    typedef ElementType Type;
16712872Sgabeblack@google.com    typedef typename sc_gem5::remove_const<ElementType>::type PlainType;
16812872Sgabeblack@google.com
16912872Sgabeblack@google.com    typedef sc_direct_access<ElementType> Policy;
17012872Sgabeblack@google.com    typedef sc_direct_access<PlainType> NonConstPolicy;
17112872Sgabeblack@google.com    typedef sc_direct_access<const PlainType> ConstPolicy;
17212872Sgabeblack@google.com
17312872Sgabeblack@google.com    sc_direct_access() {}
17412872Sgabeblack@google.com    sc_direct_access(const NonConstPolicy &) {}
17512872Sgabeblack@google.com
17612872Sgabeblack@google.com    template <typename U>
17712872Sgabeblack@google.com    sc_direct_access(const U &,
17812872Sgabeblack@google.com        SC_ENABLE_IF_((
17912872Sgabeblack@google.com            sc_gem5::is_more_const<
18012872Sgabeblack@google.com                    ElementType, typename U::Policy::ElementType>
18112872Sgabeblack@google.com        ))
18212872Sgabeblack@google.com    )
18312872Sgabeblack@google.com    {}
18412872Sgabeblack@google.com
18512872Sgabeblack@google.com    ElementType *
18612872Sgabeblack@google.com    get(ElementType *this_) const
18712872Sgabeblack@google.com    {
18812872Sgabeblack@google.com        return this_;
18912872Sgabeblack@google.com    }
19012872Sgabeblack@google.com};
19112872Sgabeblack@google.com
19212872Sgabeblack@google.comtemplate <typename Element, typename Access>
19312872Sgabeblack@google.comclass sc_member_access
19412872Sgabeblack@google.com{
19512872Sgabeblack@google.com  public:
19612872Sgabeblack@google.com    template <typename, typename>
19712872Sgabeblack@google.com    friend class sc_member_access;
19812872Sgabeblack@google.com
19912872Sgabeblack@google.com    typedef Element ElementType;
20012872Sgabeblack@google.com    typedef Access AccessType;
20112872Sgabeblack@google.com    typedef AccessType (ElementType::*MemberType);
20212872Sgabeblack@google.com    typedef AccessType Type;
20312872Sgabeblack@google.com    typedef typename sc_gem5::remove_const<AccessType>::type PlainType;
20412872Sgabeblack@google.com    typedef typename sc_gem5::remove_const<ElementType>::type PlainElemType;
20512872Sgabeblack@google.com
20612872Sgabeblack@google.com    typedef sc_member_access<ElementType, AccessType> Policy;
20712872Sgabeblack@google.com    typedef sc_member_access<PlainElemType, PlainType> NonConstPolicy;
20812872Sgabeblack@google.com    typedef sc_member_access<const PlainElemType, const PlainType> ConstPolicy;
20912872Sgabeblack@google.com
21012872Sgabeblack@google.com    sc_member_access(MemberType ptr) : ptr_(ptr) {}
21112872Sgabeblack@google.com    sc_member_access(const NonConstPolicy &other) : ptr_(other.ptr_) {}
21212872Sgabeblack@google.com
21312872Sgabeblack@google.com    AccessType *get(ElementType *this_) const { return &(this_->*ptr_); }
21412872Sgabeblack@google.com
21512872Sgabeblack@google.com  private:
21612872Sgabeblack@google.com    MemberType ptr_;
21712872Sgabeblack@google.com};
21812872Sgabeblack@google.com
21912872Sgabeblack@google.comtemplate <typename Element,
22012872Sgabeblack@google.com          typename AccessPolicy=sc_direct_access<Element> >
22112852Sgabeblack@google.comclass sc_vector_iter :
22212872Sgabeblack@google.com        public std::iterator<std::random_access_iterator_tag,
22312872Sgabeblack@google.com                             typename AccessPolicy::Type>,
22412872Sgabeblack@google.com        private AccessPolicy
22512852Sgabeblack@google.com{
22612872Sgabeblack@google.com  private:
22712872Sgabeblack@google.com    typedef Element ElementType;
22812872Sgabeblack@google.com    typedef typename AccessPolicy::Policy Policy;
22912872Sgabeblack@google.com    typedef typename AccessPolicy::NonConstPolicy NonConstPolicy;
23012872Sgabeblack@google.com    typedef typename AccessPolicy::ConstPolicy ConstPolicy;
23112872Sgabeblack@google.com    typedef typename Policy::Type AccessType;
23212872Sgabeblack@google.com
23312872Sgabeblack@google.com    typedef typename sc_gem5::remove_const<ElementType>::type PlainType;
23412872Sgabeblack@google.com    typedef const PlainType ConstPlainType;
23512872Sgabeblack@google.com    typedef typename sc_direct_access<PlainType>::ConstPolicy
23612872Sgabeblack@google.com        ConstDirectPolicy;
23712872Sgabeblack@google.com
23812872Sgabeblack@google.com    friend class sc_vector<PlainType>;
23912872Sgabeblack@google.com    template <typename, typename>
24012872Sgabeblack@google.com    friend class sc_vector_assembly;
24112872Sgabeblack@google.com    template <typename, typename>
24212872Sgabeblack@google.com    friend class sc_vector_iter;
24312872Sgabeblack@google.com
24412872Sgabeblack@google.com    typedef std::iterator<std::random_access_iterator_tag, AccessType>
24512872Sgabeblack@google.com        BaseType;
24612872Sgabeblack@google.com    typedef sc_vector_iter ThisType;
24712872Sgabeblack@google.com    typedef sc_vector<PlainType> VectorType;
24812872Sgabeblack@google.com    typedef std::vector<void *> StorageType;
24912872Sgabeblack@google.com
25012872Sgabeblack@google.com    template <typename U>
25112872Sgabeblack@google.com    struct SelectIter
25212872Sgabeblack@google.com    {
25312872Sgabeblack@google.com        typedef typename std::vector<void *>::iterator type;
25412872Sgabeblack@google.com    };
25512872Sgabeblack@google.com    template <typename U>
25612872Sgabeblack@google.com    struct SelectIter<const U>
25712872Sgabeblack@google.com    {
25812872Sgabeblack@google.com        typedef typename std::vector<void *>::const_iterator type;
25912872Sgabeblack@google.com    };
26012872Sgabeblack@google.com    typedef typename SelectIter<ElementType>::type RawIterator;
26112872Sgabeblack@google.com    typedef sc_vector_iter<ConstPlainType, ConstPolicy> ConstIterator;
26212872Sgabeblack@google.com    typedef sc_vector_iter<ConstPlainType, ConstDirectPolicy>
26312872Sgabeblack@google.com        ConstDirectIterator;
26412872Sgabeblack@google.com
26512872Sgabeblack@google.com    RawIterator it_;
26612872Sgabeblack@google.com
26712872Sgabeblack@google.com    sc_vector_iter(RawIterator it, Policy acc=Policy()) :
26812872Sgabeblack@google.com        Policy(acc), it_(it)
26912872Sgabeblack@google.com    {}
27012872Sgabeblack@google.com
27112872Sgabeblack@google.com    Policy const &get_policy() const { return *this; }
27212872Sgabeblack@google.com
27312872Sgabeblack@google.com  public:
27412852Sgabeblack@google.com    // Conforms to Random Access Iterator category.
27512852Sgabeblack@google.com    // See ISO/IEC 14882:2003(E), 24.1 [lib.iterator.requirements]
27612852Sgabeblack@google.com
27712872Sgabeblack@google.com    typedef typename BaseType::difference_type difference_type;
27812872Sgabeblack@google.com    typedef typename BaseType::reference reference;
27912872Sgabeblack@google.com    typedef typename BaseType::pointer pointer;
28012872Sgabeblack@google.com
28112872Sgabeblack@google.com    sc_vector_iter() : Policy(), it_() {}
28212872Sgabeblack@google.com
28312872Sgabeblack@google.com    template <typename It>
28412872Sgabeblack@google.com    sc_vector_iter(const It &it,
28512872Sgabeblack@google.com        SC_ENABLE_IF_((
28612872Sgabeblack@google.com            sc_gem5::is_more_const<
28712872Sgabeblack@google.com                ElementType, typename It::Policy::ElementType>
28812872Sgabeblack@google.com        ))
28912872Sgabeblack@google.com    ) : Policy(it.get_policy()), it_(it.it_)
29012872Sgabeblack@google.com    {}
29112872Sgabeblack@google.com
29212872Sgabeblack@google.com    ThisType &
29312872Sgabeblack@google.com    operator ++ ()
29412872Sgabeblack@google.com    {
29512872Sgabeblack@google.com        ++it_;
29612872Sgabeblack@google.com        return *this;
29712872Sgabeblack@google.com    }
29812872Sgabeblack@google.com    ThisType &
29912872Sgabeblack@google.com    operator -- ()
30012872Sgabeblack@google.com    {
30112872Sgabeblack@google.com        --it_;
30212872Sgabeblack@google.com        return *this;
30312872Sgabeblack@google.com    }
30412872Sgabeblack@google.com    ThisType
30512872Sgabeblack@google.com    operator ++ (int)
30612872Sgabeblack@google.com    {
30712872Sgabeblack@google.com        ThisType old(*this);
30812872Sgabeblack@google.com        ++it_;
30912872Sgabeblack@google.com        return old;
31012872Sgabeblack@google.com    }
31112872Sgabeblack@google.com    ThisType
31212872Sgabeblack@google.com    operator -- (int)
31312872Sgabeblack@google.com    {
31412872Sgabeblack@google.com        ThisType old(*this);
31512872Sgabeblack@google.com        --it_;
31612872Sgabeblack@google.com        return old;
31712872Sgabeblack@google.com    }
31812872Sgabeblack@google.com
31912872Sgabeblack@google.com    ThisType
32012872Sgabeblack@google.com    operator + (difference_type n) const
32112872Sgabeblack@google.com    {
32212872Sgabeblack@google.com        return ThisType(it_ + n, get_policy());
32312872Sgabeblack@google.com    }
32412872Sgabeblack@google.com    ThisType
32512872Sgabeblack@google.com    operator - (difference_type n) const
32612872Sgabeblack@google.com    {
32712872Sgabeblack@google.com        return ThisType(it_ - n, get_policy());
32812872Sgabeblack@google.com    }
32912872Sgabeblack@google.com
33012872Sgabeblack@google.com    ThisType &
33112872Sgabeblack@google.com    operator += (difference_type n)
33212872Sgabeblack@google.com    {
33312872Sgabeblack@google.com        it_ += n;
33412872Sgabeblack@google.com        return *this;
33512872Sgabeblack@google.com    }
33612872Sgabeblack@google.com
33712872Sgabeblack@google.com    ThisType &
33812872Sgabeblack@google.com    operator -= (difference_type n)
33912872Sgabeblack@google.com    {
34012872Sgabeblack@google.com        it_ -= n;
34112872Sgabeblack@google.com        return *this;
34212872Sgabeblack@google.com    }
34312872Sgabeblack@google.com
34412872Sgabeblack@google.com    bool
34512872Sgabeblack@google.com    operator == (const ConstDirectIterator &other) const
34612872Sgabeblack@google.com    {
34712872Sgabeblack@google.com        return it_ == other.it_;
34812872Sgabeblack@google.com    }
34912872Sgabeblack@google.com    bool
35012872Sgabeblack@google.com    operator != (const ConstDirectIterator &other) const
35112872Sgabeblack@google.com    {
35212872Sgabeblack@google.com        return it_ != other.it_;
35312872Sgabeblack@google.com    }
35412872Sgabeblack@google.com    bool
35512872Sgabeblack@google.com    operator <= (const ConstDirectIterator &other) const
35612872Sgabeblack@google.com    {
35712872Sgabeblack@google.com        return it_ <= other.it_;
35812872Sgabeblack@google.com    }
35912872Sgabeblack@google.com    bool
36012872Sgabeblack@google.com    operator >= (const ConstDirectIterator &other) const
36112872Sgabeblack@google.com    {
36212872Sgabeblack@google.com        return it_ >= other.it_;
36312872Sgabeblack@google.com    }
36412872Sgabeblack@google.com    bool
36512872Sgabeblack@google.com    operator < (const ConstDirectIterator &other) const
36612872Sgabeblack@google.com    {
36712872Sgabeblack@google.com        return it_ < other.it_;
36812872Sgabeblack@google.com    }
36912872Sgabeblack@google.com    bool
37012872Sgabeblack@google.com    operator > (const ConstDirectIterator &other) const
37112872Sgabeblack@google.com    {
37212872Sgabeblack@google.com        return it_ > other.it_;
37312872Sgabeblack@google.com    }
37412872Sgabeblack@google.com
37512872Sgabeblack@google.com    reference
37612872Sgabeblack@google.com    operator * () const
37712872Sgabeblack@google.com    {
37812872Sgabeblack@google.com        return *Policy::get(static_cast<ElementType *>((void *)*it_));
37912872Sgabeblack@google.com    }
38012872Sgabeblack@google.com    pointer
38112872Sgabeblack@google.com    operator -> () const
38212872Sgabeblack@google.com    {
38312872Sgabeblack@google.com        return Policy::get(static_cast<ElementType *>((void *)*it_));
38412872Sgabeblack@google.com    }
38512872Sgabeblack@google.com    reference
38612872Sgabeblack@google.com    operator [] (difference_type n) const
38712872Sgabeblack@google.com    {
38812872Sgabeblack@google.com        return *Policy::get(static_cast<ElementType *>((void *)it_[n]));
38912872Sgabeblack@google.com    }
39012872Sgabeblack@google.com
39112872Sgabeblack@google.com    difference_type
39212872Sgabeblack@google.com    operator - (ConstDirectIterator const &other) const
39312872Sgabeblack@google.com    {
39412872Sgabeblack@google.com        return it_ - other.it_;
39512872Sgabeblack@google.com    }
39612852Sgabeblack@google.com};
39712852Sgabeblack@google.com
39812852Sgabeblack@google.comtemplate <typename T>
39912852Sgabeblack@google.comclass sc_vector : public sc_vector_base
40012852Sgabeblack@google.com{
40112852Sgabeblack@google.com  public:
40212852Sgabeblack@google.com    using sc_vector_base::size_type;
40312852Sgabeblack@google.com    typedef sc_vector_iter<T> iterator;
40412852Sgabeblack@google.com    typedef sc_vector_iter<const T> const_iterator;
40512852Sgabeblack@google.com
40612852Sgabeblack@google.com    sc_vector() : sc_vector_base()
40712852Sgabeblack@google.com    {
40812852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
40912852Sgabeblack@google.com    }
41012852Sgabeblack@google.com    explicit sc_vector(const char *) : sc_vector_base()
41112852Sgabeblack@google.com    {
41212852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
41312852Sgabeblack@google.com    }
41412852Sgabeblack@google.com    sc_vector(const char *, size_type) : sc_vector_base()
41512852Sgabeblack@google.com    {
41612852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
41712852Sgabeblack@google.com    }
41812852Sgabeblack@google.com    template <typename Creator>
41912852Sgabeblack@google.com    sc_vector(const char *, size_type, Creator) : sc_vector_base()
42012852Sgabeblack@google.com    {
42112852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
42212852Sgabeblack@google.com    }
42312852Sgabeblack@google.com    virtual ~sc_vector() {}
42412852Sgabeblack@google.com
42512852Sgabeblack@google.com    void
42612852Sgabeblack@google.com    init(size_type)
42712852Sgabeblack@google.com    {
42812852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
42912852Sgabeblack@google.com    }
43012852Sgabeblack@google.com    static T *
43112852Sgabeblack@google.com    create_element(const char *, size_type)
43212852Sgabeblack@google.com    {
43312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
43412852Sgabeblack@google.com        return nullptr;
43512852Sgabeblack@google.com    }
43612852Sgabeblack@google.com
43712852Sgabeblack@google.com    template <typename Creator>
43812852Sgabeblack@google.com    void
43912852Sgabeblack@google.com    init(size_type, Creator)
44012852Sgabeblack@google.com    {
44112852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
44212852Sgabeblack@google.com    }
44312852Sgabeblack@google.com
44412852Sgabeblack@google.com    T &
44512852Sgabeblack@google.com    operator [] (size_type)
44612852Sgabeblack@google.com    {
44712852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
44812852Sgabeblack@google.com        return *(T *)nullptr;
44912852Sgabeblack@google.com    }
45012852Sgabeblack@google.com    const T &
45112852Sgabeblack@google.com    operator [] (size_type) const
45212852Sgabeblack@google.com    {
45312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
45412852Sgabeblack@google.com        return *(const T *)nullptr;
45512852Sgabeblack@google.com    }
45612852Sgabeblack@google.com
45712852Sgabeblack@google.com    T &
45812852Sgabeblack@google.com    at(size_type)
45912852Sgabeblack@google.com    {
46012852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
46112852Sgabeblack@google.com        return *(T *)nullptr;
46212852Sgabeblack@google.com    }
46312852Sgabeblack@google.com    const T &
46412852Sgabeblack@google.com    at(size_type) const
46512852Sgabeblack@google.com    {
46612852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
46712852Sgabeblack@google.com        return *(const T *)nullptr;
46812852Sgabeblack@google.com    }
46912852Sgabeblack@google.com
47012852Sgabeblack@google.com    iterator
47112852Sgabeblack@google.com    begin()
47212852Sgabeblack@google.com    {
47312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
47412852Sgabeblack@google.com        return iterator();
47512852Sgabeblack@google.com    }
47612852Sgabeblack@google.com    iterator
47712852Sgabeblack@google.com    end()
47812852Sgabeblack@google.com    {
47912852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
48012852Sgabeblack@google.com        return iterator();
48112852Sgabeblack@google.com    }
48212852Sgabeblack@google.com
48312852Sgabeblack@google.com    const_iterator
48412852Sgabeblack@google.com    begin() const
48512852Sgabeblack@google.com    {
48612852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
48712852Sgabeblack@google.com        return const_iterator();
48812852Sgabeblack@google.com    }
48912852Sgabeblack@google.com    const_iterator
49012852Sgabeblack@google.com    end() const
49112852Sgabeblack@google.com    {
49212852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
49312852Sgabeblack@google.com        return const_iterator();
49412852Sgabeblack@google.com    }
49512852Sgabeblack@google.com
49612852Sgabeblack@google.com    const_iterator
49712852Sgabeblack@google.com    cbegin() const
49812852Sgabeblack@google.com    {
49912852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
50012852Sgabeblack@google.com        return const_iterator();
50112852Sgabeblack@google.com    }
50212852Sgabeblack@google.com    const_iterator
50312852Sgabeblack@google.com    cend() const
50412852Sgabeblack@google.com    {
50512852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
50612852Sgabeblack@google.com        return const_iterator();
50712852Sgabeblack@google.com    }
50812852Sgabeblack@google.com
50912852Sgabeblack@google.com    template <typename ContainerType, typename ArgumentType>
51012852Sgabeblack@google.com    iterator
51112852Sgabeblack@google.com    bind(sc_vector_assembly<ContainerType, ArgumentType>)
51212852Sgabeblack@google.com    {
51312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
51412852Sgabeblack@google.com        return iterator();
51512852Sgabeblack@google.com    }
51612852Sgabeblack@google.com
51712852Sgabeblack@google.com    template <typename BindableContainer>
51812852Sgabeblack@google.com    iterator
51912852Sgabeblack@google.com    bind(BindableContainer &)
52012852Sgabeblack@google.com    {
52112852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
52212852Sgabeblack@google.com        return iterator();
52312852Sgabeblack@google.com    }
52412852Sgabeblack@google.com
52512852Sgabeblack@google.com    template <typename BindableIterator>
52612852Sgabeblack@google.com    iterator
52712852Sgabeblack@google.com    bind(BindableIterator, BindableIterator)
52812852Sgabeblack@google.com    {
52912852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
53012852Sgabeblack@google.com        return iterator();
53112852Sgabeblack@google.com    }
53212852Sgabeblack@google.com
53312852Sgabeblack@google.com    template <typename BindableIterator>
53412852Sgabeblack@google.com    iterator
53512852Sgabeblack@google.com    bind(BindableIterator, BindableIterator, iterator)
53612852Sgabeblack@google.com    {
53712852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
53812852Sgabeblack@google.com        return iterator();
53912852Sgabeblack@google.com    }
54012852Sgabeblack@google.com
54112852Sgabeblack@google.com    template <typename ContainerType, typename ArgumentType>
54212852Sgabeblack@google.com    iterator
54312852Sgabeblack@google.com    operator () (sc_vector_assembly<ContainerType, ArgumentType> c)
54412852Sgabeblack@google.com    {
54512852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
54612852Sgabeblack@google.com        return iterator();
54712852Sgabeblack@google.com    }
54812852Sgabeblack@google.com
54912852Sgabeblack@google.com    template <typename ArgumentContainer>
55012852Sgabeblack@google.com    iterator
55112852Sgabeblack@google.com    operator () (ArgumentContainer &)
55212852Sgabeblack@google.com    {
55312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
55412852Sgabeblack@google.com        return iterator();
55512852Sgabeblack@google.com    }
55612852Sgabeblack@google.com
55712852Sgabeblack@google.com    template <typename ArgumentIterator>
55812852Sgabeblack@google.com    iterator
55912852Sgabeblack@google.com    operator () (ArgumentIterator, ArgumentIterator)
56012852Sgabeblack@google.com    {
56112852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
56212852Sgabeblack@google.com        return iterator();
56312852Sgabeblack@google.com    }
56412852Sgabeblack@google.com
56512852Sgabeblack@google.com    template <typename ArgumentIterator>
56612852Sgabeblack@google.com    iterator
56712852Sgabeblack@google.com    operator () (ArgumentIterator, ArgumentIterator, iterator)
56812852Sgabeblack@google.com    {
56912852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
57012852Sgabeblack@google.com        return iterator();
57112852Sgabeblack@google.com    }
57212852Sgabeblack@google.com
57312852Sgabeblack@google.com  private:
57412852Sgabeblack@google.com    // Disabled
57512852Sgabeblack@google.com    sc_vector(const sc_vector &) : sc_vector_base() {}
57612852Sgabeblack@google.com    sc_vector &operator = (const sc_vector &) { return *this; }
57712852Sgabeblack@google.com};
57812852Sgabeblack@google.com
57912852Sgabeblack@google.comtemplate <typename T, typename MT>
58012852Sgabeblack@google.comclass sc_vector_assembly
58112852Sgabeblack@google.com{
58212852Sgabeblack@google.com  public:
58312852Sgabeblack@google.com    friend sc_vector_assembly<T, MT> sc_assemble_vector<>(
58412872Sgabeblack@google.com            sc_vector<T> &, MT (T::*));
58512852Sgabeblack@google.com
58612852Sgabeblack@google.com    typedef size_t size_type;
58712872Sgabeblack@google.com    typedef sc_vector_iter<T, sc_member_access<T, MT> > iterator;
58812872Sgabeblack@google.com    typedef sc_vector_iter<
58912872Sgabeblack@google.com        const T, sc_member_access<const T, const MT> > const_iterator;
59012872Sgabeblack@google.com    typedef MT (T::*MemberType);
59112852Sgabeblack@google.com
59212852Sgabeblack@google.com    sc_vector_assembly(const sc_vector_assembly &)
59312852Sgabeblack@google.com    {
59412852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
59512852Sgabeblack@google.com    }
59612852Sgabeblack@google.com
59712872Sgabeblack@google.com    iterator begin() { return iterator(vec_->begin().it_, ptr_); }
59812872Sgabeblack@google.com    iterator end() { return iterator(vec_->end().it_, ptr_); }
59912852Sgabeblack@google.com
60012852Sgabeblack@google.com    const_iterator
60112852Sgabeblack@google.com    cbegin() const
60212852Sgabeblack@google.com    {
60312872Sgabeblack@google.com        return const_iterator(vec_->begin().it_, ptr_);
60412852Sgabeblack@google.com    }
60512852Sgabeblack@google.com    const_iterator
60612852Sgabeblack@google.com    cend() const
60712852Sgabeblack@google.com    {
60812872Sgabeblack@google.com        return const_iterator(vec_->end().it_, ptr_);
60912852Sgabeblack@google.com    }
61012852Sgabeblack@google.com
61112872Sgabeblack@google.com    const_iterator
61212872Sgabeblack@google.com    begin() const
61312852Sgabeblack@google.com    {
61412872Sgabeblack@google.com        return const_iterator(vec_->begin().it_, ptr_);
61512852Sgabeblack@google.com    }
61612872Sgabeblack@google.com    const_iterator
61712872Sgabeblack@google.com    end() const
61812872Sgabeblack@google.com    {
61912872Sgabeblack@google.com        return const_iterator(vec_->end().it_, ptr_);
62012872Sgabeblack@google.com    }
62112872Sgabeblack@google.com
62212872Sgabeblack@google.com    size_type size() const { return vec_->size(); }
62312872Sgabeblack@google.com
62412852Sgabeblack@google.com    std::vector<sc_object *>
62512852Sgabeblack@google.com    get_elements() const
62612852Sgabeblack@google.com    {
62712852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
62812852Sgabeblack@google.com        return *(std::vector<sc_object *> *)nullptr;
62912852Sgabeblack@google.com    }
63012852Sgabeblack@google.com
63112852Sgabeblack@google.com    typename iterator::reference
63212872Sgabeblack@google.com    operator [] (size_type i)
63312852Sgabeblack@google.com    {
63412872Sgabeblack@google.com        return (*vec_)[i].*ptr_;
63512852Sgabeblack@google.com    }
63612852Sgabeblack@google.com    typename const_iterator::reference
63712872Sgabeblack@google.com    operator [] (size_type i) const
63812852Sgabeblack@google.com    {
63912872Sgabeblack@google.com        return (*vec_)[i].*ptr_;
64012852Sgabeblack@google.com    }
64112852Sgabeblack@google.com
64212852Sgabeblack@google.com    typename iterator::reference
64312872Sgabeblack@google.com    at(size_type i)
64412852Sgabeblack@google.com    {
64512872Sgabeblack@google.com        return vec_->at(i).*ptr_;
64612852Sgabeblack@google.com    }
64712852Sgabeblack@google.com    typename const_iterator::reference
64812872Sgabeblack@google.com    at(size_type i) const
64912852Sgabeblack@google.com    {
65012872Sgabeblack@google.com        return vec_->at(i).*ptr_;
65112852Sgabeblack@google.com    }
65212852Sgabeblack@google.com
65312852Sgabeblack@google.com    template <typename ContainerType, typename ArgumentType>
65412852Sgabeblack@google.com    iterator
65512852Sgabeblack@google.com    bind(sc_vector_assembly<ContainerType, ArgumentType>)
65612852Sgabeblack@google.com    {
65712852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
65812872Sgabeblack@google.com        return begin();
65912852Sgabeblack@google.com    }
66012852Sgabeblack@google.com
66112852Sgabeblack@google.com    template <typename BindableContainer>
66212852Sgabeblack@google.com    iterator
66312852Sgabeblack@google.com    bind(BindableContainer &)
66412852Sgabeblack@google.com    {
66512852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
66612872Sgabeblack@google.com        return begin();
66712852Sgabeblack@google.com    }
66812852Sgabeblack@google.com
66912852Sgabeblack@google.com    template <typename BindableIterator>
67012852Sgabeblack@google.com    iterator
67112852Sgabeblack@google.com    bind(BindableIterator, BindableIterator)
67212852Sgabeblack@google.com    {
67312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
67412872Sgabeblack@google.com        return begin();
67512852Sgabeblack@google.com    }
67612852Sgabeblack@google.com
67712852Sgabeblack@google.com    template <typename BindableIterator>
67812852Sgabeblack@google.com    iterator
67912852Sgabeblack@google.com    bind(BindableIterator, BindableIterator, iterator)
68012852Sgabeblack@google.com    {
68112852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
68212872Sgabeblack@google.com        return begin();
68312852Sgabeblack@google.com    }
68412852Sgabeblack@google.com
68512852Sgabeblack@google.com    template <typename BindableIterator>
68612852Sgabeblack@google.com    iterator
68712852Sgabeblack@google.com    bind(BindableIterator, BindableIterator, typename sc_vector<T>::iterator)
68812852Sgabeblack@google.com    {
68912852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
69012872Sgabeblack@google.com        return begin();
69112852Sgabeblack@google.com    }
69212852Sgabeblack@google.com
69312852Sgabeblack@google.com    template <typename ContainerType, typename ArgumentType>
69412852Sgabeblack@google.com    iterator
69512852Sgabeblack@google.com    operator () (sc_vector_assembly<ContainerType, ArgumentType>)
69612852Sgabeblack@google.com    {
69712852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
69812872Sgabeblack@google.com        return begin();
69912852Sgabeblack@google.com    }
70012852Sgabeblack@google.com
70112852Sgabeblack@google.com    template <typename ArgumentContainer>
70212852Sgabeblack@google.com    iterator
70312852Sgabeblack@google.com    operator () (ArgumentContainer &)
70412852Sgabeblack@google.com    {
70512852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
70612872Sgabeblack@google.com        return begin();
70712852Sgabeblack@google.com    }
70812852Sgabeblack@google.com
70912852Sgabeblack@google.com    template <typename ArgumentIterator>
71012852Sgabeblack@google.com    iterator
71112852Sgabeblack@google.com    operator () (ArgumentIterator, ArgumentIterator)
71212852Sgabeblack@google.com    {
71312852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
71412872Sgabeblack@google.com        return begin();
71512852Sgabeblack@google.com    }
71612852Sgabeblack@google.com
71712852Sgabeblack@google.com    template <typename ArgumentIterator>
71812852Sgabeblack@google.com    iterator
71912852Sgabeblack@google.com    operator () (ArgumentIterator, ArgumentIterator, iterator)
72012852Sgabeblack@google.com    {
72112852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
72212872Sgabeblack@google.com        return begin();
72312852Sgabeblack@google.com    }
72412852Sgabeblack@google.com
72512852Sgabeblack@google.com    template <typename ArgumentIterator>
72612852Sgabeblack@google.com    iterator
72712852Sgabeblack@google.com    operator () (ArgumentIterator, ArgumentIterator,
72812852Sgabeblack@google.com                 typename sc_vector<T>::iterator)
72912852Sgabeblack@google.com    {
73012852Sgabeblack@google.com        sc_utils_warn_unimpl(__PRETTY_FUNCTION__);
73112872Sgabeblack@google.com        return begin();
73212852Sgabeblack@google.com    }
73312852Sgabeblack@google.com
73412852Sgabeblack@google.com  private:
73512872Sgabeblack@google.com    sc_vector_assembly(sc_vector<T> &v, MemberType ptr) :
73612872Sgabeblack@google.com        vec_(&v), ptr_(ptr)
73712872Sgabeblack@google.com    {}
73812872Sgabeblack@google.com
73912872Sgabeblack@google.com    sc_vector<T> *vec_;
74012872Sgabeblack@google.com    MemberType ptr_;
74112852Sgabeblack@google.com};
74212852Sgabeblack@google.com
74312852Sgabeblack@google.comtemplate <typename T, typename MT>
74412852Sgabeblack@google.comsc_vector_assembly<T, MT>
74512872Sgabeblack@google.comsc_assemble_vector(sc_vector<T> &v, MT (T::*ptr))
74612852Sgabeblack@google.com{
74712872Sgabeblack@google.com    return sc_vector_assembly<T, MT>(v, ptr);
74812852Sgabeblack@google.com}
74912852Sgabeblack@google.com
75012852Sgabeblack@google.com} // namespace sc_core
75112852Sgabeblack@google.com
75212852Sgabeblack@google.com#endif  //__SYSTEMC_EXT_UTIL_SC_VECTOR_HH__
753