Belle II Software  release-08-01-10
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 <string>
13 #include <vector>
14 #include <regex>
15 
16 namespace Belle2 {
33  class PruneDataStoreModule: public Module {
34 
35  public:
36 
39 
41  virtual ~PruneDataStoreModule() = default;
42 
44  void initialize() override;
45 
47  void event() override;
48 
49  protected:
50 
54  std::regex compileAndCatch(std::string& regexString) const;
55 
57  std::vector<std::string> m_matchEntries;
58 
64  std::vector<std::string> m_keepEntriesImplicit = {{ "EventMetaData" }};
65 
70  bool m_keepMatchedEntries = true;
71 
73  std::vector < std::regex > m_compiled_regex;
74 
76  std::vector < std::regex > m_compiled_regex_implicit;
77 
78  };
80 } // end namespace Belle2
Base class for Modules.
Definition: Module.h:72
Clears the content of the DataStore while it keeps entries matching the regex expression in the match...
void initialize() override
Prepare regex checks.
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< 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.
virtual ~PruneDataStoreModule()=default
Virtual Constructor to prevent memory leaks.
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.
std::regex compileAndCatch(std::string &regexString) const
Compile a regex expression and catch the exception if the regex string is not valid.
Abstract base class for different kinds of events.