Belle II Software development
DependencyMap.cc
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#include <framework/datastore/DependencyMap.h>
9#include <framework/core/Module.h>
10
11#include <algorithm>
12
13using namespace std;
14using namespace Belle2;
15
16std::string DependencyMap::getModuleID(const Module& mod)
17{
18 return mod.getType() + std::to_string(long(&mod));
19}
20
21void DependencyMap::ModuleInfo::addEntry(const std::string& name, EEntryType type, bool isRelation)
22{
23 if (isRelation)
24 relations[type].insert(name);
25 else
26 entries[type].insert(name);
27}
28
29bool DependencyMap::isUsedAs(const std::string& branchName, EEntryType type) const
30{
31 return any_of(m_moduleInfo.begin(), m_moduleInfo.end(),
32 [branchName, type](const pair<string, ModuleInfo>& info) {
33 if (info.second.entries[type].count(branchName))
34 return true;
35 return (bool)info.second.relations[type].count(branchName);
36 });
37}
EEntryType
Possible types of entries/relations for a module.
Definition: DependencyMap.h:32
std::map< std::string, ModuleInfo > m_moduleInfo
Stores information on inputs/outputs of each module, as obtained by requireInput()/optionalInput()/re...
Definition: DependencyMap.h:73
static std::string getModuleID(const Module &mod)
Return unique ID for given module.
bool isUsedAs(const std::string &branchName, EEntryType type) const
Is the object/array/relation with given name used as specified input/output type (in any module)?
Base class for Modules.
Definition: Module.h:72
Abstract base class for different kinds of events.
STL namespace.
std::set< std::string > entries[c_NEntryTypes]
objects/arrays.
Definition: DependencyMap.h:42
std::set< std::string > relations[c_NEntryTypes]
relations between them.
Definition: DependencyMap.h:43
void addEntry(const std::string &name, EEntryType type, bool isRelation)
Adds given entry/relation.