ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
Navigation
Navigation
NavigableVector.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef NAVIGATION_NAVIGABLEVECTOR_H
6
#define NAVIGATION_NAVIGABLEVECTOR_H
8
// Simple container for navigable objects. //
10
11
#include "
AthLinks/tools/GenerateIndexingPolicy.h
"
12
#include "AthLinks/ElementLink.h"
13
14
#include "
Navigation/NavigableVectorIterator.h
"
15
16
#include <vector>
17
18
template
<
typename
CONT,
typename
OBJCT=
typename
CONT::base_value_type >
19
class
NavigableVector
20
{
21
public
:
22
23
// object container index type
24
typedef
typename
SG::GenerateIndexingPolicy<CONT>::type::index_type
25
external_index_type
;
26
27
//
28
typedef
ElementLink<CONT>
data_type
;
29
typedef
std::vector<data_type>
store_type
;
30
typedef
typename
store_type::iterator
store_iter
;
31
typedef
typename
store_type::const_iterator
store_const_iter
;
32
typedef
NavigableVectorIterator<OBJCT,store_type>
const_iterator
;
33
typedef
OBJCT*
object_ptr
;
34
typedef
const
OBJCT*
object_const_ptr
;
35
36
NavigableVector
()
37
{ }
38
39
virtual
~NavigableVector
() =
default
;
40
41
// add elements
42
void
addElement
(
const
CONT* aContainer,
const
OBJCT* anObject)
43
{
44
data_type
aLink;
45
aLink.
toContainedElement
(*aContainer,(
object_ptr
)anObject);
46
m_store
.push_back(aLink);
47
}
48
49
void
addElement
(
const
CONT* aContainer,
external_index_type
anIndex)
50
{
51
data_type
aLink;
52
aLink.
toIndexedElement
(*aContainer,anIndex);
53
m_store
.push_back(aLink);
54
}
55
56
void
addElement
(
const
data_type
& aLink)
57
{
58
m_store
.push_back(aLink);
59
}
60
61
unsigned
int
size
()
const
{
return
m_store
.size(); }
62
63
// iterator access
64
const_iterator
begin
()
const
65
{
66
return
const_iterator
(
m_store
).
begin
();
67
}
68
const_iterator
end
()
const
69
{
70
return
const_iterator
(
m_store
).
end
();
71
}
72
const_iterator
find
(
const
OBJCT* anObject)
const
73
{
74
return
const_iterator
(
m_store
).
find
(anObject);
75
}
76
77
// operators
78
const
OBJCT*
operator[]
(
int
i)
const
79
{
80
return
i >= 0 && i < (int)
m_store
.size()
81
? *(
m_store
[i])
82
: 0;
83
}
84
const
OBJCT*
operator[]
(
size_t
i)
const
85
{
86
return
i <
m_store
.size()
87
? *(
m_store
[i])
88
: 0;
89
}
90
91
// Return contained ElementLink directly.
92
const
data_type
&
linkAt
(
size_t
i)
const
93
{
94
if
(i <
m_store
.size())
95
return
m_store
[i];
96
static
const
data_type
null;
97
return
null;
98
}
99
100
void
push_back
(
data_type
& theData)
101
{
102
m_store
.push_back(theData);
103
}
104
105
protected
:
106
107
store_type
m_store
;
108
};
109
#endif
GenerateIndexingPolicy.h
NavigableVectorIterator.h
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
ElementLink::toContainedElement
bool toContainedElement(BaseConstReference container, ElementType element)
Set link to point to given element (slowest).
ElementLink::toIndexedElement
bool toIndexedElement(BaseConstReference container, index_type index)
Set link to point to given index (slower).
NavigableVectorIterator
Definition
NavigableVectorIterator.h:15
NavigableVectorIterator::end
NavigableVectorIterator end()
Definition
NavigableVectorIterator.h:64
NavigableVectorIterator::begin
NavigableVectorIterator begin()
Definition
NavigableVectorIterator.h:53
NavigableVectorIterator::find
NavigableVectorIterator & find(const object_type *anObject)
Definition
NavigableVectorIterator.h:126
NavigableVector::const_iterator
NavigableVectorIterator< OBJCT, store_type > const_iterator
Definition
NavigableVector.h:32
NavigableVector::~NavigableVector
virtual ~NavigableVector()=default
NavigableVector::linkAt
const data_type & linkAt(size_t i) const
Definition
NavigableVector.h:92
NavigableVector::operator[]
const OBJCT * operator[](int i) const
Definition
NavigableVector.h:78
NavigableVector::store_const_iter
store_type::const_iterator store_const_iter
Definition
NavigableVector.h:31
NavigableVector::object_ptr
OBJCT * object_ptr
Definition
NavigableVector.h:33
NavigableVector::addElement
void addElement(const CONT *aContainer, const OBJCT *anObject)
Definition
NavigableVector.h:42
NavigableVector::find
const_iterator find(const OBJCT *anObject) const
Definition
NavigableVector.h:72
NavigableVector::NavigableVector
NavigableVector()
Definition
NavigableVector.h:36
NavigableVector::store_iter
store_type::iterator store_iter
Definition
NavigableVector.h:30
NavigableVector::end
const_iterator end() const
Definition
NavigableVector.h:68
NavigableVector::m_store
store_type m_store
Definition
NavigableVector.h:107
NavigableVector::addElement
void addElement(const data_type &aLink)
Definition
NavigableVector.h:56
NavigableVector::operator[]
const OBJCT * operator[](size_t i) const
Definition
NavigableVector.h:84
NavigableVector::begin
const_iterator begin() const
Definition
NavigableVector.h:64
NavigableVector::data_type
ElementLink< CONT > data_type
Definition
NavigableVector.h:28
NavigableVector::size
unsigned int size() const
Definition
NavigableVector.h:61
NavigableVector::object_const_ptr
const OBJCT * object_const_ptr
Definition
NavigableVector.h:34
NavigableVector::addElement
void addElement(const CONT *aContainer, external_index_type anIndex)
Definition
NavigableVector.h:49
NavigableVector::store_type
std::vector< data_type > store_type
Definition
NavigableVector.h:29
NavigableVector::external_index_type
SG::GenerateIndexingPolicy< CONT >::type::index_type external_index_type
Definition
NavigableVector.h:25
NavigableVector::push_back
void push_back(data_type &theData)
Definition
NavigableVector.h:100
SG::GenerateIndexingPolicy
Definition
GenerateIndexingPolicy.h:25
Generated on
for ATLAS Offline Software by
1.17.0