LHAPDF is hosted by Hepforge, IPPP Durham
LHAPDF  6.2.1
Config.h
1 // -*- C++ -*-
2 //
3 // This file is part of LHAPDF
4 // Copyright (C) 2012-2016 The LHAPDF collaboration (see AUTHORS for details)
5 //
6 #pragma once
7 #ifndef LHAPDF_Config_H
8 #define LHAPDF_Config_H
9 
10 #include "LHAPDF/Info.h"
11 
12 namespace LHAPDF {
13 
14 
16  class Config : public Info {
17  public:
18 
20 
21 
30  static Config& get() {
31  static Config _cfg; //< Could we use the Info(path) constructor for automatic init-once behaviour?
32  // Test for emptiness and only initialise *once*:
33  if (_cfg._metadict.empty()) {
34  std::string confpath = findFile("lhapdf.conf");
35  if (!confpath.empty()) _cfg.load(confpath);
36  }
37  return _cfg;
38  }
39 
41 
42 
44  ~Config();
45 
46 
47  private:
48 
50  Config() {
51  // std::cout << "CONFIG CONSTRUCTION" << std::endl;
52  }
53 
55 
56  };
57 
58 
60 
61 
65  inline int verbosity() {
66  return Config::get().get_entry_as<int>("Verbosity", 1);
67  }
68 
72  inline void setVerbosity(int v) {
73  Config::get().set_entry("Verbosity", v);
74  }
75 
77 
78 
79 }
80 #endif
void set_entry(const std::string &key, const T &val)
Set a keyed value entry.
Definition: Info.h:147
Class for PDF set metadata and manipulation.
Definition: Config.h:16
std::map< std::string, std::string > _metadict
The string -> string native metadata storage container.
Definition: Info.h:157
static Config & get()
Definition: Config.h:30
void load(const std::string &filepath)
T get_entry_as(const std::string &key) const
Definition: Info.h:128
int verbosity()
Definition: Config.h:65
Namespace for all LHAPDF functions and classes.
Definition: AlphaS.h:14
void setVerbosity(int v)
Definition: Config.h:72
Config()
Hide the default constructor.
Definition: Config.h:50
std::string findFile(const std::string &target)
Metadata base class for PDFs, PDF sets, or global configuration.
Definition: Info.h:30
~Config()
Config destructor, used for end-of-run banner printing.