Belle II Software  release-05-02-19
GearDir.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/gearbox/Interface.h>
14 #include <framework/gearbox/Gearbox.h>
15 
16 namespace Belle2 {
33  class GearDir: public gearbox::Interface {
34  public:
36  GearDir(const gearbox::Interface& start, const std::string& path, int index = 0)
37  {
38  m_path = ensurePath(start.getPath()) + path;
39  if (index > 0) m_path = addIndex(m_path, index);
40  }
42  GearDir(const std::string& path = "", int index = 0)
43  {
44  m_path = path;
45  if (index > 0) m_path = addIndex(path, index);
46  }
48  GearDir(const GearDir& other): gearbox::Interface(other)
49  {
50  m_path = other.m_path;
51  }
52 
54  void append(const std::string& path) { m_path += path; }
55 
60  virtual int getNumberNodes(const std::string& path = "") const override
61  {
63  }
64 
71  virtual std::string getString(const std::string& path = "") const noexcept(false) override
72  {
74  }
75 
84  std::string getString(const std::string& path, const std::string& defaultValue) const
85  {
86  return gearbox::Interface::getString(path, defaultValue);
87  }
88 
100  virtual std::pair<std::string, std::string> getStringWithUnit(const std::string& path = "") const noexcept(false) override
101  {
103  }
104 
114  virtual const TObject* getTObject(const std::string& path) const noexcept(false) override
115  {
117  }
118  };
119 
121 }
Belle2::Gearbox::getStringWithUnit
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:164
Belle2::GearDir::GearDir
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:44
Belle2::gearbox::Interface::ensurePath
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:171
Belle2::Gearbox::getTObject
virtual const TObject * getTObject(const std::string &path) const noexcept(false) override
Get the parameter path as a TObject.
Definition: Gearbox.cc:288
Belle2::Gearbox::getInstance
static Gearbox & getInstance()
Return reference to the Gearbox instance.
Definition: Gearbox.cc:74
Belle2::GearDir::getTObject
virtual const TObject * getTObject(const std::string &path) const noexcept(false) override
Get the parameter path as a TObject.
Definition: GearDir.h:122
Belle2::Gearbox::getNumberNodes
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
Definition: Gearbox.h:122
Belle2::GearDir::getStringWithUnit
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:108
Belle2::gearbox::Interface::getString
virtual std::string getString(const std::string &path="") const noexcept(false)=0
Get the parameter path as a string.
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Gearbox::getString
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: Gearbox.h:133
Belle2::gearbox::Interface::addIndex
std::string addIndex(const std::string &path, int index) const
add [index] to the path (after stripping trailing slashes)
Definition: Interface.cc:176
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::GearDir::append
void append(const std::string &path)
Append something to the current path, modifying the GearDir in place.
Definition: GearDir.h:62
Belle2::GearDir::getString
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: GearDir.h:79
Belle2::gearbox::Interface
Exception to be thrown in case of an empty result.
Definition: Interface.h:37
Belle2::gearbox::Interface::m_path
std::string m_path
path of the current interface
Definition: Interface.h:500
Belle2::GearDir::getNumberNodes
virtual int getNumberNodes(const std::string &path="") const override
Return the number of nodes a given path will expand to.
Definition: GearDir.h:68