Belle II Software development
MetadataService.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 <string>
12#include <nlohmann/json.hpp>
13
14
15namespace Belle2 {
21 class FileMetaData;
22
28
29 public:
30
36 static MetadataService& Instance();
37
43 void setJsonFileName(const std::string& fileName) {m_fileName = fileName; writeJson();};
44
48 void addRootOutputFile(const std::string& fileName, const FileMetaData* metaData = nullptr);
49
53 void addNtuple(const std::string& fileName);
54
58 void addBasf2Status(const std::string& message = "");
59
64
68 void finishBasf2(bool success = true);
69
70 private:
71
72 std::string m_fileName;
73 nlohmann::json m_json;
80
85
90
94 void writeJson();
95
96 };
97
99} //end of namespace Belle2
Metadata information about a file.
Definition: FileMetaData.h:29
This class provides a service for writing metadata about the basf2 execution and about output files t...
void writeJson()
Serialize the current json content to the json file.
MetadataService(const MetadataService &)=delete
Disable/Hide the copy constructor.
double m_basf2StartTime
the start time of basf2
void addModuleCallsCount()
Add the metadata of number of calls of all modules.
void addBasf2Status(const std::string &message="")
Add metadata of basf2 status.
void setJsonFileName(const std::string &fileName)
Set the name of the json metadata file.
std::string m_fileName
The name of the json file.
MetadataService()
Constructor.
void addNtuple(const std::string &fileName)
Add the metadata of any ntuple file.
void addRootOutputFile(const std::string &fileName, const FileMetaData *metaData=nullptr)
Add the metadata of a root output file.
nlohmann::json m_json
The json object.
MetadataService & operator=(const MetadataService &)=delete
Disable/Hide the copy assignment operator.
static MetadataService & Instance()
Static method to get a reference to the MetadataService instance.
void finishBasf2(bool success=true)
Add metadata for basf2 completion.
Abstract base class for different kinds of events.