Belle II Software light-2406-ragdoll
GearDir.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/gearbox/Interface.h>
12#include <framework/gearbox/Gearbox.h>
13
14namespace Belle2 {
32 public:
34 GearDir(const gearbox::Interface& start, const std::string& path, int index = 0)
35 {
36 m_path = ensurePath(start.getPath()) + path;
37 if (index > 0) m_path = addIndex(m_path, index);
38 }
40 GearDir(const std::string& path = "", int index = 0)
41 {
42 m_path = path;
43 if (index > 0) m_path = addIndex(path, index);
44 }
46 GearDir(const GearDir& other): gearbox::Interface(other)
47 {
48 m_path = other.m_path;
49 }
50
52 void append(const std::string& path) { m_path += path; }
53
58 virtual int getNumberNodes(const std::string& path = "") const override
59 {
61 }
62
69 virtual std::string getString(const std::string& path = "") const noexcept(false) override
70 {
72 }
73
82 std::string getString(const std::string& path, const std::string& defaultValue) const
83 {
84 return gearbox::Interface::getString(path, defaultValue);
85 }
86
98 virtual std::pair<std::string, std::string> getStringWithUnit(const std::string& path = "") const noexcept(false) override
99 {
101 }
102
112 virtual const TObject* getTObject(const std::string& path) const noexcept(false) override
113 {
115 }
116 };
117
119}
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:31
GearDir(const std::string &path="", int index=0)
Create a GearDir with an absolute path and optionally appending an index.
Definition: GearDir.h:40
std::string getString(const std::string &path, const std::string &defaultValue) const
Get the parameter path as a string.
Definition: GearDir.h:82
void append(const std::string &path)
Append something to the current path, modifying the GearDir in place.
Definition: GearDir.h:52
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
Definition: GearDir.h:58
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: GearDir.h:69
virtual const TObject * getTObject(const std::string &path) const noexcept(false) override
Get the parameter path as a TObject.
Definition: GearDir.h:112
GearDir(const gearbox::Interface &start, const std::string &path, int index=0)
Create a GearDir starting at a given base path and appending some subpath and optionally an index.
Definition: GearDir.h:34
virtual std::pair< std::string, std::string > getStringWithUnit(const std::string &path="") const noexcept(false) override
Get the parameter path as string and also return the unit it was defined with.
Definition: GearDir.h:98
GearDir(const GearDir &other)
Copy constructor.
Definition: GearDir.h:46
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
Definition: Gearbox.h:112
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: Gearbox.h:123
virtual std::pair< std::string, std::string > getStringWithUnit(const std::string &path="") const noexcept(false) override
Get the parameter path as string and also return the unit it was defined with.
Definition: Gearbox.h:154
Exception to be thrown in case of an empty result.
Definition: Interface.h:35
virtual std::string getString(const std::string &path="") const noexcept(false)=0
Get the parameter path as a string.
std::string addIndex(const std::string &path, int index) const
add [index] to the path (after stripping trailing slashes)
Definition: Interface.cc:166
std::string m_path
path of the current interface
Definition: Interface.h:498
std::string ensurePath(const std::string &path) const
make sure the path really corresponds to a path by appending a trailing slash if neccessary
Definition: Interface.cc:161
static Gearbox & getInstance()
Return reference to the Gearbox instance.
Definition: Gearbox.cc:81
virtual const TObject * getTObject(const std::string &path) const noexcept(false) override
Get the parameter path as a TObject.
Definition: Gearbox.cc:295
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24