Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
VertexManager.cc
Go to the documentation of this file.
1
10
11#include "Objects/Vertex.h"
12
14
15#include <algorithm>
16
17namespace pandora
18{
19
20VertexManager::VertexManager(const Pandora *const pPandora) :
22{
23 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, this->CreateInitialLists());
24}
25
26//------------------------------------------------------------------------------------------------------------------------------------------
27
32
33//------------------------------------------------------------------------------------------------------------------------------------------
34
37{
38 pVertex = nullptr;
39
40 try
41 {
43 throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
44
45 NameToListMap::iterator iter = m_nameToListMap.find(m_currentListName);
46
47 if (m_nameToListMap.end() == iter)
48 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
49
50 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, factory.Create(parameters, pVertex));
51
52 if (!pVertex)
53 throw StatusCodeException(STATUS_CODE_FAILURE);
54
55 iter->second->push_back(pVertex);
56 return STATUS_CODE_SUCCESS;
57 }
58 catch (StatusCodeException &statusCodeException)
59 {
60 std::cout << "Failed to create vertex: " << statusCodeException.ToString() << std::endl;
61 delete pVertex;
62 pVertex = nullptr;
63 return statusCodeException.GetStatusCode();
64 }
65}
66
67//------------------------------------------------------------------------------------------------------------------------------------------
68
70{
71 return this->Modifiable(pVertex)->AlterMetadata(metadata);
72}
73
74//------------------------------------------------------------------------------------------------------------------------------------------
75
76template <>
77bool VertexManager::IsAvailable(const Vertex *const pVertex) const
78{
79 return pVertex->IsAvailable();
80}
81
82template <>
83bool VertexManager::IsAvailable(const VertexList *const pVertexList) const
84{
85 bool isAvailable(true);
86
87 for (const Vertex *const pVertex : *pVertexList)
88 isAvailable &= this->IsAvailable(pVertex);
89
90 return isAvailable;
91}
92
93//------------------------------------------------------------------------------------------------------------------------------------------
94
95template <>
96void VertexManager::SetAvailability(const Vertex *const pVertex, bool isAvailable) const
97{
98 this->Modifiable(pVertex)->SetAvailability(isAvailable);
99}
100
101template <>
102void VertexManager::SetAvailability(const VertexList *const pVertexList, bool isAvailable) const
103{
104 for (const Vertex *const pVertex : *pVertexList)
105 this->SetAvailability(pVertex, isAvailable);
106}
107
108} // namespace pandora
Header file for the object factory class.
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
Definition StatusCodes.h:43
Header file for the vertex class.
Header file for the vertex manager class.
AlgorithmObjectManager class.
bool m_canMakeNewObjects
Whether the manager is allowed to make new objects when requested by algorithms.
virtual StatusCode EraseAllContent()
Erase all manager content.
std::string m_currentListName
The name of the current list.
Definition Manager.h:181
virtual T * Modifiable(const T *const pT) const
Access a modifiable object, when provided with address to const object.
Definition Manager.cc:288
NameToListMap m_nameToListMap
The name to list map.
Definition Manager.h:178
virtual StatusCode CreateInitialLists()
Create initial lists.
Definition Manager.cc:274
ObjectFactory class responsible for extended pandora object creation.
virtual StatusCode Create(const Parameters &parameters, const Object *&pObject) const =0
Create an object with the given parameters.
Pandora class.
Definition Pandora.h:40
StatusCodeException class.
std::string ToString() const
Get status code as a string.
StatusCode GetStatusCode() const
Get status code.
Vertex class.
Definition Vertex.h:26
bool IsAvailable() const
Whether the vertex is available to be added to a particle flow object.
Definition Vertex.h:131
StatusCode AlterMetadata(const Vertex *const pVertex, const object_creation::Vertex::Metadata &metadata) const
Alter the metadata information stored in a vertex.
VertexManager(const Pandora *const pPandora)
Constructor.
~VertexManager()
Destructor.
bool IsAvailable(const T *const pT) const
Is a vertex, or a list of vertices, available to add to a particle flow object.
StatusCode Create(const object_creation::Vertex::Parameters &parameters, const Vertex *&pVertex, const ObjectFactory< object_creation::Vertex::Parameters, object_creation::Vertex::Object > &factory)
Create a vertex.
void SetAvailability(const T *const pT, bool isAvailable) const
Set availability of a vertex, or a list of vertices, to be added to a particle flow object.
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.