29 auto newDefines = std::make_shared<DefinesMap_t>(*
fDefines);
30 const std::string &colName = column->GetName();
31 (*newDefines)[colName] = column;
38 auto newVariations = std::make_shared<VariationsMap_t>(*
fVariations);
39 const std::vector<std::string> &colNames = variation->GetColumnNames();
40 for (
auto &colName : colNames)
41 newVariations->insert({colName, variation});
42 fVariations = std::move(newVariations);
45std::vector<std::string> RColumnRegister::GetVariationsFor(
const std::string &column)
const
47 std::vector<std::string> variations;
48 auto range = fVariations->equal_range(column);
49 for (
auto it = range.first; it != range.second; ++it)
50 for (
const auto &variationName : it->second->GetVariationNames())
51 variations.emplace_back(variationName);
56std::vector<std::string> RColumnRegister::GetVariationDeps(
const std::string &column)
const
58 return GetVariationDeps(std::vector<std::string>{column});
61std::vector<std::string> RColumnRegister::GetVariationDeps(
const ColumnNames_t &columns)
const
64 std::set<std::string> variationNames;
66 for (
const auto &col : columns) {
67 const auto &variations = GetVariationsFor(col);
68 for (
const auto &var : variations)
69 variationNames.insert(var);
72 auto defineIt = fDefines->find(col);
73 if (defineIt != fDefines->end()) {
74 for (
const auto &
v : defineIt->second->GetVariations())
75 variationNames.insert(
v);
79 return {variationNames.begin(), variationNames.end()};
83RVariationBase &RColumnRegister::FindVariation(
const std::string &colName,
const std::string &variationName)
const
85 auto range = fVariations->equal_range(colName);
86 assert(range.first != fVariations->end() &&
"Could not find the variation you asked for. This should never happen.");
87 auto it = range.first;
88 while (it != fVariations->end() && !
IsStrInVec(variationName, it->second->GetVariationNames()))
90 assert(it != fVariations->end() &&
"Could not find the variation you asked for. This should never happen.");
94void RColumnRegister::AddName(std::string_view
name)
96 const auto &names = *fColumnNames;
97 if (std::find(names.begin(), names.end(),
name) != names.end())
100 auto newColsNames = std::make_shared<ColumnNames_t>(names);
101 newColsNames->emplace_back(std::string(
name));
102 fColumnNames = newColsNames;
105void RColumnRegister::AddAlias(std::string_view alias, std::string_view colName)
109 auto newAliases = std::make_shared<std::unordered_map<std::string, std::string>>(*fAliases);
110 (*newAliases)[std::string(alias)] =
ResolveAlias(colName);
111 fAliases = std::move(newAliases);
115bool RColumnRegister::IsAlias(
const std::string &
name)
const
117 return fAliases->find(
name) != fAliases->end();
120std::string RColumnRegister::ResolveAlias(std::string_view alias)
const
122 std::string aliasStr{alias};
125 if (aliasStr.size() > 1 && aliasStr[0] ==
'#')
126 return "R_rdf_sizeof_" + aliasStr.substr(1);
128 auto it = fAliases->find(aliasStr);
129 if (it != fAliases->end())
135void RColumnRegister::Clear()
140 fColumnNames.reset();
void AddVariation(const std::shared_ptr< RVariationBase > &variation)
Register a new systematic variation.
std::shared_ptr< const VariationsMap_t > fVariations
Immutable multimap of Variations, can be shared among several nodes.
std::shared_ptr< const DefinesMap_t > fDefines
Immutable map of Defines, can be shared among several nodes.
bool HasName(std::string_view name) const
Check if the provided name is tracked in the names list.
std::shared_ptr< const ColumnNames_t > fColumnNames
Names of Defines and Aliases registered so far.
void AddColumn(const std::shared_ptr< RDFDetail::RDefineBase > &column)
Add a new booked column.
std::vector< std::string > ColumnNames_t
void AddName(std::string_view name)
Add a new name to the list returned by GetNames without booking a new column.
This type includes all parts of RVariation that do not depend on the callable signature.
bool IsStrInVec(const std::string &str, const std::vector< std::string > &vec)
std::string ResolveAlias(const std::string &col, const std::map< std::string, std::string > &aliasMap)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...