Example of class source code generation using KVClassFactory
KVClassFactory can be used to generate skeleton class source files
To execute this function, do
$ kaliveda
kaliveda[0] .L KVClassFactory_examples.C+
kaliveda[1] make_examples()
#include "KVClassFactory.h"
#include "KVNameValueList.h"
void make_examples()
{
KVClassFactory ex1(
"BaseClass",
"Example 1: a simple base class with no member variables");
KVClassFactory ex2(
"BaseClassWithMember",
"Example 2: a simple base class with 1 member variable");
ex2.
AddMember(
"MemberVar",
"Double_t",
"a member variable");
KVClassFactory ex3(
"TNamedClass",
"Example 3: a TNamed-derived class with no member variables",
"TNamed");
KVClassFactory ex4(
"TNamedClassWithMember",
"Example 4: a TNamed-derived class with 1 member variable",
"TNamed");
ex4.
AddMember(
"MemberVar",
"Double_t",
"a member variable");
TIter next_class(&examples);
while ((cl = next_class())) {
}
KVClassFactory ex5(
"DerivedClassWithMember",
"Example 5: a -derived class with 1 member variable",
"BaseClassWithMember");
ex5.
AddMember(
"Toto",
"BaseClassWithMember*",
"pointer");
KVClassFactory ex6(
"TColorDerived",
"Example 6: a TColor-derived class with extra member variables",
"TColor");
ex6.
AddMember(
"B",
"double",
"another number");
nvl.
WriteClass(
"NVLclass",
"Class generated from a KVNameValueList");
examples.
Add(
new TNamed(
"NVLclass.cpp",
"NVLclass"));
TIter next_class2(&examples);
while ((cl = next_class2())) {
}
}
R__EXTERN TSystem * gSystem
void SetInline(Bool_t yes=kTRUE)
Factory class for generating skeleton files for new classes.
const Char_t * GetClassName() const
void GenerateCode()
Generate header and implementation file for currently-defined class.
const Char_t * GetImpFileName() const
void InlineAllConstructors(bool yes=true)
KVClassDestructor * GetDestructor() const
KVClassMember * AddMember(const Char_t *name, const Char_t *type, const Char_t *comment, const Char_t *access="protected")
Extended TList class which owns its objects by default.
Handles lists of named parameters with different types, a list of KVNamedParameter objects.
void SetValue(const Char_t *name, value_type value)
void WriteClass(const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="")
virtual void Clear(Option_t *option="")
virtual void Add(TObject *obj)
virtual int CompileMacro(const char *filename, Option_t *opt="", const char *library_name="", const char *build_dir="", UInt_t dirmode=0)