12 #ifndef R__SELECTIONRULES_H 13 #define R__SELECTIONRULES_H 19 #include "clang/AST/Decl.h" 28 namespace TMetaUtils {
29 class TNormalizedCtxt;
35 template<
class ASSOCIATIVECONTAINER>
36 inline bool areEqualAttributes(
const ASSOCIATIVECONTAINER&
c1,
const ASSOCIATIVECONTAINER&
c2,
bool moduloNameOrPattern){
37 if (c1.size() != c2.size())
return false;
38 if (moduloNameOrPattern) {
39 for (
auto&& keyValPairC1 : c1){
40 auto keyC1 = keyValPairC1.first;
41 if (
"pattern" == keyC1 ||
"name" == keyC1)
continue;
42 auto valC1 = keyValPairC1.second;
43 auto C2It = c2.find(keyC1);
44 if (C2It == c2.end() || valC1 != C2It->second)
return false;
54 inline bool areEqual(
const RULE*
r1,
const RULE*
r2,
bool moduloNameOrPattern =
false){
55 return areEqualAttributes(r1->GetAttributes(), r2->GetAttributes(), moduloNameOrPattern);
58 template<
class RULESCOLLECTION>
60 const RULESCOLLECTION&
r2,
61 bool moduloNameOrPattern =
false){
62 if (r1.size() != r2.size())
return false;
63 auto rIt1 = r1.begin();
64 auto rIt2 = r2.begin();
65 for (;rIt1!=r1.cend();++rIt1,++rIt2){
66 if (!
areEqual(&(*rIt1),&(*rIt2), moduloNameOrPattern))
return false;
73 bool moduloNameOrPattern){
74 if (!
areEqualAttributes(r1->GetAttributes(), r2->GetAttributes(),moduloNameOrPattern))
return false;
77 r2->GetFieldSelectionRules(),
81 r2->GetMethodSelectionRules(),
95 kNumSelectionFileTypes
100 const std::vector<std::pair<std::string,std::string>>& namesForExclusion):
101 fSelectionFileType(kNumSelectionFileTypes),
103 fHasFileNameRule(false),
108 for (
auto& attrValPair : namesForExclusion){
112 AddClassSelectionRule(csr);
119 return fClassSelectionRules;
124 return !fFunctionSelectionRules.empty();
127 return fFunctionSelectionRules;
133 return !fVariableSelectionRules.empty();
136 return fVariableSelectionRules;
142 return fEnumSelectionRules;
145 void PrintSelectionRules()
const;
147 void ClearSelectionRules();
152 int CheckDuplicates();
155 void SetDeep(
bool deep);
169 const ClassSelectionRule *IsClassSelected(
const clang::Decl* D,
const std::string& qual_name)
const;
170 const ClassSelectionRule *IsNamespaceSelected(
const clang::Decl* D,
const std::string& qual_name)
const;
174 const BaseSelectionRule *IsVarSelected(
const clang::VarDecl* D,
const std::string& qual_name)
const;
175 const BaseSelectionRule *IsFunSelected(
const clang::FunctionDecl* D,
const std::string& qual_name)
const;
176 const BaseSelectionRule *IsEnumSelected(
const clang::EnumDecl* D,
const std::string& qual_name)
const;
177 const BaseSelectionRule *IsLinkdefVarSelected(
const clang::VarDecl* D,
const std::string& qual_name)
const;
178 const BaseSelectionRule *IsLinkdefFunSelected(
const clang::FunctionDecl* D,
const std::string& qual_name)
const;
179 const BaseSelectionRule *IsLinkdefEnumSelected(
const clang::EnumDecl* D,
const std::string& qual_name)
const;
182 const BaseSelectionRule *IsMemberSelected(
const clang::Decl* D,
const std::string& str_name)
const;
183 const BaseSelectionRule *IsLinkdefMethodSelected(
const clang::Decl* D,
const std::string& qual_name)
const;
186 unsigned int Size()
const{
return fClassSelectionRules.size()+
187 fFunctionSelectionRules.size()+
188 fVariableSelectionRules.size()+
189 fEnumSelectionRules.size();};
192 bool IsParentClass(
const clang::Decl* D)
const;
195 bool IsParentClass(
const clang::Decl* D, std::string& parent_name, std::string& parent_qual_name)
const;
198 bool GetParentName(
const clang::Decl* D, std::string& parent_name, std::string& parent_qual_name)
const;
205 bool GetDeclName(
const clang::Decl* D, std::string&
name, std::string& qual_name)
const;
208 void GetDeclQualName(
const clang::Decl* D, std::string& qual_name)
const;
211 bool GetFunctionPrototype(
const clang::FunctionDecl*
F, std::string& prototype)
const;
214 return fSelectionFileType == kSelectionXMLFile;
217 return fSelectionFileType == kLinkdefFile;
220 fSelectionFileType = fileType;
224 bool AreAllSelectionRulesUsed()
const;
228 bool SearchNames(cling::Interpreter &interp);
std::list< ClassSelectionRule > fClassSelectionRules
List of the class selection rules.
RooCmdArg Optimize(Int_t flag=2)
bool fIsDeep
if –deep option passed from command line, this should be set to true
ROOT::TMetaUtils::TNormalizedCtxt & fNormCtxt
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
const std::list< FunctionSelectionRule > & GetFunctionSelectionRules() const
bool HasClassSelectionRules() const
bool HasEnumSelectionRules() const
ESelectionFileTypes
Type of selection file.
std::list< VariableSelectionRule > fVariableSelectionRules
List of the global variables selection rules.
void SetHasFileNameRule(bool file_rule)
unsigned int Size() const
SelectionRules(cling::Interpreter &interp, ROOT::TMetaUtils::TNormalizedCtxt &normCtxt, const std::vector< std::pair< std::string, std::string >> &namesForExclusion)
bool HasFunctionSelectionRules() const
bool IsSelectionXMLFile() const
bool GetHasFileNameRule() const
const std::list< EnumSelectionRule > & GetEnumSelectionRules() const
The class representing the collection of selection rules.
bool fHasFileNameRule
if we have a file name rule, this should be set to true
const std::list< ClassSelectionRule > & GetClassSelectionRules() const
void SetSelectionFileType(ESelectionFileTypes fileType)
unsigned int r1[N_CITIES]
cling::Interpreter & fInterp
std::list< EnumSelectionRule > fEnumSelectionRules
List of the enums selection rules.
bool areEqual(const RULE *r1, const RULE *r2, bool moduloNameOrPattern=false)
Print a TSeq at the prompt:
void SetSelected(ESelect sel)
ESelectionFileTypes fSelectionFileType
void SetAttributeValue(const std::string &attributeName, const std::string &attributeValue)
bool areEqualColl(const RULESCOLLECTION &r1, const RULESCOLLECTION &r2, bool moduloNameOrPattern=false)
const std::list< VariableSelectionRule > & GetVariableSelectionRules() const
std::list< FunctionSelectionRule > fFunctionSelectionRules
List of the global functions selection rules.
bool areEqualAttributes(const ASSOCIATIVECONTAINER &c1, const ASSOCIATIVECONTAINER &c2, bool moduloNameOrPattern)
bool areEqual< ClassSelectionRule >(const ClassSelectionRule *r1, const ClassSelectionRule *r2, bool moduloNameOrPattern)
bool IsLinkdefFile() const
bool HasVariableSelectionRules() const
unsigned int r2[N_CITIES]