gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
printer_id_tools.cpp
Go to the documentation of this file.
1 
3 #include "gambit/Logs/logger.hpp"
4 
5 namespace Gambit
6 {
7  namespace Printers
8  {
10  // bjf> I'm not sure that it is so great to have this as a global.
11  // It would be better managed by the printer object. Some
12  // changes required in ScannerBit to do this though
13  unsigned long long int &get_point_id()
14  {
15  static unsigned long long int id = 0;
16 
17  return id;
18  }
19 
21  {
22  static bool ai = true;
23  return ai;
24  }
25 
26  // Access the global parameter ID map. Not declared in header, so
27  // can only be accessed in this file.
28  std::unordered_map<std::string, long long int> &get_param_id_map()
29  {
30  static std::unordered_map<std::string, long long int> map;
31  return map;
32  }
33 
37  std::vector<std::string> get_all_params()
38  {
39  std::vector<std::string> out(get_param_id_map().size());
40  std::cout <<"size? " << out.size() << std::endl;
41  for( auto it = get_param_id_map().begin(); it!=get_param_id_map().end(); ++it)
42  {
43  std::cout << it->second << ", " << it->first << std::endl;
44  out.at(it->second) = it->first;
45  }
46  return out;
47  }
48 
54  int get_param_id(const std::string& name, bool& is_new)
55  {
56  static long long int N = 0; // Next unused index
57 
58  auto it = get_param_id_map().find(name);
59  if (it != get_param_id_map().end())
60  {
61  is_new = false;
62  return it->second;
63  }
64  else
65  {
66  get_param_id_map()[name] = N;
67  logger() << LogTags::printers << LogTags::info << "Assigned printer ID '"<<N<<"' to output quantity with label '"<<name<<"'" << EOM;
68  is_new = true;
69  N++;
70  return N-1;
71  }
72  }
73 
74  int get_param_id(const std::string &name)
75  {
76  bool is_new; // Dummy for optional return argument
77  return get_param_id(name, is_new);
78  }
79 
80  int get_main_param_id(const std::string& name, bool& is_new)
81  {
82  return get_param_id(name,is_new);
83  }
84 
85  int get_main_param_id(const std::string &name)
86  {
87  bool is_new; // Dummy for optional return argument
88  return get_main_param_id(name, is_new);
89  }
90 
91  int get_aux_param_id(const std::string &name, bool& is_new)
92  {
93  return get_param_id(name,is_new);
94  }
95 
96  int get_aux_param_id(const std::string &name)
97  {
98  bool is_new; // Dummy for optional return argument
99  return get_aux_param_id(name, is_new);
100  }
101 
102  }
103 }
Logging access header for GAMBIT.
EXPORT_SYMBOLS bool & auto_increment()
Global flag to indicate if auto-incrementing of the PointID by the likelihood container is allowed...
EXPORT_SYMBOLS unsigned long long int & get_point_id()
Returns unigue pointid;.
EXPORT_SYMBOLS int get_main_param_id(const std::string &)
Returns unique positive parameter id; just a thin wrapper for get_param_id.
std::unordered_map< std::string, long long int > & get_param_id_map()
EXPORT_SYMBOLS int get_aux_param_id(const std::string &)
Returns unique negative parameter id; just a thin wrapper for get_param_id.
EXPORT_SYMBOLS int get_param_id(const std::string &name, bool &is_new)
Consolidated &#39;get id&#39; function, for both main and aux.
const Logging::endofmessage EOM
Explicit const instance of the end of message struct in Gambit namespace.
Definition: logger.hpp:100
EXPORT_SYMBOLS Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
Tools for accessing printers.
TODO: see if we can use this one:
Definition: Analysis.hpp:33
EXPORT_SYMBOLS std::vector< std::string > get_all_params()
Get names of all parameters known to printer system (vector index corresponds to ID number) ...