112027Sjungma@eit.uni-kl.de/*****************************************************************************
212027Sjungma@eit.uni-kl.de
312027Sjungma@eit.uni-kl.de  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412027Sjungma@eit.uni-kl.de  more contributor license agreements.  See the NOTICE file distributed
512027Sjungma@eit.uni-kl.de  with this work for additional information regarding copyright ownership.
612027Sjungma@eit.uni-kl.de  Accellera licenses this file to you under the Apache License, Version 2.0
712027Sjungma@eit.uni-kl.de  (the "License"); you may not use this file except in compliance with the
812027Sjungma@eit.uni-kl.de  License.  You may obtain a copy of the License at
912027Sjungma@eit.uni-kl.de
1012027Sjungma@eit.uni-kl.de    http://www.apache.org/licenses/LICENSE-2.0
1112027Sjungma@eit.uni-kl.de
1212027Sjungma@eit.uni-kl.de  Unless required by applicable law or agreed to in writing, software
1312027Sjungma@eit.uni-kl.de  distributed under the License is distributed on an "AS IS" BASIS,
1412027Sjungma@eit.uni-kl.de  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512027Sjungma@eit.uni-kl.de  implied.  See the License for the specific language governing
1612027Sjungma@eit.uni-kl.de  permissions and limitations under the License.
1712027Sjungma@eit.uni-kl.de
1812027Sjungma@eit.uni-kl.de *****************************************************************************/
1912027Sjungma@eit.uni-kl.de
2012027Sjungma@eit.uni-kl.de/*****************************************************************************
2112027Sjungma@eit.uni-kl.de
2212027Sjungma@eit.uni-kl.de  sc_vector.h - A vector of named (SystemC) objects (modules, ports, channels)
2312027Sjungma@eit.uni-kl.de
2412027Sjungma@eit.uni-kl.de  Original Author: Philipp A. Hartmann, OFFIS
2512027Sjungma@eit.uni-kl.de
2612027Sjungma@eit.uni-kl.de  CHANGE LOG AT END OF FILE
2712027Sjungma@eit.uni-kl.de *****************************************************************************/
2812027Sjungma@eit.uni-kl.de
2912027Sjungma@eit.uni-kl.de#ifndef SC_VECTOR_H_INCLUDED_
3012027Sjungma@eit.uni-kl.de#define SC_VECTOR_H_INCLUDED_
3112027Sjungma@eit.uni-kl.de
3212027Sjungma@eit.uni-kl.de#include <vector>
3312027Sjungma@eit.uni-kl.de#include <iterator>
3412027Sjungma@eit.uni-kl.de#include <string>
3512027Sjungma@eit.uni-kl.de#include <algorithm> // std::swap
3612027Sjungma@eit.uni-kl.de
3712027Sjungma@eit.uni-kl.de#include "sysc/kernel/sc_object.h"
3812027Sjungma@eit.uni-kl.de#include <type_traits>
3912027Sjungma@eit.uni-kl.de
4012027Sjungma@eit.uni-kl.de//#define SC_VECTOR_HEADER_ONLY_
4112027Sjungma@eit.uni-kl.de
4212027Sjungma@eit.uni-kl.denamespace sc_core {
4312027Sjungma@eit.uni-kl.denamespace sc_meta {
4412027Sjungma@eit.uni-kl.de
4512027Sjungma@eit.uni-kl.de  using ::std::enable_if;
4612027Sjungma@eit.uni-kl.de  using ::std::remove_const;
4712027Sjungma@eit.uni-kl.de  using ::std::is_same;
4812027Sjungma@eit.uni-kl.de  using ::std::is_const;
4912027Sjungma@eit.uni-kl.de
5012027Sjungma@eit.uni-kl.de  template< typename CT, typename T >
5112027Sjungma@eit.uni-kl.de  struct is_more_const {
5212027Sjungma@eit.uni-kl.de    static constexpr bool value
5312027Sjungma@eit.uni-kl.de       = ( is_same< typename remove_const<CT>::type
5412027Sjungma@eit.uni-kl.de                 , typename remove_const<T>::type
5512027Sjungma@eit.uni-kl.de                 >::value
5612027Sjungma@eit.uni-kl.de          && ( is_const<CT>::value >= is_const<T>::value ) );
5712027Sjungma@eit.uni-kl.de  };
5812027Sjungma@eit.uni-kl.de
5912027Sjungma@eit.uni-kl.de} // namespace sc_meta
6012027Sjungma@eit.uni-kl.de
6112027Sjungma@eit.uni-kl.de// forward declarations
6212027Sjungma@eit.uni-kl.detemplate< typename T >              class sc_vector;
6312027Sjungma@eit.uni-kl.detemplate< typename T, typename MT > class sc_vector_assembly;
6412027Sjungma@eit.uni-kl.detemplate< typename T, typename MT > class sc_vector_iter;
6512027Sjungma@eit.uni-kl.de
6612027Sjungma@eit.uni-kl.de// implementation-defined
6712027Sjungma@eit.uni-kl.detemplate< typename Container, typename ArgumentIterator >
6812027Sjungma@eit.uni-kl.detypename Container::iterator
6912027Sjungma@eit.uni-kl.desc_vector_do_bind( Container & cont
7012027Sjungma@eit.uni-kl.de                 , ArgumentIterator  first
7112027Sjungma@eit.uni-kl.de                 , ArgumentIterator  last
7212027Sjungma@eit.uni-kl.de                 , typename Container::iterator from );
7312027Sjungma@eit.uni-kl.de
7412027Sjungma@eit.uni-kl.de// implementation-defined
7512027Sjungma@eit.uni-kl.detemplate< typename Container, typename ArgumentIterator >
7612027Sjungma@eit.uni-kl.detypename Container::iterator
7712027Sjungma@eit.uni-kl.desc_vector_do_operator_paren( Container & cont
7812027Sjungma@eit.uni-kl.de                           , ArgumentIterator  first
7912027Sjungma@eit.uni-kl.de                           , ArgumentIterator  last
8012027Sjungma@eit.uni-kl.de                           , typename Container::iterator from );
8112027Sjungma@eit.uni-kl.de
8212027Sjungma@eit.uni-kl.declass sc_vector_base
8312027Sjungma@eit.uni-kl.de  : public sc_object
8412027Sjungma@eit.uni-kl.de{
8512027Sjungma@eit.uni-kl.de
8612027Sjungma@eit.uni-kl.de  template<typename,typename> friend class sc_vector_assembly;
8712027Sjungma@eit.uni-kl.de  template<typename,typename> friend class sc_vector_iter;
8812027Sjungma@eit.uni-kl.de
8912027Sjungma@eit.uni-kl.depublic:
9012027Sjungma@eit.uni-kl.de
9112027Sjungma@eit.uni-kl.de  typedef std::vector< void* >          storage_type;
9212027Sjungma@eit.uni-kl.de  typedef storage_type::size_type       size_type;
9312027Sjungma@eit.uni-kl.de  typedef storage_type::difference_type difference_type;
9412027Sjungma@eit.uni-kl.de
9512027Sjungma@eit.uni-kl.de  const char * kind() const { return "sc_vector"; }
9612027Sjungma@eit.uni-kl.de
9712027Sjungma@eit.uni-kl.de  std::vector<sc_object*> const & get_elements() const;
9812027Sjungma@eit.uni-kl.de
9912027Sjungma@eit.uni-kl.de  size_type size() const
10012027Sjungma@eit.uni-kl.de    { return vec_.size(); }
10112027Sjungma@eit.uni-kl.de
10212027Sjungma@eit.uni-kl.deprotected:
10312027Sjungma@eit.uni-kl.de
10412027Sjungma@eit.uni-kl.de  // begin implementation defined
10512027Sjungma@eit.uni-kl.de
10612027Sjungma@eit.uni-kl.de  typedef storage_type::iterator        iterator;
10712027Sjungma@eit.uni-kl.de  typedef storage_type::const_iterator  const_iterator;
10812027Sjungma@eit.uni-kl.de
10912027Sjungma@eit.uni-kl.de  sc_vector_base();
11012027Sjungma@eit.uni-kl.de
11112027Sjungma@eit.uni-kl.de  sc_vector_base( const char* prefix )
11212027Sjungma@eit.uni-kl.de    : sc_object( prefix )
11312027Sjungma@eit.uni-kl.de    , vec_()
11412027Sjungma@eit.uni-kl.de    , objs_vec_(0)
11512027Sjungma@eit.uni-kl.de  {}
11612027Sjungma@eit.uni-kl.de
11712027Sjungma@eit.uni-kl.de  ~sc_vector_base()
11812027Sjungma@eit.uni-kl.de    { delete objs_vec_; }
11912027Sjungma@eit.uni-kl.de
12012027Sjungma@eit.uni-kl.de  void * & at( size_type i )
12112027Sjungma@eit.uni-kl.de    { return vec_[i]; }
12212027Sjungma@eit.uni-kl.de
12312027Sjungma@eit.uni-kl.de  void const * at( size_type i ) const
12412027Sjungma@eit.uni-kl.de    { return vec_[i]; }
12512027Sjungma@eit.uni-kl.de
12612027Sjungma@eit.uni-kl.de  void reserve( size_type n )
12712027Sjungma@eit.uni-kl.de    { vec_.reserve(n); }
12812027Sjungma@eit.uni-kl.de
12912027Sjungma@eit.uni-kl.de  void clear()
13012027Sjungma@eit.uni-kl.de    { vec_.clear(); }
13112027Sjungma@eit.uni-kl.de
13212027Sjungma@eit.uni-kl.de  void push_back( void* item )
13312027Sjungma@eit.uni-kl.de    { vec_.push_back(item); }
13412027Sjungma@eit.uni-kl.de
13512027Sjungma@eit.uni-kl.de  void check_index( size_type i ) const;
13612027Sjungma@eit.uni-kl.de  bool check_init( size_type n )  const;
13712027Sjungma@eit.uni-kl.de
13812027Sjungma@eit.uni-kl.de  static std::string make_name( const char* prefix, size_type index );
13912027Sjungma@eit.uni-kl.de
14012027Sjungma@eit.uni-kl.de  iterator begin() { return vec_.begin(); }
14112027Sjungma@eit.uni-kl.de  iterator end()   { return vec_.end();   }
14212027Sjungma@eit.uni-kl.de
14312027Sjungma@eit.uni-kl.de  const_iterator begin() const { return vec_.begin(); }
14412027Sjungma@eit.uni-kl.de  const_iterator end()   const { return vec_.end();   }
14512027Sjungma@eit.uni-kl.de
14612027Sjungma@eit.uni-kl.de  virtual sc_object* object_cast( void* ) const = 0;
14712027Sjungma@eit.uni-kl.de
14812027Sjungma@eit.uni-kl.de  sc_object* implicit_cast( sc_object* p ) const { return p; }
14912027Sjungma@eit.uni-kl.de  sc_object* implicit_cast( ... /* incompatible */ )  const;
15012027Sjungma@eit.uni-kl.de
15112027Sjungma@eit.uni-kl.depublic:
15212027Sjungma@eit.uni-kl.de
15312027Sjungma@eit.uni-kl.de  void report_empty_bind( const char* kind_, bool dst_range_ ) const;
15412027Sjungma@eit.uni-kl.de
15512027Sjungma@eit.uni-kl.deprivate:
15612027Sjungma@eit.uni-kl.de  storage_type vec_;
15712027Sjungma@eit.uni-kl.de  mutable std::vector< sc_object* >* objs_vec_;
15812027Sjungma@eit.uni-kl.de
15912027Sjungma@eit.uni-kl.de  // disabled
16012027Sjungma@eit.uni-kl.de  sc_vector_base( const sc_vector_base& );
16112027Sjungma@eit.uni-kl.de  sc_vector_base& operator=( const sc_vector_base& );
16212027Sjungma@eit.uni-kl.de
16312027Sjungma@eit.uni-kl.de}; // sc_vector_base
16412027Sjungma@eit.uni-kl.de
16512027Sjungma@eit.uni-kl.de// iterator access adapters
16612027Sjungma@eit.uni-kl.detemplate< typename ElementType >
16712027Sjungma@eit.uni-kl.destruct sc_direct_access
16812027Sjungma@eit.uni-kl.de{
16912027Sjungma@eit.uni-kl.de  typedef ElementType  element_type;
17012027Sjungma@eit.uni-kl.de  typedef element_type type;
17112027Sjungma@eit.uni-kl.de  typedef typename sc_meta::remove_const<type>::type plain_type;
17212027Sjungma@eit.uni-kl.de
17312027Sjungma@eit.uni-kl.de  typedef sc_direct_access< type >             policy;
17412027Sjungma@eit.uni-kl.de  typedef sc_direct_access< plain_type >       non_const_policy;
17512027Sjungma@eit.uni-kl.de  typedef sc_direct_access< const plain_type > const_policy;
17612027Sjungma@eit.uni-kl.de
17712027Sjungma@eit.uni-kl.de  sc_direct_access(){}
17812027Sjungma@eit.uni-kl.de  sc_direct_access( const non_const_policy& ) {}
17912027Sjungma@eit.uni-kl.de  // convert from any policy to (const) direct policy
18012027Sjungma@eit.uni-kl.de  template <typename U>
18112027Sjungma@eit.uni-kl.de  sc_direct_access(const U&,
18212027Sjungma@eit.uni-kl.de                   typename sc_meta::enable_if<sc_meta::is_more_const<
18312027Sjungma@eit.uni-kl.de                     type,
18412027Sjungma@eit.uni-kl.de                     typename U::policy::element_type>::value>::type* = NULL)
18512027Sjungma@eit.uni-kl.de  {}
18612027Sjungma@eit.uni-kl.de
18712027Sjungma@eit.uni-kl.de  type* get( type* this_ ) const
18812027Sjungma@eit.uni-kl.de    { return this_; }
18912027Sjungma@eit.uni-kl.de};
19012027Sjungma@eit.uni-kl.de
19112027Sjungma@eit.uni-kl.de// iterator access adapters
19212027Sjungma@eit.uni-kl.detemplate< typename ElementType
19312027Sjungma@eit.uni-kl.de        , typename AccessType   >
19412027Sjungma@eit.uni-kl.declass sc_member_access
19512027Sjungma@eit.uni-kl.de{
19612027Sjungma@eit.uni-kl.de  public:
19712027Sjungma@eit.uni-kl.de    template< typename, typename > friend class sc_member_access;
19812027Sjungma@eit.uni-kl.de
19912027Sjungma@eit.uni-kl.de    typedef ElementType element_type;
20012027Sjungma@eit.uni-kl.de    typedef AccessType  access_type;
20112027Sjungma@eit.uni-kl.de    typedef access_type (ElementType::*member_type);
20212027Sjungma@eit.uni-kl.de    typedef access_type type;
20312027Sjungma@eit.uni-kl.de    typedef typename sc_meta::remove_const<type>::type plain_type;
20412027Sjungma@eit.uni-kl.de    typedef typename sc_meta::remove_const<ElementType>::type plain_elem_type;
20512027Sjungma@eit.uni-kl.de
20612027Sjungma@eit.uni-kl.de    typedef sc_member_access< element_type, access_type > policy;
20712027Sjungma@eit.uni-kl.de    typedef sc_member_access< plain_elem_type, plain_type >
20812027Sjungma@eit.uni-kl.de      non_const_policy;
20912027Sjungma@eit.uni-kl.de    typedef sc_member_access< const plain_elem_type, const plain_type >
21012027Sjungma@eit.uni-kl.de      const_policy;
21112027Sjungma@eit.uni-kl.de
21212027Sjungma@eit.uni-kl.de    sc_member_access( member_type ptr )
21312027Sjungma@eit.uni-kl.de      : ptr_(ptr) {}
21412027Sjungma@eit.uni-kl.de
21512027Sjungma@eit.uni-kl.de    sc_member_access( const non_const_policy& other )
21612027Sjungma@eit.uni-kl.de      : ptr_(other.ptr_)
21712027Sjungma@eit.uni-kl.de    {}
21812027Sjungma@eit.uni-kl.de
21912027Sjungma@eit.uni-kl.de    access_type * get( element_type* this_ ) const
22012027Sjungma@eit.uni-kl.de      { return &(this_->*ptr_); }
22112027Sjungma@eit.uni-kl.de
22212027Sjungma@eit.uni-kl.de  private:
22312027Sjungma@eit.uni-kl.de    member_type ptr_;
22412027Sjungma@eit.uni-kl.de}; // sc_member_access
22512027Sjungma@eit.uni-kl.de
22612027Sjungma@eit.uni-kl.de
22712027Sjungma@eit.uni-kl.detemplate< typename ElementType
22812027Sjungma@eit.uni-kl.de        , typename AccessPolicy = sc_direct_access<ElementType> >
22912027Sjungma@eit.uni-kl.declass sc_vector_iter
23012027Sjungma@eit.uni-kl.de  : public std::iterator< std::random_access_iterator_tag
23112027Sjungma@eit.uni-kl.de                        , typename AccessPolicy::type >
23212027Sjungma@eit.uni-kl.de  , private AccessPolicy
23312027Sjungma@eit.uni-kl.de{
23412027Sjungma@eit.uni-kl.de  typedef ElementType  element_type;
23512027Sjungma@eit.uni-kl.de  typedef typename AccessPolicy::policy            access_policy;
23612027Sjungma@eit.uni-kl.de  typedef typename AccessPolicy::non_const_policy  non_const_policy;
23712027Sjungma@eit.uni-kl.de  typedef typename AccessPolicy::const_policy      const_policy;
23812027Sjungma@eit.uni-kl.de  typedef typename access_policy::type access_type;
23912027Sjungma@eit.uni-kl.de
24012027Sjungma@eit.uni-kl.de  typedef typename sc_meta::remove_const<ElementType>::type plain_type;
24112027Sjungma@eit.uni-kl.de  typedef const plain_type                                  const_plain_type;
24212027Sjungma@eit.uni-kl.de
24312027Sjungma@eit.uni-kl.de  friend class sc_vector< plain_type >;
24412027Sjungma@eit.uni-kl.de  template< typename, typename > friend class sc_vector_assembly;
24512027Sjungma@eit.uni-kl.de  template< typename, typename > friend class sc_vector_iter;
24612027Sjungma@eit.uni-kl.de
24712027Sjungma@eit.uni-kl.de  typedef std::iterator< std::random_access_iterator_tag, access_type > base_type;
24812027Sjungma@eit.uni-kl.de  typedef sc_vector_iter               this_type;
24912027Sjungma@eit.uni-kl.de  typedef sc_vector<plain_type>        vector_type;
25012027Sjungma@eit.uni-kl.de  typedef sc_vector_base::storage_type storage_type;
25112027Sjungma@eit.uni-kl.de
25212027Sjungma@eit.uni-kl.de  // select correct base-type iterator
25312027Sjungma@eit.uni-kl.de  template< typename U > struct select_iter
25412027Sjungma@eit.uni-kl.de    { typedef typename storage_type::iterator       type; };
25512027Sjungma@eit.uni-kl.de  template< typename U > struct select_iter< const U >
25612027Sjungma@eit.uni-kl.de    { typedef typename storage_type::const_iterator type; };
25712027Sjungma@eit.uni-kl.de
25812027Sjungma@eit.uni-kl.de  typedef typename select_iter<ElementType>::type          raw_iterator;
25912027Sjungma@eit.uni-kl.de  typedef sc_vector_iter< const_plain_type, const_policy > const_iterator;
26012027Sjungma@eit.uni-kl.de
26112027Sjungma@eit.uni-kl.de  // underlying vector iterator
26212027Sjungma@eit.uni-kl.de
26312027Sjungma@eit.uni-kl.de  raw_iterator it_;
26412027Sjungma@eit.uni-kl.de
26512027Sjungma@eit.uni-kl.de  sc_vector_iter( raw_iterator it, access_policy acc = access_policy() )
26612027Sjungma@eit.uni-kl.de    : access_policy(acc), it_(it) {}
26712027Sjungma@eit.uni-kl.de
26812027Sjungma@eit.uni-kl.de  access_policy const & get_policy() const { return *this; }
26912027Sjungma@eit.uni-kl.de
27012027Sjungma@eit.uni-kl.depublic:
27112027Sjungma@eit.uni-kl.de  // interface for Random Access Iterator category,
27212027Sjungma@eit.uni-kl.de  // see ISO/IEC 14882:2003(E), 24.1 [lib.iterator.requirements]
27312027Sjungma@eit.uni-kl.de
27412027Sjungma@eit.uni-kl.de  typedef typename base_type::difference_type difference_type;
27512027Sjungma@eit.uni-kl.de  typedef typename base_type::reference       reference;
27612027Sjungma@eit.uni-kl.de  typedef typename base_type::pointer         pointer;
27712027Sjungma@eit.uni-kl.de
27812027Sjungma@eit.uni-kl.de  sc_vector_iter() : access_policy(), it_() {}
27912027Sjungma@eit.uni-kl.de
28012027Sjungma@eit.uni-kl.de  // iterator conversions to more const, and/or direct iterators
28112027Sjungma@eit.uni-kl.de  template< typename OtherElement, typename OtherPolicy >
28212027Sjungma@eit.uni-kl.de  sc_vector_iter( const sc_vector_iter<OtherElement, OtherPolicy>& it
28312027Sjungma@eit.uni-kl.de      , typename sc_meta::enable_if<sc_meta::is_more_const<
28412027Sjungma@eit.uni-kl.de                     element_type,
28512027Sjungma@eit.uni-kl.de                     typename OtherPolicy::element_type>::value>::type* = NULL)
28612027Sjungma@eit.uni-kl.de    : access_policy( it.get_policy() ), it_( it.it_ )
28712027Sjungma@eit.uni-kl.de  {}
28812027Sjungma@eit.uni-kl.de
28912027Sjungma@eit.uni-kl.de  // step
29012027Sjungma@eit.uni-kl.de  this_type& operator++(){ ++it_; return *this; }
29112027Sjungma@eit.uni-kl.de  this_type& operator--(){ --it_; return *this; }
29212027Sjungma@eit.uni-kl.de  this_type  operator++(int){ this_type old(*this); ++it_; return old; }
29312027Sjungma@eit.uni-kl.de  this_type  operator--(int){ this_type old(*this); --it_; return old; }
29412027Sjungma@eit.uni-kl.de
29512027Sjungma@eit.uni-kl.de  // advance
29612027Sjungma@eit.uni-kl.de  this_type  operator+( difference_type n ) const
29712027Sjungma@eit.uni-kl.de    { return this_type( it_ + n, get_policy()); }
29812027Sjungma@eit.uni-kl.de  this_type  operator-( difference_type n ) const
29912027Sjungma@eit.uni-kl.de    { return this_type( it_ - n, get_policy()); }
30012027Sjungma@eit.uni-kl.de
30112027Sjungma@eit.uni-kl.de  this_type& operator+=( difference_type n ) { it_+=n; return *this; }
30212027Sjungma@eit.uni-kl.de  this_type& operator-=( difference_type n ) { it_-=n; return *this; }
30312027Sjungma@eit.uni-kl.de
30412027Sjungma@eit.uni-kl.de  // relations
30512027Sjungma@eit.uni-kl.de  bool operator== ( const this_type& that ) const { return it_ == that.it_; }
30612027Sjungma@eit.uni-kl.de  bool operator!= ( const this_type& that ) const { return it_ != that.it_; }
30712027Sjungma@eit.uni-kl.de  bool operator<= ( const this_type& that ) const { return it_ <= that.it_; }
30812027Sjungma@eit.uni-kl.de  bool operator>= ( const this_type& that ) const { return it_ >= that.it_; }
30912027Sjungma@eit.uni-kl.de  bool operator<  ( const this_type& that ) const { return it_ < that.it_; }
31012027Sjungma@eit.uni-kl.de  bool operator>  ( const this_type& that ) const { return it_ > that.it_; }
31112027Sjungma@eit.uni-kl.de
31212027Sjungma@eit.uni-kl.de  // dereference
31312027Sjungma@eit.uni-kl.de  reference operator*() const
31412027Sjungma@eit.uni-kl.de    { return *access_policy::get( static_cast<element_type*>(*it_) ); }
31512027Sjungma@eit.uni-kl.de  pointer   operator->() const
31612027Sjungma@eit.uni-kl.de    { return access_policy::get( static_cast<element_type*>(*it_) ); }
31712027Sjungma@eit.uni-kl.de  reference operator[]( difference_type n ) const
31812027Sjungma@eit.uni-kl.de    { return *access_policy::get( static_cast<element_type*>(it_[n]) ); }
31912027Sjungma@eit.uni-kl.de
32012027Sjungma@eit.uni-kl.de  // distance
32112027Sjungma@eit.uni-kl.de  difference_type operator-( this_type const& that ) const
32212027Sjungma@eit.uni-kl.de    { return it_-that.it_; }
32312027Sjungma@eit.uni-kl.de
32412027Sjungma@eit.uni-kl.de}; // sc_vector_iter
32512027Sjungma@eit.uni-kl.de
32612027Sjungma@eit.uni-kl.detemplate< typename T >
32712027Sjungma@eit.uni-kl.declass sc_vector
32812027Sjungma@eit.uni-kl.de  : public sc_vector_base
32912027Sjungma@eit.uni-kl.de{
33012027Sjungma@eit.uni-kl.de  typedef sc_vector_base base_type;
33112027Sjungma@eit.uni-kl.de  typedef sc_vector<T>   this_type;
33212027Sjungma@eit.uni-kl.de
33312027Sjungma@eit.uni-kl.depublic:
33412027Sjungma@eit.uni-kl.de  typedef T element_type;
33512027Sjungma@eit.uni-kl.de  typedef sc_vector_iter< element_type >       iterator;
33612027Sjungma@eit.uni-kl.de  typedef sc_vector_iter< const element_type > const_iterator;
33712027Sjungma@eit.uni-kl.de
33812027Sjungma@eit.uni-kl.de  sc_vector(){}
33912027Sjungma@eit.uni-kl.de
34012027Sjungma@eit.uni-kl.de  explicit sc_vector( const char* prefix )
34112027Sjungma@eit.uni-kl.de    : base_type( prefix )
34212027Sjungma@eit.uni-kl.de  {}
34312027Sjungma@eit.uni-kl.de
34412027Sjungma@eit.uni-kl.de  explicit sc_vector( const char* prefix, size_type n )
34512027Sjungma@eit.uni-kl.de    : base_type( prefix )
34612027Sjungma@eit.uni-kl.de    { init(n); }
34712027Sjungma@eit.uni-kl.de
34812027Sjungma@eit.uni-kl.de  template< typename Creator >
34912027Sjungma@eit.uni-kl.de  sc_vector( const char* prefix, size_type n, Creator creator )
35012027Sjungma@eit.uni-kl.de    : base_type( prefix )
35112027Sjungma@eit.uni-kl.de  {
35212027Sjungma@eit.uni-kl.de    init( n, creator );
35312027Sjungma@eit.uni-kl.de  }
35412027Sjungma@eit.uni-kl.de
35512027Sjungma@eit.uni-kl.de  virtual ~sc_vector();
35612027Sjungma@eit.uni-kl.de
35712027Sjungma@eit.uni-kl.de  element_type& operator[]( size_type i )
35812027Sjungma@eit.uni-kl.de    { return *static_cast<element_type*>( base_type::at(i) ); }
35912027Sjungma@eit.uni-kl.de
36012027Sjungma@eit.uni-kl.de  element_type& at( size_type i )
36112027Sjungma@eit.uni-kl.de    { check_index(i); return (*this)[i]; }
36212027Sjungma@eit.uni-kl.de
36312027Sjungma@eit.uni-kl.de  const element_type& operator[]( size_type i ) const
36412027Sjungma@eit.uni-kl.de    { return *static_cast<element_type const *>( base_type::at(i) ); }
36512027Sjungma@eit.uni-kl.de
36612027Sjungma@eit.uni-kl.de  const element_type& at( size_type i ) const
36712027Sjungma@eit.uni-kl.de    { check_index(i); return (*this)[i]; }
36812027Sjungma@eit.uni-kl.de
36912027Sjungma@eit.uni-kl.de  void init( size_type n )
37012027Sjungma@eit.uni-kl.de    { init( n, &this_type::create_element ); }
37112027Sjungma@eit.uni-kl.de
37212027Sjungma@eit.uni-kl.de  template< typename Creator >
37312027Sjungma@eit.uni-kl.de  void init( size_type n, Creator c );
37412027Sjungma@eit.uni-kl.de
37512027Sjungma@eit.uni-kl.de  static element_type * create_element( const char* prefix, size_type index );
37612027Sjungma@eit.uni-kl.de
37712027Sjungma@eit.uni-kl.de  iterator begin() { return base_type::begin(); }
37812027Sjungma@eit.uni-kl.de  iterator end()   { return base_type::end();   }
37912027Sjungma@eit.uni-kl.de
38012027Sjungma@eit.uni-kl.de  const_iterator begin()  const { return base_type::begin(); }
38112027Sjungma@eit.uni-kl.de  const_iterator end()    const { return base_type::end(); }
38212027Sjungma@eit.uni-kl.de
38312027Sjungma@eit.uni-kl.de  const_iterator cbegin() const { return base_type::begin(); }
38412027Sjungma@eit.uni-kl.de  const_iterator cend()   const { return base_type::end(); }
38512027Sjungma@eit.uni-kl.de
38612027Sjungma@eit.uni-kl.de  template< typename ContainerType, typename ArgumentType >
38712027Sjungma@eit.uni-kl.de  iterator bind( sc_vector_assembly<ContainerType,ArgumentType> c )
38812027Sjungma@eit.uni-kl.de    { return bind( c.begin(), c.end() ); }
38912027Sjungma@eit.uni-kl.de
39012027Sjungma@eit.uni-kl.de  template< typename BindableContainer >
39112027Sjungma@eit.uni-kl.de  iterator bind( BindableContainer & c )
39212027Sjungma@eit.uni-kl.de    { return bind( c.begin(), c.end() ); }
39312027Sjungma@eit.uni-kl.de
39412027Sjungma@eit.uni-kl.de  template< typename BindableIterator >
39512027Sjungma@eit.uni-kl.de  iterator bind( BindableIterator first, BindableIterator last )
39612027Sjungma@eit.uni-kl.de    { return bind( first, last, this->begin() ); }
39712027Sjungma@eit.uni-kl.de
39812027Sjungma@eit.uni-kl.de  template< typename BindableIterator >
39912027Sjungma@eit.uni-kl.de  iterator bind( BindableIterator first, BindableIterator last
40012027Sjungma@eit.uni-kl.de               , iterator from )
40112027Sjungma@eit.uni-kl.de    { return sc_vector_do_bind( *this, first, last, from ); }
40212027Sjungma@eit.uni-kl.de
40312027Sjungma@eit.uni-kl.de  template< typename ContainerType, typename ArgumentType >
40412027Sjungma@eit.uni-kl.de  iterator operator()( sc_vector_assembly<ContainerType,ArgumentType> c )
40512027Sjungma@eit.uni-kl.de    { return operator()( c.begin(), c.end() ); }
40612027Sjungma@eit.uni-kl.de
40712027Sjungma@eit.uni-kl.de  template< typename ArgumentContainer >
40812027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentContainer & c )
40912027Sjungma@eit.uni-kl.de    { return operator()( c.begin(), c.end() ); }
41012027Sjungma@eit.uni-kl.de
41112027Sjungma@eit.uni-kl.de  template< typename ArgumentIterator >
41212027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentIterator first, ArgumentIterator last )
41312027Sjungma@eit.uni-kl.de    { return operator()( first, last, this->begin() ); }
41412027Sjungma@eit.uni-kl.de
41512027Sjungma@eit.uni-kl.de  template< typename ArgumentIterator >
41612027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentIterator first, ArgumentIterator last
41712027Sjungma@eit.uni-kl.de                     , iterator from )
41812027Sjungma@eit.uni-kl.de    { return sc_vector_do_operator_paren( *this, first, last, from ); }
41912027Sjungma@eit.uni-kl.de
42012027Sjungma@eit.uni-kl.de  // member-wise access
42112027Sjungma@eit.uni-kl.de
42212027Sjungma@eit.uni-kl.de  template< typename MT >
42312027Sjungma@eit.uni-kl.de  sc_vector_assembly<T,MT> assemble( MT (T::*member_ptr) )
42412027Sjungma@eit.uni-kl.de    { return sc_vector_assembly<T,MT>( *this, member_ptr ); }
42512027Sjungma@eit.uni-kl.de
42612027Sjungma@eit.uni-kl.deprotected:
42712027Sjungma@eit.uni-kl.de
42812027Sjungma@eit.uni-kl.de  void clear();
42912027Sjungma@eit.uni-kl.de
43012027Sjungma@eit.uni-kl.de  virtual sc_object* object_cast( void* p ) const
43112027Sjungma@eit.uni-kl.de    { return implicit_cast( static_cast<element_type*>(p) ); }
43212027Sjungma@eit.uni-kl.de
43312027Sjungma@eit.uni-kl.de};
43412027Sjungma@eit.uni-kl.de
43512027Sjungma@eit.uni-kl.detemplate< typename T, typename MT >
43612027Sjungma@eit.uni-kl.declass sc_vector_assembly
43712027Sjungma@eit.uni-kl.de{
43812027Sjungma@eit.uni-kl.de  template< typename U > friend class sc_vector;
43912027Sjungma@eit.uni-kl.de
44012027Sjungma@eit.uni-kl.depublic:
44112027Sjungma@eit.uni-kl.de
44212027Sjungma@eit.uni-kl.de  typedef sc_vector<T> base_type;
44312027Sjungma@eit.uni-kl.de
44412027Sjungma@eit.uni-kl.de  typedef sc_vector_iter< T, sc_member_access<T, MT> >          iterator;
44512027Sjungma@eit.uni-kl.de  typedef sc_vector_iter< const T
44612027Sjungma@eit.uni-kl.de                        , sc_member_access<const T, const MT> > const_iterator;
44712027Sjungma@eit.uni-kl.de
44812027Sjungma@eit.uni-kl.de  typedef T  element_type;
44912027Sjungma@eit.uni-kl.de  typedef MT access_type;
45012027Sjungma@eit.uni-kl.de
45112027Sjungma@eit.uni-kl.de  typedef typename base_type::size_type       size_type;
45212027Sjungma@eit.uni-kl.de  typedef typename base_type::difference_type difference_type;
45312027Sjungma@eit.uni-kl.de  typedef typename iterator::reference        reference;
45412027Sjungma@eit.uni-kl.de  typedef typename iterator::pointer          pointer;
45512027Sjungma@eit.uni-kl.de  typedef typename const_iterator::reference  const_reference;
45612027Sjungma@eit.uni-kl.de  typedef typename const_iterator::pointer    const_pointer;
45712027Sjungma@eit.uni-kl.de
45812027Sjungma@eit.uni-kl.de
45912027Sjungma@eit.uni-kl.de  typedef access_type (T::*member_type);
46012027Sjungma@eit.uni-kl.de
46112027Sjungma@eit.uni-kl.de  const char* name() const { return vec_->name(); }
46212027Sjungma@eit.uni-kl.de  const char* kind() const { return "sc_vector_assembly"; }
46312027Sjungma@eit.uni-kl.de
46412027Sjungma@eit.uni-kl.de  iterator begin()
46512027Sjungma@eit.uni-kl.de    { return iterator( (*vec_).begin().it_, ptr_ ); }
46612027Sjungma@eit.uni-kl.de  iterator end()
46712027Sjungma@eit.uni-kl.de    { return iterator( (*vec_).end().it_, ptr_ ); }
46812027Sjungma@eit.uni-kl.de
46912027Sjungma@eit.uni-kl.de  const_iterator cbegin() const
47012027Sjungma@eit.uni-kl.de    { return const_iterator( (*vec_).cbegin().it_, ptr_ ); }
47112027Sjungma@eit.uni-kl.de  const_iterator cend() const
47212027Sjungma@eit.uni-kl.de    { return const_iterator( (*vec_).cend().it_, ptr_ ); }
47312027Sjungma@eit.uni-kl.de
47412027Sjungma@eit.uni-kl.de  const_iterator begin() const
47512027Sjungma@eit.uni-kl.de    { return const_iterator( (*vec_).begin().it_, ptr_ ); }
47612027Sjungma@eit.uni-kl.de  const_iterator end()   const
47712027Sjungma@eit.uni-kl.de    { return const_iterator( (*vec_).end().it_, ptr_ ); }
47812027Sjungma@eit.uni-kl.de
47912027Sjungma@eit.uni-kl.de  size_type size() const { return vec_->size(); }
48012027Sjungma@eit.uni-kl.de  const std::vector< sc_object* > & get_elements() const;
48112027Sjungma@eit.uni-kl.de
48212027Sjungma@eit.uni-kl.de  reference operator[]( size_type idx )
48312027Sjungma@eit.uni-kl.de    { return (*vec_)[idx].*ptr_; }
48412027Sjungma@eit.uni-kl.de  reference at( size_type idx )
48512027Sjungma@eit.uni-kl.de    { return vec_->at(idx).*ptr_; }
48612027Sjungma@eit.uni-kl.de  const_reference operator[]( size_type idx ) const
48712027Sjungma@eit.uni-kl.de    { return (*vec_)[idx].*ptr_; }
48812027Sjungma@eit.uni-kl.de  const_reference at( size_type idx ) const
48912027Sjungma@eit.uni-kl.de    { return vec_->at(idx).*ptr_; }
49012027Sjungma@eit.uni-kl.de
49112027Sjungma@eit.uni-kl.de  template< typename ContainerType, typename ArgumentType >
49212027Sjungma@eit.uni-kl.de  iterator bind( sc_vector_assembly<ContainerType,ArgumentType> c )
49312027Sjungma@eit.uni-kl.de    { return bind( c.begin(), c.end() ); }
49412027Sjungma@eit.uni-kl.de
49512027Sjungma@eit.uni-kl.de  template< typename BindableContainer >
49612027Sjungma@eit.uni-kl.de  iterator bind( BindableContainer & c )
49712027Sjungma@eit.uni-kl.de    { return bind( c.begin(), c.end() ); }
49812027Sjungma@eit.uni-kl.de
49912027Sjungma@eit.uni-kl.de  template< typename BindableIterator >
50012027Sjungma@eit.uni-kl.de  iterator bind( BindableIterator first, BindableIterator last )
50112027Sjungma@eit.uni-kl.de    { return bind( first, last, this->begin() ); }
50212027Sjungma@eit.uni-kl.de
50312027Sjungma@eit.uni-kl.de  template< typename BindableIterator >
50412027Sjungma@eit.uni-kl.de  iterator bind( BindableIterator first, BindableIterator last
50512027Sjungma@eit.uni-kl.de               , iterator from )
50612027Sjungma@eit.uni-kl.de    { return sc_vector_do_bind( *this, first, last, from ); }
50712027Sjungma@eit.uni-kl.de
50812027Sjungma@eit.uni-kl.de  template< typename BindableIterator >
50912027Sjungma@eit.uni-kl.de  iterator bind( BindableIterator first, BindableIterator last
51012027Sjungma@eit.uni-kl.de               , typename base_type::iterator from )
51112027Sjungma@eit.uni-kl.de    { return bind( first, last, iterator(from.it_, ptr_) ); }
51212027Sjungma@eit.uni-kl.de
51312027Sjungma@eit.uni-kl.de  template< typename ContainerType, typename ArgumentType >
51412027Sjungma@eit.uni-kl.de  iterator operator()( sc_vector_assembly<ContainerType,ArgumentType> c )
51512027Sjungma@eit.uni-kl.de    { return operator()( c.begin(), c.end() ); }
51612027Sjungma@eit.uni-kl.de
51712027Sjungma@eit.uni-kl.de  template< typename ArgumentContainer >
51812027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentContainer & c )
51912027Sjungma@eit.uni-kl.de    { return operator()( c.begin(), c.end() ); }
52012027Sjungma@eit.uni-kl.de
52112027Sjungma@eit.uni-kl.de  template< typename ArgumentIterator >
52212027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentIterator first, ArgumentIterator last )
52312027Sjungma@eit.uni-kl.de    { return operator()( first, last, this->begin() ); }
52412027Sjungma@eit.uni-kl.de
52512027Sjungma@eit.uni-kl.de  template< typename ArgumentIterator >
52612027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentIterator first, ArgumentIterator last
52712027Sjungma@eit.uni-kl.de                     , iterator from )
52812027Sjungma@eit.uni-kl.de    { return sc_vector_do_operator_paren( *this, first, last, from ); }
52912027Sjungma@eit.uni-kl.de
53012027Sjungma@eit.uni-kl.de  template< typename ArgumentIterator >
53112027Sjungma@eit.uni-kl.de  iterator operator()( ArgumentIterator first, ArgumentIterator last
53212027Sjungma@eit.uni-kl.de                     , typename base_type::iterator from )
53312027Sjungma@eit.uni-kl.de    { return operator()( first, last, iterator(from.it_, ptr_) ); }
53412027Sjungma@eit.uni-kl.de
53512027Sjungma@eit.uni-kl.de  sc_vector_assembly( const sc_vector_assembly & other )
53612027Sjungma@eit.uni-kl.de    : vec_( other.vec_ )
53712027Sjungma@eit.uni-kl.de    , ptr_( other.ptr_ )
53812027Sjungma@eit.uni-kl.de    , child_vec_(0)
53912027Sjungma@eit.uni-kl.de  {}
54012027Sjungma@eit.uni-kl.de
54112027Sjungma@eit.uni-kl.de  sc_vector_assembly& operator=( sc_vector_assembly other_copy )
54212027Sjungma@eit.uni-kl.de  {
54312027Sjungma@eit.uni-kl.de    swap( other_copy );
54412027Sjungma@eit.uni-kl.de    return *this;
54512027Sjungma@eit.uni-kl.de  }
54612027Sjungma@eit.uni-kl.de
54712027Sjungma@eit.uni-kl.de  void swap( sc_vector_assembly & that )
54812027Sjungma@eit.uni-kl.de  {
54912027Sjungma@eit.uni-kl.de    using std::swap;
55012027Sjungma@eit.uni-kl.de    swap( vec_,       that.vec_ );
55112027Sjungma@eit.uni-kl.de    swap( ptr_,       that.ptr_ );
55212027Sjungma@eit.uni-kl.de    swap( child_vec_, that.child_vec_ );
55312027Sjungma@eit.uni-kl.de  }
55412027Sjungma@eit.uni-kl.de
55512027Sjungma@eit.uni-kl.de  void report_empty_bind( const char* kind_, bool dst_empty_ ) const
55612027Sjungma@eit.uni-kl.de    { vec_->report_empty_bind( kind_, dst_empty_ ); }
55712027Sjungma@eit.uni-kl.de
55812027Sjungma@eit.uni-kl.de  ~sc_vector_assembly()
55912027Sjungma@eit.uni-kl.de    { delete child_vec_; }
56012027Sjungma@eit.uni-kl.de
56112027Sjungma@eit.uni-kl.deprivate:
56212027Sjungma@eit.uni-kl.de
56312027Sjungma@eit.uni-kl.de  sc_vector_assembly( base_type & v, member_type ptr )
56412027Sjungma@eit.uni-kl.de    : vec_(&v)
56512027Sjungma@eit.uni-kl.de    , ptr_(ptr)
56612027Sjungma@eit.uni-kl.de    , child_vec_(0)
56712027Sjungma@eit.uni-kl.de  {}
56812027Sjungma@eit.uni-kl.de
56912027Sjungma@eit.uni-kl.de  sc_object* object_cast( pointer p ) const
57012027Sjungma@eit.uni-kl.de    { return vec_->implicit_cast( p ); }
57112027Sjungma@eit.uni-kl.de
57212027Sjungma@eit.uni-kl.de  base_type * vec_;
57312027Sjungma@eit.uni-kl.de  member_type ptr_;
57412027Sjungma@eit.uni-kl.de
57512027Sjungma@eit.uni-kl.de  mutable std::vector< sc_object* >* child_vec_;
57612027Sjungma@eit.uni-kl.de};
57712027Sjungma@eit.uni-kl.de
57812027Sjungma@eit.uni-kl.detemplate< typename T, typename MT >
57912027Sjungma@eit.uni-kl.desc_vector_assembly<T,MT>
58012027Sjungma@eit.uni-kl.desc_assemble_vector( sc_vector<T> & vec, MT (T::*ptr) )
58112027Sjungma@eit.uni-kl.de{
58212027Sjungma@eit.uni-kl.de  return vec.assemble( ptr );
58312027Sjungma@eit.uni-kl.de}
58412027Sjungma@eit.uni-kl.de
58512027Sjungma@eit.uni-kl.detemplate< typename T >
58612027Sjungma@eit.uni-kl.detypename sc_vector<T>::element_type *
58712027Sjungma@eit.uni-kl.desc_vector<T>::create_element( const char* name, size_type /* idx */ )
58812027Sjungma@eit.uni-kl.de{
58912027Sjungma@eit.uni-kl.de  return new T( name );
59012027Sjungma@eit.uni-kl.de}
59112027Sjungma@eit.uni-kl.de
59212027Sjungma@eit.uni-kl.detemplate< typename T >
59312027Sjungma@eit.uni-kl.detemplate< typename Creator >
59412027Sjungma@eit.uni-kl.devoid
59512027Sjungma@eit.uni-kl.desc_vector<T>::init( size_type n, Creator c )
59612027Sjungma@eit.uni-kl.de{
59712027Sjungma@eit.uni-kl.de  if ( base_type::check_init(n) )
59812027Sjungma@eit.uni-kl.de  {
59912027Sjungma@eit.uni-kl.de    base_type::reserve( n );
60012027Sjungma@eit.uni-kl.de    try
60112027Sjungma@eit.uni-kl.de    {
60212027Sjungma@eit.uni-kl.de      for ( size_type i = 0; i<n; ++i )
60312027Sjungma@eit.uni-kl.de      {
60412027Sjungma@eit.uni-kl.de        // this workaround is needed for SystemC 2.2/2.3 sc_bind
60512027Sjungma@eit.uni-kl.de        std::string  name  = make_name( basename(), i );
60612027Sjungma@eit.uni-kl.de        const char*  cname = name.c_str();
60712027Sjungma@eit.uni-kl.de
60812027Sjungma@eit.uni-kl.de        void* p = c( cname, i ) ; // call Creator
60912027Sjungma@eit.uni-kl.de        base_type::push_back(p);
61012027Sjungma@eit.uni-kl.de      }
61112027Sjungma@eit.uni-kl.de    }
61212027Sjungma@eit.uni-kl.de    catch ( ... )
61312027Sjungma@eit.uni-kl.de    {
61412027Sjungma@eit.uni-kl.de      clear();
61512027Sjungma@eit.uni-kl.de      throw;
61612027Sjungma@eit.uni-kl.de    }
61712027Sjungma@eit.uni-kl.de  }
61812027Sjungma@eit.uni-kl.de}
61912027Sjungma@eit.uni-kl.de
62012027Sjungma@eit.uni-kl.detemplate< typename T >
62112027Sjungma@eit.uni-kl.devoid
62212027Sjungma@eit.uni-kl.desc_vector<T>::clear()
62312027Sjungma@eit.uni-kl.de{
62412027Sjungma@eit.uni-kl.de  size_type i = size();
62512027Sjungma@eit.uni-kl.de  while ( i --> 0 )
62612027Sjungma@eit.uni-kl.de  {
62712027Sjungma@eit.uni-kl.de    delete &( (*this)[i] );
62812027Sjungma@eit.uni-kl.de    base_type::at(i) = 0;
62912027Sjungma@eit.uni-kl.de  }
63012027Sjungma@eit.uni-kl.de  base_type::clear();
63112027Sjungma@eit.uni-kl.de}
63212027Sjungma@eit.uni-kl.de
63312027Sjungma@eit.uni-kl.detemplate< typename Container, typename ArgumentIterator >
63412027Sjungma@eit.uni-kl.detypename Container::iterator
63512027Sjungma@eit.uni-kl.desc_vector_do_bind( Container & cont
63612027Sjungma@eit.uni-kl.de                 , ArgumentIterator  first
63712027Sjungma@eit.uni-kl.de                 , ArgumentIterator  last
63812027Sjungma@eit.uni-kl.de                 , typename Container::iterator from )
63912027Sjungma@eit.uni-kl.de{
64012027Sjungma@eit.uni-kl.de  typename Container::iterator end = cont.end();
64112027Sjungma@eit.uni-kl.de
64212027Sjungma@eit.uni-kl.de  if( !cont.size() || from == end || first == last )
64312027Sjungma@eit.uni-kl.de      cont.report_empty_bind( cont.kind(), from == end );
64412027Sjungma@eit.uni-kl.de
64512027Sjungma@eit.uni-kl.de  while( from!=end && first != last )
64612027Sjungma@eit.uni-kl.de    (*from++).bind( *first++ );
64712027Sjungma@eit.uni-kl.de  return from;
64812027Sjungma@eit.uni-kl.de}
64912027Sjungma@eit.uni-kl.de
65012027Sjungma@eit.uni-kl.detemplate< typename Container, typename ArgumentIterator >
65112027Sjungma@eit.uni-kl.detypename Container::iterator
65212027Sjungma@eit.uni-kl.desc_vector_do_operator_paren( Container& cont
65312027Sjungma@eit.uni-kl.de                           , ArgumentIterator  first
65412027Sjungma@eit.uni-kl.de                           , ArgumentIterator  last
65512027Sjungma@eit.uni-kl.de                           , typename Container::iterator from )
65612027Sjungma@eit.uni-kl.de{
65712027Sjungma@eit.uni-kl.de  typename Container::iterator end = cont.end();
65812027Sjungma@eit.uni-kl.de
65912027Sjungma@eit.uni-kl.de  if( !cont.size() || from == end || first == last )
66012027Sjungma@eit.uni-kl.de      cont.report_empty_bind( cont.kind(), from == end );
66112027Sjungma@eit.uni-kl.de
66212027Sjungma@eit.uni-kl.de  while( from!=end && first != last )
66312027Sjungma@eit.uni-kl.de    (*from++)( *first++ );
66412027Sjungma@eit.uni-kl.de  return from;
66512027Sjungma@eit.uni-kl.de}
66612027Sjungma@eit.uni-kl.de
66712027Sjungma@eit.uni-kl.detemplate< typename T >
66812027Sjungma@eit.uni-kl.desc_vector<T>::~sc_vector()
66912027Sjungma@eit.uni-kl.de{
67012027Sjungma@eit.uni-kl.de  clear();
67112027Sjungma@eit.uni-kl.de}
67212027Sjungma@eit.uni-kl.de
67312027Sjungma@eit.uni-kl.detemplate< typename T, typename MT >
67412027Sjungma@eit.uni-kl.destd::vector< sc_object* > const &
67512027Sjungma@eit.uni-kl.desc_vector_assembly<T,MT>::get_elements() const
67612027Sjungma@eit.uni-kl.de{
67712027Sjungma@eit.uni-kl.de  if( !child_vec_ )
67812027Sjungma@eit.uni-kl.de    child_vec_ = new std::vector< sc_object* >;
67912027Sjungma@eit.uni-kl.de
68012027Sjungma@eit.uni-kl.de  if( child_vec_->size() || !size() )
68112027Sjungma@eit.uni-kl.de    return *child_vec_;
68212027Sjungma@eit.uni-kl.de
68312027Sjungma@eit.uni-kl.de  child_vec_->reserve( size() );
68412027Sjungma@eit.uni-kl.de  for( const_iterator it=begin(); it != end(); ++it )
68512027Sjungma@eit.uni-kl.de    if( sc_object * obj = object_cast( const_cast<MT*>(&*it) ) )
68612027Sjungma@eit.uni-kl.de      child_vec_->push_back( obj );
68712027Sjungma@eit.uni-kl.de
68812027Sjungma@eit.uni-kl.de  return *child_vec_;
68912027Sjungma@eit.uni-kl.de}
69012027Sjungma@eit.uni-kl.de
69112027Sjungma@eit.uni-kl.de} // namespace sc_core
69212027Sjungma@eit.uni-kl.de#undef SC_RPTYPE_
69312027Sjungma@eit.uni-kl.de#undef SC_ENABLE_IF_
69412027Sjungma@eit.uni-kl.de
69512027Sjungma@eit.uni-kl.de// $Log: sc_vector.h,v $
69612027Sjungma@eit.uni-kl.de// Revision 1.17  2011/08/26 20:46:20  acg
69712027Sjungma@eit.uni-kl.de//  Andy Goodrich: moved the modification log to the end of the file to
69812027Sjungma@eit.uni-kl.de//  eliminate source line number skew when check-ins are done.
69912027Sjungma@eit.uni-kl.de//
70012027Sjungma@eit.uni-kl.de// Revision 1.16  2011/07/25 10:21:17  acg
70112027Sjungma@eit.uni-kl.de//  Andy Goodrich: check in aftermath of call to automake.
70212027Sjungma@eit.uni-kl.de//
70312027Sjungma@eit.uni-kl.de// Revision 1.15  2011/04/02 00:04:32  acg
70412027Sjungma@eit.uni-kl.de//  Philipp A. Hartmann: fix distance from member iterators, and
70512027Sjungma@eit.uni-kl.de//  add iterator conversions.
70612027Sjungma@eit.uni-kl.de//
70712027Sjungma@eit.uni-kl.de// Revision 1.14  2011/04/01 22:35:19  acg
70812027Sjungma@eit.uni-kl.de//  Andy Goodrich: spelling fix.
70912027Sjungma@eit.uni-kl.de//
71012027Sjungma@eit.uni-kl.de// Revision 1.13  2011/03/28 13:03:09  acg
71112027Sjungma@eit.uni-kl.de//  Andy Goodrich: Philipp's latest update.
71212027Sjungma@eit.uni-kl.de//
71312027Sjungma@eit.uni-kl.de// Revision 1.12  2011/03/23 16:16:28  acg
71412027Sjungma@eit.uni-kl.de//  Philipp A. Hartmann: rebase implementation on void*
71512027Sjungma@eit.uni-kl.de//      - supports virtual inheritance from sc_object again
71612027Sjungma@eit.uni-kl.de//      - build up get_elements result on demand
71712027Sjungma@eit.uni-kl.de//      - still requires element type to be derived from sc_object
71812027Sjungma@eit.uni-kl.de//
71912027Sjungma@eit.uni-kl.de// Revision 1.11  2011/02/19 16:46:36  acg
72012027Sjungma@eit.uni-kl.de//  Andy Goodrich: finally get the update from Philipp correct!
72112027Sjungma@eit.uni-kl.de//
72212027Sjungma@eit.uni-kl.de
72312027Sjungma@eit.uni-kl.de#endif // SC_VECTOR_H_INCLUDED_
72412027Sjungma@eit.uni-kl.de// Taf!
725