00001
00002
00003
00012 #ifndef ATHCONTAINERS_TOOLS_DVLINFO_H
00013 #define ATHCONTAINERS_TOOLS_DVLINFO_H
00014
00015
00016 #include "AthContainers/tools/ClassID.h"
00017 #include "AthContainers/AuxVectorBase.h"
00018 #include <typeinfo>
00019 #include <cstddef>
00020
00021
00022 #if __cplusplus > 201100
00023 # include <type_traits>
00024 namespace SG_STD_OR_BOOST = std;
00025 #else
00026 # include "boost/type_traits/remove_const.hpp"
00027 # include "boost/type_traits/is_pointer.hpp"
00028 # include "boost/type_traits/is_base_of.hpp"
00029 namespace SG_STD_OR_BOOST = boost;
00030 #endif
00031
00032
00033
00034 namespace DataModel_detail {
00035
00036
00040 class DVLIteratorBase
00041 {
00042 public:
00044 virtual ~DVLIteratorBase() {}
00045
00046
00055 virtual const void* next() = 0;
00056 };
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 class DVLInfoBase
00077 {
00078 public:
00087 DVLInfoBase (const std::type_info& tinfo,
00088 const std::type_info& elt_tinfo);
00089
00090
00092 virtual ~DVLInfoBase() {}
00093
00094
00098 const std::type_info& tinfo() const;
00099
00100
00104 CLID clid() const;
00105
00106
00111 const std::type_info& elt_tinfo() const;
00112
00113
00119 virtual void* make (size_t nreserve) const = 0;
00120
00121
00128 virtual void push (void* cont_p, void* elt_p) const = 0;
00129
00130
00135 virtual size_t size (void* cont_p) const = 0;
00136
00137
00142 virtual void clear (void* cont_p) const = 0;
00143
00144
00149 virtual void del (void* cont_p) const = 0;
00150
00151
00156 virtual void* clone (void* cont_p) const = 0;
00157
00158
00163 virtual DVLIteratorBase* iterator (const void* cont_p) const = 0;
00164
00165
00170 virtual SG::AuxVectorBase* base (void* cont_p) const = 0;
00171
00172
00178 static DVLInfoBase* find (const std::type_info& tinfo);
00179
00180
00186 static DVLInfoBase* find (CLID clid);
00187
00188
00189 private:
00191 const std::type_info& m_tinfo;
00192
00194 const std::type_info& m_elt_tinfo;
00195 };
00196
00197
00198
00199
00200
00201
00202
00203
00204 template <class T>
00205 class DVLInfo
00206 : public DVLInfoBase
00207 {
00208 public:
00210 typedef T Container;
00211
00213 typedef typename
00214 SG_STD_OR_BOOST::remove_const<typename Container::base_value_type>::type
00215 Elt;
00216
00217
00223 DVLInfo();
00224
00225
00231 virtual void* make (size_t nreserve) const;
00232
00233
00240 virtual void push (void* cont_p, void* elt_p) const;
00241
00242
00247 virtual size_t size (void* cont_p) const;
00248
00249
00254 virtual void clear (void* cont_p) const;
00255
00256
00261 virtual void del (void* cont_p) const;
00262
00263
00268 virtual void* clone (void* cont_p) const;
00269
00270
00275 virtual DVLIteratorBase* iterator (const void* cont_p) const;
00276
00277
00282 virtual SG::AuxVectorBase* base (void* cont_p) const;
00283
00284
00292 static const std::type_info* initHelper();
00293 };
00294
00295
00296 template <class T>
00297 class DVLIterator
00298 : public DVLIteratorBase
00299 {
00300 public:
00301 typedef typename T::const_iterator base_iterator;
00302
00303
00309 DVLIterator (const base_iterator& beg, const base_iterator& end);
00310
00311
00320 virtual const void* next();
00321
00322
00323 private:
00324 typename T::const_iterator m_it;
00325 typename T::const_iterator m_end;
00326 };
00327
00328
00339 template <class T>
00340 void* dvl_convert (const T& src,
00341 const DVLInfoBase& targ_info);
00342
00343
00355 template <class T>
00356 void* dvl_convert (const T& src,
00357 const std::type_info& targ_tinfo,
00358 DVLInfoBase*& targ_info);
00359
00360
00372 template <class T>
00373 void* dvl_convert (const T& src,
00374 CLID clid,
00375 DVLInfoBase*& targ_info);
00376
00377
00387 template <class T>
00388 void dvl_update (const T& src,
00389 void* target,
00390 const DVLInfoBase* targ_info);
00391
00392
00393
00394 }
00395
00396
00397 #include "AthContainers/tools/DVLInfo.icc"
00398
00399
00400 #endif // not ATHCONTAINERS_TOOLS_DVLINFO_H