Belle II Software development
PruneDataStoreModule.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 <framework/core/Module.h>
12#include <framework/datastore/DataStore.h>
13#include <string>
14#include <vector>
15#include <regex>
16
17namespace Belle2 {
32
33 public:
34
37
39 virtual ~PruneDataStoreModule() override = default;
40
42 void initialize() override;
43
45 void event() override;
46
47 protected:
48
52 static std::regex compileAndCatch(std::string& regexString);
53
55 std::vector<std::string> m_matchEntries;
56
62 std::vector<std::string> m_keepEntriesImplicit = {{ "EventMetaData" }};
63
69
71 std::vector < std::regex > m_compiled_regex;
72
74 std::vector < std::regex > m_compiled_regex_implicit;
75
80
85 std::vector<DataStore::StoreEntry*> m_entriesToPrune;
86
88 std::vector<const std::string*> m_entriesToKeep;
89
91 bool m_cacheValid{false};
92
93 };
94
95} // end namespace Belle2
std::map< std::string, StoreEntry > StoreEntryMap
Map for StoreEntries.
Definition DataStore.h:87
Module()
Constructor.
Definition Module.cc:30
virtual ~PruneDataStoreModule() override=default
Virtual Constructor to prevent memory leaks.
void initialize() override
Prepare regex checks.
bool m_cacheValid
Whether the caches above have already been filled for this run.
void event() override
Prune datastore.
std::vector< std::string > m_keepEntriesImplicit
Branches to always keep because the are required by the framework to properly work with the datastore...
std::vector< const std::string * > m_entriesToKeep
Names of the DataStore entries which are kept, only used for debug output.
std::vector< std::regex > m_compiled_regex_implicit
Caching the regex expression for the keep check.
bool m_keepMatchedEntries
If true, all entries matched by the RegEx expression are kept.
std::vector< std::regex > m_compiled_regex
Caching the regex expression for the keep check.
std::vector< std::string > m_matchEntries
Storing the option of branches to keep.
void updateCache(DataStore::StoreEntryMap &storemap)
Evaluate the regular expressions for all entries of the given DataStore map and fill the m_entriesToP...
static std::regex compileAndCatch(std::string &regexString)
Compile a regex expression and catch the exception if the regex string is not valid.
std::vector< DataStore::StoreEntry * > m_entriesToPrune
DataStore entries which have to be pruned.
Abstract base class for different kinds of events.