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 addRootNtupleFile(const std::string& fileName);
54
58 void addHDF5File(const std::string& fileName);
59
63 void addBasf2Status(const std::string& message = "");
64
69
73 void finishBasf2(bool success = true);
74
75 private:
76
77 std::string m_fileName;
78 nlohmann::json m_json;
85
90
95
99 void writeJson();
100
101 };
102
104} //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 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.
void addHDF5File(const std::string &fileName)
Add the metadata of a HDF5 file.
static MetadataService & Instance()
Static method to get a reference to the MetadataService instance.
void finishBasf2(bool success=true)
Add metadata for basf2 completion.
void addRootNtupleFile(const std::string &fileName)
Add the metadata of a root ntuple file.
Abstract base class for different kinds of events.