Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ExternallyConfiguredAlgorithm.cc
Go to the documentation of this file.
1
10
11namespace pandora
12{
13
14ExternallyConfiguredAlgorithm::ExternalParametersMap ExternallyConfiguredAlgorithm::m_externalParametersMap;
15
16//------------------------------------------------------------------------------------------------------------------------------------------
17
19 m_nParameterAccessAttempts(0)
20{
21}
22
23//------------------------------------------------------------------------------------------------------------------------------------------
24
28
29//------------------------------------------------------------------------------------------------------------------------------------------
30
32{
34 throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
35}
36
37//------------------------------------------------------------------------------------------------------------------------------------------
38//------------------------------------------------------------------------------------------------------------------------------------------
39
48
49//------------------------------------------------------------------------------------------------------------------------------------------
50
51StatusCode ExternallyConfiguredAlgorithm::SetExternalParameters(const Pandora &pandora, const std::string &algorithmType, ExternalParameters *const pExternalParameters)
52{
53 return m_externalParametersMap.SetExternalParameters(pandora, algorithmType, pExternalParameters);
54}
55
56//------------------------------------------------------------------------------------------------------------------------------------------
57
62
63//------------------------------------------------------------------------------------------------------------------------------------------
64
66{
67 ExternalParameters *const pExternalParameters(m_externalParametersMap.GetExternalParameters(this->GetPandora(), this->GetType()));
68 pExternalParameters->RegisterParameterAccessAttempt();
69 return pExternalParameters;
70}
71
72//------------------------------------------------------------------------------------------------------------------------------------------
73//------------------------------------------------------------------------------------------------------------------------------------------
74
76{
77 for (const TheMap::value_type &pandoraMapEntry : m_theMap)
78 {
79 for (const AlgTypeToParametersMap::value_type &algorithmMapEntry : pandoraMapEntry.second)
80 delete algorithmMapEntry.second;
81 }
82}
83
84//------------------------------------------------------------------------------------------------------------------------------------------
85
87{
88 return ((m_theMap.count(&pandora) > 0) && (m_theMap.at(&pandora).count(algorithmType) > 0));
89}
90
91//------------------------------------------------------------------------------------------------------------------------------------------
92
94{
95 if (!this->ExternalParametersPresent(pandora, algorithmType))
96 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
97
98 return m_theMap.at(&pandora).at(algorithmType);
99}
100
101//------------------------------------------------------------------------------------------------------------------------------------------
102
104 ExternalParameters *const pExternalParameters)
105{
106 if (!pExternalParameters)
107 return STATUS_CODE_INVALID_PARAMETER;
108
109 if (!m_theMap[&pandora].insert(AlgTypeToParametersMap::value_type(algorithmType, pExternalParameters)).second)
110 return STATUS_CODE_ALREADY_PRESENT;
111
112 return STATUS_CODE_SUCCESS;
113}
114
115//------------------------------------------------------------------------------------------------------------------------------------------
116
118{
119 if (this->ExternalParametersPresent(pandora, algorithmType))
120 {
121 AlgTypeToParametersMap &algTypeToParametersMap(m_theMap[&pandora]);
122 AlgTypeToParametersMap::iterator iter(algTypeToParametersMap.find(algorithmType));
123
124 if (algTypeToParametersMap.end() != iter)
125 {
126 delete iter->second;
127 algTypeToParametersMap.erase(iter);
128 }
129 }
130}
131
132} // namespace pandora
Header file for the externally configured algorithm class.
unsigned int m_nParameterAccessAttempts
The number of attempts made to access the external parameters.
void RegisterParameterAccessAttempt()
Register an attempt to access the external parameters during algorithm configuration.
pandora::StatusCode SetExternalParameters(const pandora::Pandora &pandora, const std::string &algorithmType, ExternalParameters *const pExternalParameters)
Set the external parameters associated with an algorithm instance of a specific type,...
void RemoveExternalParameters(const pandora::Pandora &pandora, const std::string &algorithmType)
Remove the external parameters associated with an algorithm instance of a specific type,...
bool ExternalParametersPresent(const pandora::Pandora &pandora, const std::string &algorithmType) const
Whether external parameters are present.
std::map< const std::string, ExternalParameters * > AlgTypeToParametersMap
ExternalParameters * GetExternalParameters(const pandora::Pandora &pandora, const std::string &algorithmType) const
Get the external parameters associated with algorithm instances created by a given Pandora instance....
bool ExternalParametersPresent() const
Whether external parameters are present.
ExternalParameters * GetExternalParameters() const
Get the external parameters associated with algorithm instances created by a given Pandora instance....
static ExternalParametersMap m_externalParametersMap
The external parameters map.
static StatusCode SetExternalParameters(const Pandora &pandora, const std::string &algorithmType, ExternalParameters *const pExternalParameters)
Set the external parameters associated with an algorithm instance of a specific type,...
Pandora class.
Definition Pandora.h:40
const std::string & GetType() const
Get the type.
Definition Process.h:102
const Pandora & GetPandora() const
Get the associated pandora instance.
Definition Process.h:116
StatusCodeException class.
StatusCode
The StatusCode enum.