Changeset 51:48f953a87784 in finroc_plugins_data_ports


Ignore:
Timestamp:
07.01.2014 16:41:47 (6 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
13.10
Children:
52:68d27ab553b1, 53:c155c78f3ae6
Phase:
public
Message:
  • Bugfix: Concatenation of string and number uses std::to_string
  • Made recursion index stay in positive range to avoid narrowing types
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tPortPack.h

    r46 r51  
    7070 * \param TPort       A port class template to use for every packed port 
    7171 * \param TTypeList   A list of the data types used in the ports. e.g. rrlib::util::tTypeList 
    72  * \param Tindex      The pack creates ports using TTypeList[0] to TTypeList[Tindex]. This parameter must not be greater than TTypeList::cSIZE - 1 and is typically inferred and not set by the user. 
     72 * \param Tsize       The pack creates ports using TTypeList[0] to TTypeList[Tsize - 1]. This parameter must not be greater than TTypeList::cSIZE - 1 and is typically inferred and not set by the user. 
    7373 */ 
    74 template < template <typename> class TPort, typename TTypeList, size_t Tindex = TTypeList::cSIZE - 1 > 
    75 class tPortPack : private tPortPack < TPort, TTypeList, Tindex - 1 > 
     74template <template <typename> class TPort, typename TTypeList, size_t Tsize = rrlib::util::type_list::tSizeOf<TTypeList>::cVALUE> 
     75class tPortPack : private tPortPack < TPort, TTypeList, Tsize - 1 > 
    7676{ 
    7777 
     
    8282 
    8383  inline tPortPack(core::tFrameworkElement *parent, const std::string &name_prefix) : 
    84     tPortPack < TPort, TTypeList, Tindex - 1 > (parent, name_prefix), 
    85     port(name_prefix + std::to_string(Tindex + 1), parent) 
     84    tPortPack < TPort, TTypeList, Tsize - 1 > (parent, name_prefix), 
     85    port(name_prefix + std::to_string(Tsize), parent) 
    8686  { 
    8787    this->port.Init(); 
     
    9090  template <typename TIterator> 
    9191  inline tPortPack(core::tFrameworkElement *parent, TIterator names_begin, TIterator names_end) : 
    92     tPortPack < TPort, TTypeList, Tindex - 1 > (parent, names_begin, names_end - 1), 
     92    tPortPack < TPort, TTypeList, Tsize - 1 > (parent, names_begin, names_end - 1), 
    9393    port(names_end - 1, parent) 
    9494  { 
     
    9898  inline size_t NumberOfPorts() const 
    9999  { 
    100     return Tindex + 1; 
     100    return Tsize; 
    101101  } 
    102102 
     
    104104  { 
    105105    assert(index < this->NumberOfPorts()); 
    106     if (index == Tindex) 
     106    if (index == Tsize - 1) 
    107107    { 
    108108      return this->port; 
    109109    } 
    110     return tPortPack < TPort, TTypeList, Tindex - 1 >::GetPort(index); 
     110    return tPortPack < TPort, TTypeList, Tsize - 1 >::GetPort(index); 
    111111  } 
    112112 
     
    114114  { 
    115115    this->port.GetWrapped()->ManagedDelete(); 
    116     tPortPack < TPort, TTypeList, Tindex - 1 >::ManagedDelete(); 
     116    tPortPack < TPort, TTypeList, Tsize - 1 >::ManagedDelete(); 
    117117  } 
    118118 
     
    123123private: 
    124124 
    125   TPort<typename TTypeList::template tAt<Tindex>::tResult> port; 
     125  TPort < typename TTypeList::template tAt < Tsize - 1 >::tResult > port; 
    126126 
    127127}; 
     
    129129//! The partial specialization of tPortPack to terminate recursion 
    130130template <template <typename> class TPort, typename TTypeList> 
    131 struct tPortPack < TPort, TTypeList, -1 > 
     131struct tPortPack <TPort, TTypeList, 0> 
    132132{ 
    133133  inline tPortPack(core::tFrameworkElement *parent, const std::string &name_prefix) 
Note: See TracChangeset for help on using the changeset viewer.