DAS  3.0
Das Analysis System
MetaInfo.h
Go to the documentation of this file.
1 #ifndef DARWIN_METAINFO_H
2 #define DARWIN_METAINFO_H
3 
4 #include <string>
5 #include <filesystem>
6 #include <map>
7 
8 #include "UserInfo.h"
9 
10 #ifndef DARWIN_GIT_REPO
11 # ifndef DARWIN
12 # error "Provide the location of the Git repository at compile time."
13 # else
14 # define DARWIN_GIT_REPO DARWIN
15 # endif
16 #endif
17 
18 struct git_repository;
19 
20 namespace Darwin::Tools {
21 
22 static std::ostream dev_null(nullptr);
23 
65 class MetaInfo : public UserInfo {
66 
67  git_repository * repo;
68  mutable int git_error;
69  char sha[16];
71  const std::filesystem::path origin;
72 
77  static int get_one_status (const char *,
78  unsigned int,
79  void *
80  );
81 
84  void GitInit ();
85 
93  void PrintStatus () const;
94 
100  bool AllChangesCommitted () const;
101 
104  void SetupGit (bool);
105 
108  void SetupVersions ();
109 
114  void UpdateList (const bool
115  ) const;
116 
117 
120  MetaInfo (bool, const char*);
121 
124  MetaInfo (TTree *, const boost::property_tree::ptree&, bool,
125  const char*);
126 
129  MetaInfo (TTree *, bool, const char*);
130 
133  MetaInfo (TList *, bool, const char*);
134 public:
135 
138  struct IKnowWhatIAmDoing {};
139 
150  MetaInfo (const IKnowWhatIAmDoing&, bool git_init = true)
151  : MetaInfo(git_init, DARWIN_GIT_REPO)
152  {}
153 
161  MetaInfo (TTree *t,
162  const boost::property_tree::ptree& config,
163  bool git_init = true
164  )
165  : MetaInfo(t, config, git_init, DARWIN_GIT_REPO)
166  {}
167 
172  MetaInfo (TTree *t,
173  bool git_init = true
174  )
175  : MetaInfo(t, git_init, DARWIN_GIT_REPO)
176  {}
177 
181  MetaInfo (TList *l,
182  bool git_init = true
183  )
184  : MetaInfo(l, git_init, DARWIN_GIT_REPO)
185  {}
186 
189  template<typename Ptr, typename ...Args>
190  MetaInfo (const Ptr& t, Args... args)
191  : MetaInfo(&*t, args...) { }
192 
195  ~MetaInfo ();
196 
201  void Check (const boost::property_tree::ptree&) const;
202 
205  static std::string libgit2_version ();
206 
207  static std::map<std::string, std::string> versions;
208 
219  template<unsigned h
220  > unsigned Seed (std::pair<unsigned short, unsigned short> slice = {1,0}
221  ) const
222  {
223  unsigned b = Get<int>("preseed");
224  unsigned k = slice.second;
225  return h + (k+1) * b;
226  }
227 
228 };
229 
230 } // end of namespace
231 
232 #endif
Darwin::Tools::UserInfo::l
TList * l
main list (typically from TTree::GetUserInfo())
Definition: UserInfo.h:64
Darwin::Tools::MetaInfo::SetupVersions
void SetupVersions()
Fills in software version information in the MetaInfo.
Definition: MetaInfo.cc:195
Darwin::Tools::MetaInfo::git_error
int git_error
Definition: MetaInfo.h:68
Ntupliser_cfg.args
args
Definition: Ntupliser_cfg.py:11
Darwin::Tools::MetaInfo::Check
void Check(const boost::property_tree::ptree &) const
Definition: MetaInfo.cc:372
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:65
Darwin::Tools::MetaInfo::GitInit
void GitInit()
Inits and opens git repo, sets sha to the value at running time.
Definition: MetaInfo.cc:47
Darwin::Tools::MetaInfo::MetaInfo
MetaInfo(TList *l, bool git_init=true)
Definition: MetaInfo.h:181
DARWIN_GIT_REPO
#define DARWIN_GIT_REPO
Definition: main.cc:21
Darwin::Tools::MetaInfo::MetaInfo
MetaInfo(const Ptr &t, Args... args)
Generic constsructor for smart pointers.
Definition: MetaInfo.h:190
Darwin::Tools::MetaInfo::AllChangesCommitted
bool AllChangesCommitted() const
Definition: MetaInfo.cc:170
Darwin::Tools::config
@ config
activate -c option to provide config file
Definition: Options.h:26
Darwin::Tools::MetaInfo::PrintStatus
void PrintStatus() const
Definition: MetaInfo.cc:89
Darwin::Tools::MetaInfo::MetaInfo
MetaInfo(TTree *t, bool git_init=true)
Definition: MetaInfo.h:172
Darwin::Tools::MetaInfo::MetaInfo
MetaInfo(const IKnowWhatIAmDoing &, bool git_init=true)
Definition: MetaInfo.h:150
Darwin::Tools
Classes and functions related to the framework.
Definition: forceMetaInfo.cc:28
UserInfo.h
Darwin::Tools::MetaInfo::MetaInfo
MetaInfo(bool, const char *)
Used internally to set the git repo location (last parameter).
Definition: MetaInfo.cc:279
Darwin::Tools::MetaInfo::IKnowWhatIAmDoing
If you use this, you're supposed to know what you are doing.
Definition: MetaInfo.h:138
Darwin::Tools::MetaInfo::repo
git_repository * repo
pointer to local Git repo
Definition: MetaInfo.h:67
Darwin::Tools::MetaInfo::UpdateList
void UpdateList(const bool) const
Definition: MetaInfo.cc:204
Darwin::Tools::MetaInfo::origin
const std::filesystem::path origin
path to local repo determined at compilation time
Definition: MetaInfo.h:71
Darwin::Tools::MetaInfo::get_one_status
static int get_one_status(const char *, unsigned int, void *)
Definition: MetaInfo.cc:36
Darwin::Tools::MetaInfo::sha
char sha[16]
commit SHA at running time
Definition: MetaInfo.h:70
Darwin::Tools::dev_null
static std::ostream dev_null(nullptr)
to redirect output stream to nowhere
Darwin::Tools::MetaInfo::SetupGit
void SetupGit(bool)
Fills in git information in the MetaInfo.
Definition: MetaInfo.cc:176
Darwin::Tools::MetaInfo::MetaInfo
MetaInfo(TTree *t, const boost::property_tree::ptree &config, bool git_init=true)
Definition: MetaInfo.h:161
Darwin::Tools::UserInfo
Generic meta-information for n-tuple (can be used out of Darwin).
Definition: UserInfo.h:52
Darwin::Tools::MetaInfo::libgit2_version
static std::string libgit2_version()
Definition: MetaInfo.cc:260
Darwin::Tools::MetaInfo::Seed
unsigned Seed(std::pair< unsigned short, unsigned short > slice={1, 0}) const
Definition: MetaInfo.h:220
Darwin::Tools::MetaInfo::versions
static std::map< std::string, std::string > versions
software version
Definition: MetaInfo.h:207
Darwin::Tools::MetaInfo::~MetaInfo
~MetaInfo()
Destructor (releases memory & shuts down Git).
Definition: MetaInfo.cc:365