7 #include "KVClassFactory.h"
12 #include "KVHashList.h"
30 output += (indent + _line);
43 : fBaseClass(nullptr), fHasBaseClass(
kFALSE), fBaseClassTObject(
kFALSE), fInlineAllMethods(
kFALSE), fInlineAllCtors(
kFALSE),
44 fInheritAllCtors(
kTRUE)
85 const Char_t* templateFile)
86 : fBaseClass(nullptr), fHasBaseClass(
kFALSE), fBaseClassTObject(
kFALSE), fInlineAllMethods(
kFALSE), fInlineAllCtors(
kFALSE),
87 fInheritAllCtors(
kTRUE)
168 fWithTemplate = temp;
169 fTemplateBase = templateFile;
174 if (!CheckTemplateFiles(
GetBaseClass(), templateFile)) {
176 KVError::Error(
this,
"SetTemplate",
"Cannot find template files %s. Object made a zombie.", templateFile);
184 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
199 ((
KVClassFactory&)obj).SetTemplate(WithTemplate(), GetTemplateBase());
201 if (fMethods.GetEntries()) {
202 TIter next(&fMethods);
207 if (fImpInc.GetEntries()) fImpInc.Copy(((
KVClassFactory&)obj).fImpInc);
220 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,4,0)
234 void KVClassFactory::WriteWhoWhen(ofstream&
file)
241 file <<
"Write a detailed documentation for your class here, see doxygen manual for help.\n\n ";
242 file <<
"\\author " << fAuthor.
Data() <<
"\n \\date " << fNow.
AsString() <<
"\n*/\n\n";
254 void KVClassFactory::WritePreProc(ofstream&
file)
262 file <<
"#pragma once\n" << endl;
267 fBaseClassName.
Begin(
",");
268 while (!fBaseClassName.
End())
269 file <<
"#include \"" << fBaseClassName.
Next(kTRUE) <<
".h\"" << endl;
273 file <<
"#include \"" << fBaseClassName.
Data() <<
".h\"\n" << endl;
276 TIter next(&fHeadInc);
293 void KVClassFactory::WriteClassDec(ofstream&
file)
301 file <<
"class " << fClassName.
Data();
305 fBaseClassName.
Begin(
",");
306 file <<
"public " << fBaseClassName.
Next(kTRUE);
307 while (!fBaseClassName.
End())
file <<
", public " << fBaseClassName.
Next(kTRUE);
310 file <<
"public " << fBaseClassName.
Data();
312 file <<
"\n{" << endl;
316 if (prem->GetEntries()) {
317 file <<
"\n" << endl;
319 TIter next(prem.get());
321 while ((meth = (KVClassMember*)next())) {
322 meth->WriteDeclaration(line);
329 unique_ptr<KVSeqCollection> ctor(priv->GetSubListWithMethod(
"1",
"IsConstructor"));
330 if (ctor->GetEntries()) {
333 TIter next(ctor.get());
335 while ((meth = (KVClassMethod*)next())) {
336 meth->WriteDeclaration(line);
340 if (priv->GetEntries()) {
343 TIter next(priv.get());
345 while ((meth = (KVClassMethod*)next())) {
346 if (meth->IsNormalMethod()) {
347 meth->WriteDeclaration(line);
359 bool protected_written =
kFALSE;
363 if (prem->GetEntries()) {
364 file <<
"\nprotected:" << endl;
365 protected_written =
kTRUE;
367 TIter next(prem.get());
369 while ((meth = (KVClassMember*)next())) {
370 meth->WriteDeclaration(line);
377 ctor.reset(prot->GetSubListWithMethod(
"1",
"IsConstructor"));
378 if (ctor->GetEntries()) {
379 if (!protected_written) {
380 file <<
"\nprotected:" << endl;
381 protected_written =
kTRUE;
386 TIter next(ctor.get());
388 while ((meth = (KVClassMethod*)next())) {
389 meth->WriteDeclaration(line);
393 if (prot->GetEntries()) {
394 if (!protected_written) {
395 file <<
"\nprotected:" << endl;
396 protected_written =
kTRUE;
401 TIter next(prot.get());
403 while ((meth = (KVClassMethod*)next())) {
404 if (meth->IsNormalMethod()) {
405 meth->WriteDeclaration(line);
412 if (!protected_written) {
413 file <<
"\nprotected:" << endl;
414 protected_written =
kTRUE;
424 file <<
"public:" << endl;
427 ctor.reset(pub->GetSubListWithMethod(
"1",
"IsConstructor"));
428 unique_ptr<KVSeqCollection> pubnor(pub->GetSubListWithMethod(
"1",
"IsNormalMethod"));
429 if (ctor->GetEntries()) {
431 TIter next(ctor.get());
433 while ((meth = (KVClassMethod*)next())) {
434 meth->WriteDeclaration(line);
444 if (pubnor->GetEntries())
file << endl;
448 if (pubnor->GetEntries()) {
450 TIter next(pubnor.get());
452 while ((meth = (KVClassMethod*)next())) {
453 meth->WriteDeclaration(line);
458 file <<
"\n ClassDef(" << fClassName.
Data() <<
",1)//";
460 file <<
"};\n" << endl;
469 void KVClassFactory::WriteClassImp()
477 if (fClassPath !=
"")
gSystem->
mkdir(fClassPath, kTRUE);
480 file_cpp <<
"#include \"" << fClassName.
Data() <<
".h\"" << endl;
482 TIter next(&fImpInc);
485 file_cpp <<
"#include \"" << str->
String().
Data() <<
"\"" << endl;
488 file_cpp << endl <<
"ClassImp(" << fClassName.
Data() <<
")\n" << endl << endl;
492 if (ctor->GetEntries()) {
494 TIter next(ctor.get());
496 while ((meth = (KVClassMethod*)next())) {
497 if (!meth->IsInline()) {
498 meth->WriteImplementation(line);
499 file_cpp <<
line.Data() << endl;
508 file_cpp <<
line.Data() << endl;
513 if (normeth->GetEntries()) {
515 TIter next(normeth.get());
517 while ((meth = (KVClassMethod*)next())) {
518 if (!meth->IsInline()) {
519 meth->WriteImplementation(line);
520 file_cpp <<
line.Data() << endl << endl;
527 cout <<
"<KVClassFactory::WriteClassImp> : File " <<
GetImpFileName() <<
" generated." << endl;
535 void KVClassFactory::WriteClassHeader()
542 if (fClassPath !=
"")
gSystem->
mkdir(fClassPath, kTRUE);
545 WritePreProc(file_h);
546 WriteWhoWhen(file_h);
547 WriteClassDec(file_h);
551 cout <<
"<KVClassFactory::WriteClassHeader> : File " <<
GetHeaderFileName() <<
" generated." << endl;
635 const Char_t* templateFile)
711 KVClassFactory cf(classname, classdesc, base_class, withTemplate, templateFile);
737 KVError::Warning(
this,
"GenerateCode",
"Object is zombie. No code will be generated.");
742 WriteClassWithTemplateHeader();
743 WriteClassWithTemplateImp();
749 AddCopyConstructor();
750 AddMemberInitialiserConstructor();
751 AddAssignmentOperator();
752 if (fBaseClassTObject) {
756 AddTObjectCopyMethod();
758 else if (!fHasBaseClass) {
764 GenerateGettersAndSetters();
795 void KVClassFactory::GenerateGettersAndSetters()
803 while ((m = (KVClassMember*)it())) {
804 TString mem_name =
m->GetRealName();
807 if (mem_type ==
"Bool_t") meth =
AddMethod(
Form(
"SetIs%s", mem_name.
Data()),
"void");
810 meth->AddArgument(mem_type);
811 meth->SetMethodComment(
817 if (mem_type ==
"Bool_t") meth =
AddMethod(
Form(
"Is%s", mem_name.
Data()), mem_type,
"public", kFALSE, kTRUE);
818 else meth =
AddMethod(
Form(
"Get%s", mem_name.
Data()), mem_type,
"public", kFALSE, kTRUE);
820 meth->SetMethodComment(
836 void KVClassFactory::SetWhoWhen()
844 fAuthor = user->
fUser;
877 Ssiz_t beg_cur_line = beg;
880 while (pos <
file.Length()) {
882 if (
file(pos) ==
' ' ||
file(pos) ==
'\t') {
886 else if (
file(pos) ==
'\n') {
889 if (nonWS)
return beg_cur_line;
893 else if (
file(pos) ==
'/') {
895 if (
file(pos + 1) ==
'*') {
898 if (nonWS)
return beg_cur_line;
900 if (len > -1) pos =
len + 2;
908 else if (
file(pos + 1) ==
'/') {
911 if (nonWS)
return beg_cur_line;
932 if (nonWS && pos > -1)
return beg_cur_line;
943 void KVClassFactory::WriteClassWithTemplateHeader()
952 if (fClassPath !=
"")
gSystem->
mkdir(fClassPath, kTRUE);
955 WritePreProc(file_h);
956 WriteWhoWhen(file_h);
958 ifstream file_h_template;
964 "<KVClassFactory::WriteClassWithTemplateHeader>: cannot open " <<
965 fTemplateH.
Data() << endl;
971 file_h_template.close();
975 if ((class_ind = headFile.
Index(
"ClassDef")) > -1) {
978 Ssiz_t end_of_line = class_ind;
979 while (headFile(--end_of_line) !=
'\n') ;
981 TString part1 = headFile(0, end_of_line + 1);
988 TString part2 =
" ClassDefOverride(";
999 KVString acc_types[] = {
"private",
"protected",
"public",
"-"};
1001 while (acc_types[iac] !=
"-") {
1003 if (sublist->GetEntries()) {
1004 part_add += acc_types[iac];
1006 TIter next(sublist.get());
1007 KVClassMethod* meth;
1008 while ((meth = (KVClassMethod*)next())) {
1009 meth->WriteDeclaration(line);
1020 headFile = part1 + part_add + part2 + part3;
1028 cout <<
"<KVClassFactory::WriteClassWithTemplateHeader> : File " <<
GetHeaderFileName() <<
" generated." << endl;
1037 void KVClassFactory::WriteClassWithTemplateImp()
1044 if (fClassPath !=
"")
gSystem->
mkdir(fClassPath, kTRUE);
1047 file_cpp <<
"#include \"" << fClassName.
Data() <<
".h\"" << endl;
1049 TIter next(&fImpInc);
1052 file_cpp <<
"#include \"" << str->
String().
Data() <<
"\"" << endl;
1055 file_cpp << endl <<
"ClassImp(" << fClassName.
Data() <<
")\n" << endl;
1058 ifstream file_cpp_template;
1062 SearchAndOpenKVFile(fTemplateCPP.
Data(), file_cpp_template)) {
1064 cout <<
"<KVClassFactory::WriteClassWithTemplateImp>: cannot open "
1065 << fTemplateCPP.
Data() << endl;
1069 cppFile.
ReadFile(file_cpp_template);
1070 file_cpp_template.close();
1077 TIter next(&fMethods);
1078 KVClassMethod* meth;
1079 while ((meth = (KVClassMethod*)next())) {
1080 meth->WriteImplementation(line);
1081 file_cpp <<
line.Data();
1086 cout <<
"<KVClassFactory::WriteClassWithTemplateImp> : File " <<
GetImpFileName() <<
" generated." << endl;
1109 Bool_t KVClassFactory::CheckTemplateFiles(
const Char_t* base_class,
1110 const Char_t* templateFile)
1128 if (strcmp(base_class,
"")) {
1131 fTemplateClassName = base_class;
1132 fTemplateClassName +=
"Template";
1147 filename = fTemplateClassName +
".cpp";
1241 if (strcmp(argument_type,
"")) {
1244 meth->
AddArgument(argument_type, argument_name, default_value);
1248 meth->
SetName(
"default_ctor");
1266 const Char_t* argument_name,
const Char_t* default_value)
1276 "Method %s not found.", method_name);
1279 meth->
AddArgument(argument_type, argument_name, default_value);
1297 "Method %s not found.", method_name);
1315 "Method %s not found.", method_name);
1368 Info(
"Print",
"object name = %s, address = %p",
GetName(),
this);
1369 cout <<
" * fClassName = " << fClassName.
Data() << endl;
1370 cout <<
" * fClassDesc = " << fClassDesc.
Data() << endl;
1371 cout <<
" * fBaseClass = " << fBaseClassName.
Data() << endl;
1372 cout <<
" * fTemplateBase = " << fTemplateBase.
Data() << endl;
1373 cout <<
"---------> Methods" << endl;
1375 cout <<
"---------> Header Includes" << endl;
1377 cout <<
"---------> Implementation Includes" << endl;
1391 for (
int i = 0; i < npars; i++) {
1394 AddMember(par->
GetName(),
"TString",
"member automatically generated by KVClassFactory::AddGetSetMethods");
1398 else if (par->
IsInt()) {
1399 AddMember(par->
GetName(),
"Int_t",
"member automatically generated by KVClassFactory::AddGetSetMethods");
1402 AddMember(par->
GetName(),
"Double_t",
"member automatically generated by KVClassFactory::AddGetSetMethods");
1404 else if (par->
IsBool()) {
1405 AddMember(par->
GetName(),
"Bool_t",
"member automatically generated by KVClassFactory::AddGetSetMethods");
1419 TIter it(&fMethods);
1422 if (!
m->IsConstructor() && !
m->IsDestructor())
m->SetInline(yes);
1424 fInlineAllMethods = yes;
1438 fInlineAllCtors = yes;
1450 void KVClassFactory::AddTObjectCopyMethod()
1457 AddMethod(
"Copy",
"void",
"public", kFALSE, kTRUE);
1459 KVString body(
"This method copies the current state of 'this' object into 'obj'\n\n");
1460 body +=
"You should add here any member variables, for example:\n\n";
1461 body +=
"(supposing a member variable ";
1463 body +=
"::fToto)\n";
1464 body +=
" CastedObj.fToto = fToto;\n";
1466 body +=
" CastedObj.SetToto( GetToto() );";
1470 body += fBaseClassName;
1471 body +=
"::Copy(obj);\n";
1475 body +=
"& CastedObj = (";
1479 TIter it(&fMembers);
1481 while ((m = (KVClassMember*)it())) {
1482 body +=
" CastedObj.Set";
1483 body +=
m->GetRealName();
1485 body +=
m->GetRealName();
1499 void KVClassFactory::AddCopyConstructor()
1508 ctor->SetCopyCtor();
1509 ctor->SetMethodComment(
"Copy constructor");
1510 if (fBaseClassTObject) {
1511 ctor->SetMethodBody(
" obj.Copy(*this);");
1528 void KVClassFactory::AddMemberInitialiserConstructor(KVClassConstructor* base_ctor)
1541 TIter next(&fMembers);
1542 KVClassMember* memb = (KVClassMember*)next();
1543 KVClassConstructor* ctor;
1545 Int_t add_to_base(1);
1548 adding_to_base =
kTRUE;
1549 ctor->AddArgument(add_to_base, memb->GetType(), memb->GetRealName());
1550 ctor->SetMemberVariableNameForArgument(add_to_base, memb->GetName());
1554 ctor->SetMemberVariableNameForArgument(1, memb->GetName());
1557 while ((memb = (KVClassMember*)next())) {
1558 if (adding_to_base) {
1559 ctor->AddArgument(++add_to_base, memb->GetType(), memb->GetRealName());
1560 ctor->SetMemberVariableNameForArgument(add_to_base, memb->GetName());
1563 ctor->AddArgument(memb->GetType(), memb->GetRealName());
1564 ctor->SetMemberVariableNameForArgument(arg_num++, memb->GetName());
1567 ctor->SetMethodComment(
"Constructor with initial values for all member variables");
1575 void KVClassFactory::AddAssignmentOperator()
1581 auto swap_method =
AddMethod(
"swap",
"friend void");
1582 swap_method->AddArgument(
Form(
"%s&",fClassName.
Data()),
"a");
1583 swap_method->AddArgument(
Form(
"%s&",fClassName.
Data()),
"b");
1584 swap_method->SetInline();
1585 swap_method->SetMethodComment(
"Exception-safe swap method (copy & swap idiom)");
1586 KVString body =
" using std::swap;\n";
1587 TIter it(&fMembers);
1589 while ((m = (KVClassMember*)it())) {
1598 body +=
Form(
" swap(static_cast<%s&>(a),static_cast<%s&>(b));\n", fBaseClassName.
Data(), fBaseClassName.
Data());
1599 swap_method->SetMethodBody(body);
1601 oper->AddArgument(fClassName,
"other");
1602 oper->SetMethodComment(
"Assignment/move operator (copy & swap idiom)");
1603 body =
" swap(*this,other);\n";
1604 body +=
" return (*this);";
1605 oper->SetMethodBody(body);
1607 move_con->SetMoveCtor();
1608 move_con->SetMethodComment(
"Move constructor (copy & swap idiom)");
1609 move_con->SetNoExcept();
1610 body =
" swap(*this,other);";
1611 move_con->SetMethodBody(body);
1635 write_doxygen_format_method_comments(decl);
1637 if (fVirtual) decl +=
"virtual ";
1638 if (IsNormalMethod()) {
1639 decl += GetReturnType();
1645 decl += GetClassName();
1648 for (
int i = 1; i <= fNargs; i++) {
1649 decl += fFields.GetStringValue(
Form(
"Arg_%d", i));
1650 if (fFields.HasParameter(
Form(
"Arg_%d_name", i))) {
1652 decl += fFields.GetStringValue(
Form(
"Arg_%d_name", i));
1655 decl +=
Form(
" arg%d", i);
1656 if (fFields.HasParameter(
Form(
"Arg_%d_default", i))) {
1658 decl += fFields.GetStringValue(
Form(
"Arg_%d_default", i));
1660 if (i < fNargs) decl +=
", ";
1663 if (fConst) decl +=
" const";
1664 if (fNoexcept) decl +=
" noexcept";
1670 write_method_body(decl);
1699 void KVClassFactory::KVClassMethod::write_method_body(
KVString& decl)
1702 if (IsInline()) indentation =
" ";
1704 decl += __add_indented_line(
"{", indentation);
1705 if (!strcmp(GetAccess(),
"private")) decl += __add_indented_line(
" // PRIVATE method", indentation);
1706 else if (!strcmp(GetAccess(),
"protected")) decl += __add_indented_line(
" // PROTECTED method", indentation);
1707 if (fFields.HasParameter(
"Body")) {
1709 decl += __add_indented_line(fFields.GetStringValue(
"Body"), indentation);
1712 if (fFields.HasParameter(
"ReturnType") && strcmp(fFields.GetStringValue(
"ReturnType"),
"void")) {
1714 return_dir += GetReturnType();
1715 return_dir +=
")0;";
1716 __add_indented_line(return_dir, indentation);
1719 decl += __add_indented_line(
"}", indentation, kFALSE);
1726 void KVClassFactory::KVClassConstructor::write_method_body(
KVString& decl)
1729 if (IsInline()) indentation =
" ";
1730 if ((fNargs && !IsCopyCtor()) ||
1731 ((IsCopyCtor() || IsDefaultCtor()) && fFields.HasParameter(
"BaseClass"))
1732 || (IsCopyCtor() && !fParentClass->IsBaseClassTObject())
1739 else if (fFields.HasParameter(
"BaseClass")) {
1741 decl += fFields.GetStringValue(
"BaseClass");
1743 if (!IsCopyCtor() && fNargs) {
1744 Int_t base_args = 0;
1745 for (
int i = 1; i <= fNargs; i++) {
1746 if (fFields.HasParameter(
Form(
"Arg_%d_baseclass", i))) {
1748 if (fFields.HasParameter(
Form(
"Arg_%d_name", i))) {
1749 if (base_args > 1) decl +=
", ";
1750 decl += fFields.GetStringValue(
Form(
"Arg_%d_name", i));
1753 if (base_args > 1) decl +=
", ";
1754 decl +=
Form(
"arg%d", i);
1759 else if (IsCopyCtor() && !fParentClass->IsBaseClassTObject()) {
1761 decl += fFields.GetStringValue(
"Arg_1_name");
1764 if ((fNargs && !IsCopyCtor() && fParentClass->GetNumberOfMemberVariables())
1765 || (IsCopyCtor() && !fParentClass->IsBaseClassTObject() && fParentClass->GetNumberOfMemberVariables())) decl +=
", ";
1767 if (fParentClass->GetNumberOfMemberVariables()) {
1769 if (!IsCopyCtor() && fNargs) {
1771 for (
int i = 1; i <= fNargs; i++) {
1772 if (fFields.HasStringParameter(
Form(
"Arg_%d_memvar", i))) {
1773 if (mem_vars) decl +=
", ";
1774 decl += fFields.GetStringValue(
Form(
"Arg_%d_memvar", i));
1776 decl += fFields.GetStringValue(
Form(
"Arg_%d_name", i));
1782 else if ((IsCopyCtor() && !fParentClass->IsBaseClassTObject())) {
1783 TIter it(fParentClass->GetListOfMembers());
1786 while ((m = (KVClassMember*)it())) {
1787 if (imem) decl +=
", ";
1790 decl += fFields.GetStringValue(
"Arg_1_name");
1792 decl +=
m->GetRealName();
1800 decl += __add_indented_line(
"{", indentation);
1801 if (!strcmp(GetAccess(),
"private")) decl += __add_indented_line(
" // PRIVATE constructor", indentation);
1802 else if (!strcmp(GetAccess(),
"protected")) decl += __add_indented_line(
" // PROTECTED constructor", indentation);
1803 if (fFields.HasParameter(
"Body")) {
1805 decl += __add_indented_line(fFields.GetStringValue(
"Body"), indentation);
1807 decl += __add_indented_line(
"}", indentation, kFALSE);
1814 void KVClassFactory::KVClassMethod::write_doxygen_format_method_comments(
KVString& decl)
1816 if (fFields.HasParameter(
"Comment")) {
1818 KVString comment(fFields.GetStringValue(
"Comment"));
1819 comment.Begin(
"\n");
1822 while (!comment.End()) {
1824 if (
line.Length() > longest) longest =
line.Length();
1828 while (longest--) decl +=
"/";
1830 comment.
Begin(
"\n");
1831 while (!comment.End()) {
1853 write_doxygen_format_method_comments(decl);
1854 decl += GetReturnType();
1855 if (IsNormalMethod()) {
1860 if (IsNormalMethod())
1867 for (
int i = 1; i <= fNargs; i++) {
1868 decl += fFields.GetStringValue(
Form(
"Arg_%d", i));
1869 if (fFields.HasParameter(
Form(
"Arg_%d_name", i))) {
1871 decl += fFields.GetStringValue(
Form(
"Arg_%d_name", i));
1874 decl +=
Form(
" arg%d", i);
1875 if (i < fNargs) decl +=
", ";
1878 if (fConst) decl +=
" const";
1879 if (fNoexcept) decl +=
" noexcept";
1880 write_method_body(decl);
1951 if (!(i > 0 && i <= fNargs + 1)) {
1952 KVError::Error(
this,
"AddArgument(Int_t i, ...)",
"Must be called with i>0 & i<=%d", fNargs + 1);
1956 if (i == fNargs + 1) {
1957 AddArgument(
type, argname, defaultvalue);
1961 for (
int j = fNargs; j >= i; --j) {
1962 if (fFields.HasStringParameter(
Form(
"Arg_%d", j))) {
1963 fFields.SetValue(
Form(
"Arg_%d", j + 1), fFields.GetStringValue(
Form(
"Arg_%d", j)));
1964 fFields.RemoveParameter(
Form(
"Arg_%d", j));
1966 if (fFields.HasStringParameter(
Form(
"Arg_%d_name", j))) {
1967 fFields.SetValue(
Form(
"Arg_%d_name", j + 1), fFields.GetStringValue(
Form(
"Arg_%d_name", j)));
1968 fFields.RemoveParameter(
Form(
"Arg_%d_name", j));
1970 if (fFields.HasIntParameter(
Form(
"Arg_%d_baseclass", j))) {
1971 fFields.SetValue(
Form(
"Arg_%d_baseclass", j + 1), fFields.GetIntValue(
Form(
"Arg_%d_baseclass", j)));
1972 fFields.RemoveParameter(
Form(
"Arg_%d_baseclass", j));
1974 if (fFields.HasStringParameter(
Form(
"Arg_%d_default", j))) {
1975 fFields.SetValue(
Form(
"Arg_%d_default", j + 1), fFields.GetStringValue(
Form(
"Arg_%d_default", j)));
1976 fFields.RemoveParameter(
Form(
"Arg_%d_default", j));
1981 fFields.SetValue(
Form(
"Arg_%d", i), _type);
1982 if (strcmp(defaultvalue,
"")) {
1984 fFields.SetValue(
Form(
"Arg_%d_default", i), _s);
1986 if (strcmp(argname,
"")) {
1988 fFields.SetValue(
Form(
"Arg_%d_name", i), _s);
2002 cout <<
"KVClassMethod object -----> " <<
GetName() << endl;
2004 cout <<
"This method is " << GetAccess() << endl;
2005 if (fConst) cout <<
"This method is CONST" << endl;
2006 if (fVirtual) cout <<
"This method is VIRTUAL" << endl;
2017 cout <<
"KVClassMember object -----> " <<
GetType() <<
" " <<
GetName() << endl;
2018 cout <<
"This member is " << GetAccess() << endl;
2037 if (!fBaseClass)
return;
2042 TIter next_ctor(constructors.get());
2044 while ((method = (
TMethod*)next_ctor())) {
2049 if (typenam.
Contains(fBaseClassName))
continue;
2054 for (
int i = 1; i < method->
GetNargs(); i++) {
2061 AddMemberInitialiserConstructor(ctor);
2082 d->SetClassName(fClassName);
2083 d->SetAccess(access);
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 filename
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 Atom_t Atom_t Time_t UChar_t len
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 Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Base class for KaliVeda framework.
virtual const Char_t * GetType() const
static const Char_t * GetTEMPLATEDIRFilePath(const Char_t *namefile="")
void Copy(TObject &) const override
Make a copy of this object.
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
static Bool_t SearchAndOpenKVFile(const Char_t *name, KVSQLite::database &dbfile, const Char_t *kvsubdir="")
Constructor for a class generated with KVClassFactory.
void SetBaseClassArgument(Int_t i)
Destructor for a class generated with KVClassFactory.
Member variable in a class generated with KVClassFactory.
virtual void WriteDeclaration(KVString &)
void Print(Option_t *="") const override
print the KVClass member
void SetAccess(const Char_t *acc="public")
set access type : public, protected or private
void Copy(TObject &obj) const override
copy this to obj
Bool_t IsFundamental() const
const Char_t * GetComment() const
get access type : public, protected or private
Method in a class generated with KVClassFactory.
void SetMethodComment(const KVString &com)
void Copy(TObject &obj) const override
copy this to obj
void WriteDeclaration(KVString &) override
KVClassMethod(Bool_t Virtual=kFALSE, Bool_t Const=kFALSE, Bool_t Inline=kFALSE)
void SetConst(Bool_t c=kTRUE)
void WriteImplementation(KVString &decl)
void SetBaseClass(const Char_t *name)
void Print(Option_t *="") const override
print the KVClass method
void AddArgument(const Char_t *type, const Char_t *argname="", const Char_t *defaultvalue="")
void SetReturnType(const Char_t *type)
void SetClassName(const Char_t *name)
void SetVirtual(Bool_t c=kTRUE)
void SetInline(Bool_t yes=kTRUE)
void SetMethodBody(const KVString &body)
Factory class for generating skeleton files for new classes.
void Print(Option_t *opt="") const override
Print infos on object.
void Copy(TObject &obj) const override
Copy the state of this KVClassFactory to the one referenced by 'obj'.
const Char_t * GetClassDesc() const
Bool_t HasVirtualMethods() const
Bool_t WithMultipleBaseClasses() const
void SetTemplate(Bool_t temp, const Char_t *temp_file)
void AddMethodComment(const Char_t *method_name, const KVString &comment)
Set the comments for method 'method_name' added to the class using AddMethod.
void GenerateCode()
Generate header and implementation file for currently-defined class.
void SetClassName(const Char_t *n)
const Char_t * GetImpFileName() const
const Char_t * GetHeaderFileName() const
KVClassFactory()
Default ctor.
KVClassConstructor * GetDefaultCtor() const
static void MakeClass(const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="", Bool_t withTemplate=kFALSE, const Char_t *templateFile="")
void AddHeaderIncludeFile(const Char_t *filename)
void AddDestructor(const TString &access="public")
void AddImplIncludeFile(const Char_t *filename)
void AddDefaultConstructor()
const Char_t * GetClassName() const
void SetClassDesc(const Char_t *d)
Int_t GetNumberOfMemberVariables() const
void AddMethodBody(const Char_t *method_name, const KVString &body)
const Char_t * GetBaseClass() const
void InlineAllMethods(bool yes=true)
void AddMethodArgument(const Char_t *method_name, const Char_t *argument_type, const Char_t *argument_name="", const Char_t *default_value="")
void InlineAllConstructors(bool yes=true)
KVClassDestructor * GetDestructor() const
void SetBaseClass(const Char_t *b)
void AddGetSetMethods(const KVNameValueList &)
For each named parameter in the list, we add protected member variables with the name and type of the...
KVClassConstructor * AddConstructor(const Char_t *argument_type="", const Char_t *argument_name="", const Char_t *default_value="", const Char_t *access="public")
KVClassMember * AddMember(const Char_t *name, const Char_t *type, const Char_t *comment, const Char_t *access="protected")
void AddAllBaseConstructors()
KVClassMethod * AddMethod(const Char_t *name, const Char_t *return_type, const Char_t *access="public", Bool_t isVirtual=kFALSE, Bool_t isConst=kFALSE)
Extended version of ROOT THashList.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
KVNamedParameter * GetParameter(Int_t idx) const
return the parameter object with index idx
Int_t GetNpar() const
return the number of stored parameters
A generic named parameter storing values of different types.
KVSeqCollection * GetSubListWithName(const Char_t *retvalue) const
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
T * get_object(const TString &name) const
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
Int_t GetSize() const override
virtual TObject * FindObjectByName(const Char_t *name) const
KVSeqCollection * GetSubListWithLabel(const Char_t *retvalue) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
void Begin(TString delim) const
KVString Next(Bool_t strip_whitespace=kFALSE) const
TList * GetListOfMethods(Bool_t load=kTRUE)
virtual void Print(Option_t *option, const char *wildcard, Int_t recurse=1) const
virtual void AddAll(const TCollection *col)
virtual Int_t GetEntries() const
const char * AsString() const
TObject * First() const override
TObject * At(Int_t idx) const override
const char * GetFullTypeName() const
const char * GetDefault() const
virtual TList * GetListOfMethodArgs()
const char * GetName() const override
virtual void SetName(const char *name)
virtual const char * GetName() const
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual void Copy(TObject &object) const
virtual void Info(const char *method, const char *msgfmt,...) const
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
const char * Data() const
std::istream & ReadFile(std::istream &str)
TString & Remove(EStripType s, char c)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
TString & ReplaceAll(const char *s1, const char *s2)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
virtual UserGroup_t * GetUserInfo(const char *user=nullptr)
virtual const char * BaseName(const char *pathname)
RPY_EXPORTED bool IsDestructor(TCppMethod_t method)
void Error(UserClass p, const char *location, const char *va_(fmt),...)
void Warning(UserClass p, const char *location, const char *va_(fmt),...)
Type GetType(const std::string &Name)