source: rrlib_util/tTypeList.h @ 34:ab31d5f0532b

Last change on this file since 34:ab31d5f0532b was 34:ab31d5f0532b, checked in by Tobias Föhst <foehst@…>, 8 years ago

Updated and added old/missing copyright notes

File size: 5.0 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20//
21//----------------------------------------------------------------------
22/*!\file    tTypeList.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2011-03-25
27 *
28 * \brief Contains tTypeList
29 *
30 * \b tTypeList
31 *
32 */
33//----------------------------------------------------------------------
34#ifndef __rrlib__util__tTypeList_h__
35#define __rrlib__util__tTypeList_h__
36
37//----------------------------------------------------------------------
38// External includes (system with <>, local with "")
39//----------------------------------------------------------------------
40
41//----------------------------------------------------------------------
42// Internal includes with ""
43//----------------------------------------------------------------------
44#define __rrlib__util__type_list__include_guard__
45
46#include "rrlib/util/type_list/definitions.h"
47
48#include "rrlib/util/type_list/tSizeOf.h"
49#include "rrlib/util/type_list/tAt.h"
50#include "rrlib/util/type_list/tFind.h"
51#include "rrlib/util/type_list/tAppend.h"
52#include "rrlib/util/type_list/tRemove.h"
53#include "rrlib/util/type_list/tRemoveAll.h"
54#include "rrlib/util/type_list/tUnique.h"
55#include "rrlib/util/type_list/tReplace.h"
56#include "rrlib/util/type_list/tReplaceAll.h"
57#include "rrlib/util/type_list/tMostDerived.h"
58#include "rrlib/util/type_list/tDerivedToFront.h"
59
60#undef __rrlib__util__type_list__include_guard__
61
62//----------------------------------------------------------------------
63// Debugging
64//----------------------------------------------------------------------
65
66//----------------------------------------------------------------------
67// Namespace declaration
68//----------------------------------------------------------------------
69namespace rrlib
70{
71namespace util
72{
73
74//----------------------------------------------------------------------
75// Forward declarations / typedefs / enums
76//----------------------------------------------------------------------
77
78//----------------------------------------------------------------------
79// Class declaration
80//----------------------------------------------------------------------
81//!
82/*!
83 *
84 */
85namespace
86{
87
88template <typename THead, typename TTail>
89class tTypeListBase
90{
91  typedef tTypeList<THead, TTail> tList;
92
93public:
94
95  typedef THead tHead;
96  typedef TTail tTail;
97
98  static const size_t cSIZE = type_list::tSizeOf<tList>::cVALUE;
99
100  template <size_t Tindex>
101  struct tAt
102  {
103    typedef typename type_list::tAt<tList, Tindex>::tResult tResult;
104  };
105
106  template <typename TType>
107  struct tIndexOf
108  {
109    static const size_t cVALUE = type_list::tFind<tList, TType>::cINDEX;
110  };
111
112  template <typename TType>
113  struct tAppend
114  {
115    typedef typename type_list::tAppend<tList, TType>::tResult tResult;
116  };
117
118  template <typename TType>
119  struct tRemove
120  {
121    typedef typename type_list::tRemove<tList, TType>::tResult tResult;
122  };
123
124  template <typename TType>
125  struct tRemoveAll
126  {
127    typedef typename type_list::tRemoveAll<tList, TType>::tResult tResult;
128  };
129
130  struct tUnique
131  {
132    typedef typename type_list::tUnique<tList>::tResult tResult;
133  };
134
135  template <typename TOldType, typename TNewType>
136  struct tReplace
137  {
138    typedef typename type_list::tReplace<tList, TOldType, TNewType>::tResult tResult;
139  };
140
141  template <typename TOldType, typename TNewType>
142  struct tReplaceAll
143  {
144    typedef typename type_list::tReplaceAll<tList, TOldType, TNewType>::tResult tResult;
145  };
146
147  template <typename TBase>
148  struct tMostDerived
149  {
150    typedef typename type_list::tMostDerived<tList, TBase>::tResult tResult;
151  };
152
153  struct tDerivedToFront
154  {
155    typedef typename type_list::tDerivedToFront<tList>::tResult tResult;
156  };
157
158};
159
160}
161
162template <typename THead>
163struct tTypeList<THead> : public tTypeListBase<THead, type_list::tEmptyList>
164  {};
165
166template <typename THead, typename ... TTail>
167struct tTypeList<THead, TTail...> : public tTypeListBase<THead, tTypeList<TTail...>>
168  {};
169
170template <typename THead, typename ... TTail>
171struct tTypeList<THead, tTypeList<TTail...>> : public tTypeListBase<THead, tTypeList<TTail...>>
172  {};
173
174//----------------------------------------------------------------------
175// End of namespace declaration
176//----------------------------------------------------------------------
177}
178}
179
180#endif
Note: See TracBrowser for help on using the repository browser.