Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
BaseSelectionRule.h
Go to the documentation of this file.
1// @(#)root/core/utils:$Id: BaseSelectionRule.h 28529 2009-05-11 16:43:35Z pcanal $
2// Author: Velislava Spasova September 2010
3
4/*************************************************************************
5 * Copyright (C) 1995-2011, Rene Brun, Fons Rademakers and al. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef R__BASESELECTIONRULE_H
13#define R__BASESELECTIONRULE_H
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// BaseSelectionRule //
18// //
19// Base selection class from which all //
20// selection classes should be derived //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include <string>
25#include <unordered_map>
26#include <list>
27#include <iosfwd>
28
29namespace clang {
30 class NamedDecl;
31 class CXXRecordDecl;
32 class Type;
33}
34namespace cling {
35 class Interpreter;
36}
37
39{
40public:
41 typedef std::unordered_map<std::string, std::string> AttributesMap_t; // The liste of selection rule's attributes (name, pattern, ...)
42
43 enum ESelect { // a rule could be selected, vetoed or we don't care about it
47 };
53 };
54
55private:
56 long fIndex; // Index indicating the ordering of the rules.
57 long fLineNumber=-1; // Line number of the selection file where the rule is located
58 std::string fSelFileName=""; // Name of the selection file
59 AttributesMap_t fAttributes; // list of the attributes of the selection/exclusion rule
60 ESelect fIsSelected; // selected/vetoed/don't care
61 std::list<std::string> fSubPatterns; // a list of subpatterns, generated form a pattern/proto_pattern attribute
62 std::list<std::string> fFileSubPatterns; // a list of subpatterns, generated form a file_pattern attribute
63 bool fMatchFound; // this is true if this selection rule has been used at least once
64 const clang::CXXRecordDecl *fCXXRecordDecl; // Record decl of the entity searched for.
65 const clang::Type *fRequestedType; // Same as the record decl but with some of the typedef preserved (Double32_t, Float16_t, etc..)
66 cling::Interpreter *fInterp;
67
68 // Cached for performance
69 std::string fName = "";
70 std::string fPattern = "";
71 std::string fProtoName = "";
72 std::string fProtoPattern = "";
73 std::string fFileName = "";
74 std::string fFilePattern = "";
75 std::string fNArgsToKeep = "";
76 bool fHasNameAttribute = false;
83 bool fIsFromTypedef = false;
84
85public:
86
88
89 BaseSelectionRule(long index, cling::Interpreter &interp, const char* selFileName = "", long lineno=-1) : fIndex(index),fLineNumber(lineno),fSelFileName(selFileName),fIsSelected(kNo),fMatchFound(false),fCXXRecordDecl(nullptr),fRequestedType(nullptr),fInterp(&interp) {}
90
91 BaseSelectionRule(long index, ESelect sel, const std::string& attributeName, const std::string& attributeValue, cling::Interpreter &interp, const char* selFileName = "",long lineno=-1);
92
93 virtual ~BaseSelectionRule() = default;
94
95 virtual void DebugPrint() const;
96 virtual void Print(std::ostream &out) const = 0;
97
98 long GetIndex() const { return fIndex; }
99 void SetIndex(long index) { fIndex=index; }
100
101 long GetLineNumber() const { return fLineNumber; }
102 const char* GetSelFileName() const { return fSelFileName.c_str(); }
103
104 bool HasAttributeWithName(const std::string& attributeName) const; // returns true if there is an attribute with the specified name
105
106 void FillCache(); // Fill the cache for performant attribute retrival
107
108 bool GetAttributeValue(const std::string& attributeName, std::string& returnValue) const; // returns the value of the attribute with name attributeName
109
110 inline const std::string& GetAttributeName() const {return fName;};
111 inline bool HasAttributeName() const {return fHasNameAttribute;};
112
113 inline const std::string& GetAttributeProtoName() const {return fProtoName;};
114 inline bool HasAttributeProtoName() const {return fHasProtoNameAttribute;};
115
116 inline const std::string& GetAttributePattern() const {return fPattern;};
117 inline bool HasAttributePattern() const {return fHasPatternAttribute;};
118
119 inline const std::string& GetAttributeProtoPattern() const {return fProtoPattern;};
121
122 inline const std::string& GetAttributeFileName() const {return fFileName;};
123 inline bool HasAttributeFileName() const {return fHasFileNameAttribute;};
124
125 inline const std::string& GetAttributeFilePattern() const {return fFilePattern;};
127
128 inline bool IsFromTypedef() const {return fIsFromTypedef;};
130
131 inline const std::string& GetAttributeNArgsToKeep() const {return fNArgsToKeep;};
132
133 void SetAttributeValue(const std::string& attributeName, const std::string& attributeValue); // sets an attribute with name attribute name and value attributeValue
134
135 ESelect GetSelected() const;
136 void SetSelected(ESelect sel);
137
138 bool HasInterpreter() const {return fInterp!=NULL; };
139 void SetInterpreter(cling::Interpreter& interp) {fInterp=&interp; };
140
141 const AttributesMap_t& GetAttributes() const; // returns the list of attributes
142 void PrintAttributes(int level) const; // prints the list of attributes - level is the number of tabs from the beginning of the line
143 void PrintAttributes(std::ostream &out, int level) const; // prints the list of attributes - level is the number of tabs from the beginning of the line
144
145 EMatchType Match(const clang::NamedDecl *decl, const std::string& name, const std::string& prototype, bool isLinkdef) const; // for more detailed description look at the .cxx file
146
147 void SetMatchFound(bool match); // set fMatchFound
148 bool GetMatchFound() const; // get fMatchFound
149
150 const clang::Type *GetRequestedType() const;
151 inline const clang::CXXRecordDecl *GetCXXRecordDecl() const {return fCXXRecordDecl;} ;
152 void SetCXXRecordDecl(const clang::CXXRecordDecl *decl, const clang::Type *typeptr);
153
154protected:
155
156 // Checks if the test string matches against the pattern (which has produced the list of sub-patterns patterns_list). There is
157 // difference if we are processing linkdef.h or selection.xmlpatterns
158 inline bool CheckPattern(const std::string& test, const std::string& pattern, const std::list<std::string>& patterns_list, bool isLinkdef) const;
159
160 inline void ProcessPattern(const std::string& pattern, std::list<std::string>& out) const; // divides a pattern into a list of sub-patterns
161};
162
163inline std::ostream &operator<<(std::ostream& out, const BaseSelectionRule &obj)
164{
165 obj.Print(out);
166 return out;
167}
168#endif
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char name[80]
Definition TGX11.cxx:110
void SetAttributeValue(const std::string &attributeName, const std::string &attributeValue)
bool HasAttributeFileName() const
BaseSelectionRule(long index, cling::Interpreter &interp, const char *selFileName="", long lineno=-1)
bool HasAttributePattern() const
const std::string & GetAttributePattern() const
bool HasAttributeFilePattern() const
bool GetAttributeValue(const std::string &attributeName, std::string &returnValue) const
virtual ~BaseSelectionRule()=default
bool CheckPattern(const std::string &test, const std::string &pattern, const std::list< std::string > &patterns_list, bool isLinkdef) const
bool HasInterpreter() const
void SetSelected(ESelect sel)
void ProcessPattern(const std::string &pattern, std::list< std::string > &out) const
const std::string & GetAttributeFileName() const
const clang::CXXRecordDecl * fCXXRecordDecl
const std::string & GetAttributeNArgsToKeep() const
std::list< std::string > fSubPatterns
bool HasAttributeProtoPattern() const
const clang::CXXRecordDecl * GetCXXRecordDecl() const
virtual void DebugPrint() const
EMatchType Match(const clang::NamedDecl *decl, const std::string &name, const std::string &prototype, bool isLinkdef) const
void SetCXXRecordDecl(const clang::CXXRecordDecl *decl, const clang::Type *typeptr)
void SetIndex(long index)
void SetInterpreter(cling::Interpreter &interp)
const std::string & GetAttributeName() const
const clang::Type * GetRequestedType() const
long GetLineNumber() const
std::string fProtoPattern
const AttributesMap_t & GetAttributes() const
const std::string & GetAttributeProtoName() const
const std::string & GetAttributeProtoPattern() const
ESelect GetSelected() const
bool HasAttributeWithName(const std::string &attributeName) const
bool HasAttributeName() const
AttributesMap_t fAttributes
bool HasAttributeFromTypedef() const
cling::Interpreter * fInterp
bool IsFromTypedef() const
const clang::Type * fRequestedType
void SetMatchFound(bool match)
std::unordered_map< std::string, std::string > AttributesMap_t
void PrintAttributes(int level) const
std::list< std::string > fFileSubPatterns
bool HasAttributeProtoName() const
BaseSelectionRule(ESelect sel)
const char * GetSelFileName() const
virtual void Print(std::ostream &out) const =0
const std::string & GetAttributeFilePattern() const