本文整理汇总了C++中TClass::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TClass::GetName方法的具体用法?C++ TClass::GetName怎么用?C++ TClass::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TClass
的用法示例。
在下文中一共展示了TClass::GetName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testGetClass
template <class T> bool print_root_classname(const T *obj, const char* expect) {
TClass *cl = testGetClass(typeid(*obj));
if (!cl || strcmp(cl->GetName(),expect)!=0 ) {
cerr << "ERROR: in retrieving TClass";
if (cl) { cerr << " found " << cl->GetName() << endl; }
else { cerr << " NOT found!" << endl; };
return 0;
}
cerr << cl->GetName() << endl;
return 1;
}
示例2: loopOnBases
void TestSchemaEvolution::loopOnBases(TClass *tcl) {
TList *bases = tcl->GetListOfBases();
TIter next(bases);
while (TObject *obj = next()) {
TClass *cl = TClass::GetClass(obj->GetName());
if (cl && cl->HasDictionary()) {
unique_classes_.insert(std::make_pair(cl->GetName(), cl->GetClassVersion()));
analyseClass(cl);
}
}
}
示例3: loopOnDataMembers
void TestSchemaEvolution::loopOnDataMembers(TClass *tcl) {
TList *dms = tcl->GetListOfDataMembers();
TIter next(dms);
while (TObject *obj = next()) {
TClass *cl = TClass::GetClass(((TDataMember *)obj)->GetFullTypeName());
if (cl && cl->HasDictionary()) {
unique_classes_.insert(std::make_pair(cl->GetName(), cl->GetClassVersion()));
analyseClass(cl);
}
}
}
示例4: vector_int_cint
void vector_int_cint()
{
gROOT->ProcessLine(".autodict"); // disable auto building of dictionaries.
const std::type_info& t = edm::Wrapper<vector<int> >::typeInfo();
TClass* tc = TClass::GetClass(t);
std::cout << tc->GetName() << std::endl;
TFile f1("vectorinttest.root");
fwlite::Event ev(&f1);
fwlite::Handle<vector<int> > vip;
for (ev.toBegin(); ! ev.atEnd(); ++ev) {
edm::EventID id = ev.id();
cout << "Run " << id.run() << " event " << id.event() << endl;
vip.getByLabel(ev,"VIP");
for (unsigned int i=0; i != vip.ref().size(); ++i) {
cout <<vip.ref().at(i)<<" ";
}
cout << endl;
}
}
示例5: ojtable
void ojtable(const char *className)
{
static int fTableOffset = 0;
if (!fTableOffset) fTableOffset = gObjectTable->IsA()->GetDataMemberOffset("fTable");
// gObjectTable->Print();
TClass *kl;
if (className && !*className) className=0;
const char *qwe = ".*";
if (className) qwe = className;
TRegexp regexp(qwe);
int regexpLen=0;
int sz = gObjectTable->GetSize();
int *ptr = new int[sz];
int *idx = new int[sz];
TObject **tab = *((TObject ***)((char*)gObjectTable+fTableOffset));
TObject *to;
printf ("tab %p[%d]\n",tab,sz);
int i,num=0;
double hSize=0;
int hNumb=0;
const char *info_name = 0;
for (i=0; i<sz; i++)
{
to = tab[i];
if (!to) continue;
if (!to->TestBit(TObject::kNotDeleted)) continue;
int hs = SizeOfH(to);
if (hs) {
hSize+=hs;
hNumb++;
}
if (className && regexp.Index(to->ClassName(),®expLen)<0) continue;
const char *mk = StMkDeb::GetUser(to);
if(mk && *mk) printf("%s(%p) in %s\n",to->ClassName(),to,mk);
ptr[num++]=int(to);
}
printf("TH1 N=%d, Size = %g\n",hNumb,hSize);
TMath::Sort(num,ptr,idx,0);
int last = 0;
printf("Selected %d objects\n",num);
for (i=0; i<num; i++) {
int ix = idx[i];
to = (TObject*)ptr[ix];
int dist = 0;
if (i) dist = ptr[ix]-last;
last = ptr[ix];
// if ((int)to == 0xc94ff34) {
// printf("Skipped %p\n",to); continue; }
info_name = "??";
info_name=typeid(*to).name();
kl = to->IsA();
printf ("%4d +%6d : obj = %p(%3d) %s::%s \tinfo=%s\n",i,dist,to,kl->Size(),kl->GetName(),to->GetName(),info_name);
if (strcmp("TClonesArray",kl->GetName())) continue;
TClonesArray *tcl = ((TClonesArray*)to);
printf(" Sizes = %d %d\n",tcl->GetLast()+1,tcl->Capacity());
tcl->ls("");
}
delete [] ptr;
delete [] idx;
}
示例6: runGetMissingDictionaries
int runGetMissingDictionaries()
{
// Method to assert the dictionaries.
TClass* myClass = TClass::GetClass("TestClass");
if (myClass->HasDictionary())
Error("TClass::HasDictionary", "The class %s does not have a dictionary.", "TestClass");
THashTable expectedResult;
// Hard coded expected results.
expectedResult.Add(TClass::GetClass("NoDictClass"));
expectedResult.Add(TClass::GetClass("TestClass"));
expectedResult.Add(TClass::GetClass("MemberHidden"));
expectedResult.Add(TClass::GetClass("Tmplt<Tmplt<NoDictClass*> >"));
expectedResult.Add(TClass::GetClass("Tmplt<int>"));
expectedResult.Add(TClass::GetClass("Member"));
expectedResult.Add(TClass::GetClass("Tmplt<Member>"));
expectedResult.Add(TClass::GetClass("Tmplt<Base>"));
expectedResult.Add(TClass::GetClass("Outer<Double32_t>"));
expectedResult.Add(TClass::GetClass("Tmplt<TmpParam>"));
expectedResult.Add(TClass::GetClass("Tmplt<Tmplt<TmpTmpParam> >"));
expectedResult.Add(TClass::GetClass("Tmplt<Tmplt<Tmplt<ExtraTmp> > >"));
expectedResult.Add(TClass::GetClass("ParamList<ParamL1,ParamL2>"));
expectedResult.Add(TClass::GetClass("TypedefExample"));
expectedResult.Add(TClass::GetClass("BasicTests::TestAll"));
cerr<<"No recursion:"<<endl; // Write on the same stream of the errors below
THashTable missingDictClassesNoRecursion;
// Assert GetMissingDictionaries without recursion.
myClass->GetMissingDictionaries(missingDictClassesNoRecursion, false);
//missingDictClassesNoRecursion.Print();
if (!missingDictClassesNoRecursion.IsEmpty()) {
if (missingDictClassesNoRecursion.GetEntries() != expectedResult.GetEntries()) {
Error("TClass::GetMissingClassDictionaries", "The set of classes with missing dictionaries does not contain the correct number of elements (expected: %d got %d).",expectedResult.GetEntries(),missingDictClassesNoRecursion.GetEntries());
}
TIterator* it = missingDictClassesNoRecursion.MakeIterator();
TClass* cl = 0;
while ((cl = (TClass*)it->Next())) {
if (!expectedResult.FindObject(cl)) {
Error("TCling::GetMissingDictionaries", "Class %s is not in the expected set.", cl->GetName());
}
}
it = expectedResult.MakeIterator();
while ((cl = (TClass*)it->Next())) {
if (!missingDictClassesNoRecursion.FindObject(cl)) {
Error("TCling::GetMissingDictionaries", "Class %s with no dictionaries is not in the set.", cl->GetName());
}
}
} else {
Error("TClass::GetMissingClassDictionaries", "The set of missing classes is not created");
}
// Assert GetMissingDictionaries with recursion.
// Hard code expected results with recursion.
expectedResult.Add(TClass::GetClass("ArrayTry"));
expectedResult.Add(TClass::GetClass("NoA"));
expectedResult.Add(TClass::GetClass("vector<Tmplt<NoDictClass*> >"));
expectedResult.Add(TClass::GetClass("Tmplt<NoDictClass*>"));
expectedResult.Add(TClass::GetClass("vector<Member>"));
expectedResult.Add(TClass::GetClass("Base"));
expectedResult.Add(TClass::GetClass("vector<Base>"));
expectedResult.Add(TClass::GetClass("Inner<Double32_t>"));
expectedResult.Add(TClass::GetClass("TmpParam"));
expectedResult.Add(TClass::GetClass("TmpTmpParam"));
expectedResult.Add(TClass::GetClass("Tmplt<TmpTmpParam>"));
expectedResult.Add(TClass::GetClass("ExtraTmp"));
expectedResult.Add(TClass::GetClass("Tmplt<ExtraTmp>"));
expectedResult.Add(TClass::GetClass("Tmplt<Tmplt<ExtraTmp> >"));
expectedResult.Add(TClass::GetClass("vector<Tmplt<Tmplt<ExtraTmp> > >"));
expectedResult.Add(TClass::GetClass("vector<NoDictClass*> "));
expectedResult.Add(TClass::GetClass("vector<TmpTmpParam>"));
expectedResult.Add(TClass::GetClass("vector<Tmplt<ExtraTmp> >"));
expectedResult.Add(TClass::GetClass("vector<ExtraTmp> "));
expectedResult.Add(TClass::GetClass("vector<Tmplt<TmpTmpParam> >"));
expectedResult.Add(TClass::GetClass("vector<TmpParam>"));
expectedResult.Add(TClass::GetClass("vector<Double32_t>"));
expectedResult.Add(TClass::GetClass("ParamL1"));
expectedResult.Add(TClass::GetClass("ParamL2"));
expectedResult.Add(TClass::GetClass("vector<ParamL2*>"));
expectedResult.Add(TClass::GetClass("BasicTests::NoDictTypdefs"));
expectedResult.Add(TClass::GetClass("BasicTests::NoDict"));
expectedResult.Add(TClass::GetClass("BasicTests::HasVecDoubleTD32"));
expectedResult.Add(TClass::GetClass("BasicTests::HasVecDouble32"));
expectedResult.Add(TClass::GetClass("map<unsigned short,Double32_t>"));
cerr<<"With recursion:"<<endl; // Write on the same stream of the errors below
THashTable missingDictClassesRecursion;
myClass->GetMissingDictionaries(missingDictClassesRecursion, true);
//missingDictClassesRecursion.Print();
if (!missingDictClassesRecursion.IsEmpty()) {
if (missingDictClassesRecursion.GetEntries() != expectedResult.GetEntries()) {
Error("TClass::GetMissingClassDictionaries", "The set of classes with missing dictionaries does not contain the correct number of elements (expected: %d got %d).",expectedResult.GetEntries(),missingDictClassesRecursion.GetEntries());
// expectedResult.ls();
// missingDictClassesRecursion.ls();
}
TIterator* it = missingDictClassesRecursion.MakeIterator();
TClass* cl = 0;
while ((cl = (TClass*)it->Next())) {
if (!expectedResult.FindObject(cl)) {
//.........这里部分代码省略.........
示例7: classesFromBranch
void classesFromBranch(TBranch *tbranch, TClass *tclass, std::vector<ClassStructure> &classes, int prefix, std::set<std::string> &includes) {
std::string className = tclass->GetName();
if (className == std::string("TObject"))
includes.insert("#include \"TObject.h\"");
else if (className == std::string("TRef"))
includes.insert("#include \"TRef.h\"");
else if (className == std::string("TRefArray"))
includes.insert("#include \"TRefArray.h\"");
else if (className == std::string("TH1"))
includes.insert("#include \"TH1.h\"");
else if (className == std::string("TBits")) {
includes.insert("#include \"TBits.h\"");
}
else {
bool classSeen = false;
for (int i = 0; i < classes.size(); i++)
if (classes[i].fullName == className)
classSeen = true;
if (!classSeen) {
TVirtualStreamerInfo *tVirtualStreamerInfo = tclass->GetStreamerInfo();
int version = tVirtualStreamerInfo->GetClassVersion();
ClassStructure classStructure(tclass, version);
if (tVirtualStreamerInfo->GetElements()->GetEntries() == 1 &&
((TStreamerElement*)(tVirtualStreamerInfo->GetElements()->First()))->IsBase() &&
std::string(tVirtualStreamerInfo->GetElements()->First()->GetName()) == std::string("TObjArray")) {
TVirtualStreamerInfo *substreamer = ((TBranchElement*)tbranch)->GetInfo();
if (std::string(substreamer->GetName()) == std::string("TClonesArray")) {
ROOT::Internal::TTreeGeneratorBase ttreeGenerator(tbranch->GetTree(), "");
TString className = ttreeGenerator.GetContainedClassName((TBranchElement*)tbranch, (TStreamerElement*)(substreamer->GetElements()->First()), true);
classesFromBranch(tbranch, TClass::GetClass(className), classes, prefix + std::string(tbranch->GetName()).size() + 1, includes);
}
}
TIter elements = tVirtualStreamerInfo->GetElements();
for (TStreamerElement *tStreamerElement = (TStreamerElement*)elements.Next(); tStreamerElement != nullptr; tStreamerElement = (TStreamerElement*)elements.Next()) {
std::string streamerName = tStreamerElement->GetName();
if (tStreamerElement->IsBase()) {
TClass *elementClass = tStreamerElement->GetClassPointer();
std::string type = elementClass->GetName();
if (type == std::string("TObject")) {
classStructure.bases.push_back(type);
includes.insert(std::string("#include \"") + type + std::string(".h\""));
}
}
else {
TIter listOfBranches = tbranch->GetListOfBranches();
TBranch *subbranch;
for (subbranch = (TBranch*)listOfBranches.Next(); subbranch != nullptr; subbranch = (TBranch*)listOfBranches.Next()) {
std::string branchName = subbranch->GetName();
branchName = branchName.substr(prefix, std::string::npos);
int firstDot = branchName.find('.');
int firstBracket = branchName.find('[');
if (firstDot != std::string::npos && firstBracket != std::string::npos)
branchName = branchName.substr(0, firstDot < firstBracket ? firstDot : firstBracket);
else if (firstDot != std::string::npos)
branchName = branchName.substr(0, firstDot);
else if (firstBracket != std::string::npos)
branchName = branchName.substr(0, firstBracket);
if (branchName == streamerName)
break;
}
if (subbranch == nullptr)
continue;
std::string branchName = subbranch->GetName();
std::string variable = tStreamerElement->GetName();
std::string variableWithArray = subbranch->GetName();
variableWithArray = variableWithArray.substr(prefix, std::string::npos);
variableWithArray = variableWithArray.substr(0, variableWithArray.find('.'));
std::string comment = tStreamerElement->GetTitle();
std::string type;
Bool_t pointer = false;
switch (tStreamerElement->GetType()) {
case TVirtualStreamerInfo::kOffsetP + TVirtualStreamerInfo::kBool:
pointer = true;
case TVirtualStreamerInfo::kOffsetL + TVirtualStreamerInfo::kBool:
case TVirtualStreamerInfo::kBool:
type = "Bool_t";
break;
case TVirtualStreamerInfo::kOffsetP + TVirtualStreamerInfo::kChar:
pointer = true;
case TVirtualStreamerInfo::kOffsetL + TVirtualStreamerInfo::kChar:
case TVirtualStreamerInfo::kChar:
type = "Char_t";
break;
//.........这里部分代码省略.........