@@ -37,7 +37,7 @@ class Parameters
3737 Parameters (std::array<std::string, nPar> parNames, std::string name) : mName {name}, mPar {}, mParNames {parNames} {};
3838
3939 // / Default destructor
40- ~Parameters () = default ;
40+ virtual ~Parameters () = default ; // Ensure proper cleanup in derived classes
4141
4242 // / Setter for the parameter at position iparam
4343 // / \param iparam index in the array of the parameters
@@ -183,10 +183,27 @@ class ParameterCollection : public TNamed
183183 // / @param value parameter to add to the stored information
184184 // / @param pass key to look for in the stored information e.g. pass
185185 // / @return true if found and configured false if not fully configured
186- bool addParameter (const std::string& pass, const std::string& parName, float value);
186+ bool addParameter (const std::string& pass, const std::string& parName, float value)
187+ {
188+ const bool alreadyPresent = hasKey (pass);
189+ if (alreadyPresent) {
190+ LOG (debug) << " Changing parametrization corresponding to key " << pass << " from size " << mParameters [pass].size () << " to " << parName;
191+ } else {
192+ mParameters [pass] = std::unordered_map<std::string, paramvar_t >{};
193+ LOG (debug) << " Adding new parametrization corresponding to key " << pass << " : " << parName;
194+ }
195+ mParameters [pass][parName] = value;
196+ return true ;
197+ }
187198
188199 // / @return the size of the container i.e. the number of stored keys (or passes)
189- int getSize (const std::string& pass) const ;
200+ int getSize (const std::string& pass) const
201+ {
202+ if (!hasKey (pass)) {
203+ return -1 ;
204+ }
205+ return mParameters .at (pass).size ();
206+ }
190207
191208 // / @brief Function to push the parameters from the sub container into the collection and store it under a given key
192209 // / @tparam ParType type of the parameter container
@@ -214,10 +231,26 @@ class ParameterCollection : public TNamed
214231
215232 // / @brief printing function for the content of the pass
216233 // / @param pass pass to print
217- void print (const std::string& pass) const ;
234+ void print (const std::string& pass) const
235+ {
236+ const auto & size = getSize (pass);
237+ if (size < 0 ) {
238+ LOG (info) << " empty pass: " << pass;
239+ return ;
240+ }
241+ LOG (info) << " Pass \" " << pass << " \" with size " << size;
242+ for (const auto & [par, value] : mParameters .at (pass)) {
243+ LOG (info) << " par name = " << par << " , value = " << value;
244+ }
245+ }
218246
219247 // / @brief printing function for the full content of the container
220- void print () const ;
248+ void print () const
249+ {
250+ for (const auto & [pass, pars] : mParameters ) {
251+ print (pass);
252+ }
253+ }
221254
222255 // / @brief Getter of the full map of parameters stored in the container
223256 // / @return returns the full map of parameters
0 commit comments