1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
#ifndef DataFormats_Common_fillPtrVector_h
#define DataFormats_Common_fillPtrVector_h
// -*- C++ -*-
//
// Package: Common
// Class : fillPtrVector
//
/**\class fillPtrVector fillPtrVector.h DataFormats/Common/interface/fillPtrVector.h
Description: Helper function used to implement the edm::Ptr class
Usage:
This is an internal detail of edm::Ptr interaction with edm::Wrapper and should not be used by others
*/
//
// Original Author: Chris Jones
// Created: Sat Oct 20 11:45:38 CEST 2007
//
// system include files
// user include files
#include "DataFormats/Common/interface/FillView.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/OffsetToBase.h"
#include "DataFormats/Common/interface/fwd_fillPtrVector.h"
#include <typeinfo>
#include <vector>
// forward declarations
namespace edm {
namespace detail {
template <typename COLLECTION>
void reallyfillPtrVector(COLLECTION const& coll,
std::type_info const& iToType,
std::vector<unsigned long> const& iIndicies,
std::vector<void const*>& oPtr) {
typedef COLLECTION product_type;
typedef typename GetProduct<product_type>::element_type element_type;
typedef typename product_type::const_iterator iter;
oPtr.reserve(iIndicies.size());
if (iToType == typeid(element_type)) {
for (std::vector<unsigned long>::const_iterator itIndex = iIndicies.begin(), itEnd = iIndicies.end();
itIndex != itEnd;
++itIndex) {
iter it = coll.begin();
std::advance(it, *itIndex);
element_type const* address = GetProduct<product_type>::address(it);
oPtr.push_back(address);
}
} else {
for (std::vector<unsigned long>::const_iterator itIndex = iIndicies.begin(), itEnd = iIndicies.end();
itIndex != itEnd;
++itIndex) {
iter it = coll.begin();
std::advance(it, *itIndex);
element_type const* address = GetProduct<product_type>::address(it);
void const* ptr = pointerToBase(iToType, address);
if (nullptr != ptr) {
oPtr.push_back(ptr);
} else {
Exception::throwThis(errors::LogicError,
"TypeConversionError "
"edm::PtrVector<> : unable to convert type ",
typeid(element_type).name(),
" to ",
iToType.name(),
"\n");
}
}
}
}
} // namespace detail
template <typename T, typename A>
void fillPtrVector(std::vector<T, A> const& obj,
std::type_info const& iToType,
std::vector<unsigned long> const& iIndicies,
std::vector<void const*>& oPtr) {
detail::reallyfillPtrVector(obj, iToType, iIndicies, oPtr);
}
template <typename T, typename A>
void fillPtrVector(std::list<T, A> const& obj,
std::type_info const& iToType,
std::vector<unsigned long> const& iIndicies,
std::vector<void const*>& oPtr) {
detail::reallyfillPtrVector(obj, iToType, iIndicies, oPtr);
}
template <typename T, typename A>
void fillPtrVector(std::deque<T, A> const& obj,
std::type_info const& iToType,
std::vector<unsigned long> const& iIndicies,
std::vector<void const*>& oPtr) {
detail::reallyfillPtrVector(obj, iToType, iIndicies, oPtr);
}
template <typename T, typename A, typename Comp>
void fillPtrVector(std::set<T, A, Comp> const& obj,
std::type_info const& iToType,
std::vector<unsigned long> const& iIndicies,
std::vector<void const*>& oPtr) {
detail::reallyfillPtrVector(obj, iToType, iIndicies, oPtr);
}
} // namespace edm
#endif
|