KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVClassFactory Class Reference

Detailed Description

Factory class for generating skeleton files for new classes.

It can generate basic '.h' and '.cpp' files for

  • base classes (base_class="")
  • inherited classes (base_class!="")
  • classes based on template files

There are two ways to use KVClassFactory in order to generate code:

  1. Using the static (stand-alone) method
    KVClassFactory::MakeClass(classname, classdesc, base_class, withTemplate, templateFile);
    static void MakeClass(const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="", Bool_t withTemplate=kFALSE, const Char_t *templateFile="")
  2. Create and configure a KVClassFactory object and then call the GenerateCode() method:
    KVClassFactory fact(classname, classdesc, base_class, withTemplate, templateFile);
    fact.GenerateCode();
    Factory class for generating skeleton files for new classes.
    The second method is more flexible and allows to add methods to classes before code generation, even if the class is created from a predefined template.

For example, let us suppose that we want to add the following public method to our class:

-//-> declaration:
virtual const Char_t* GetName(Option_t* = "") const;
-//-> implementation:
_
_
const Char_t* MyNewClass::GetName(Option_t* opt) const
{
if( strcmp(opt,"") ) cout << "Option : " << opt << endl;
else cout << fName.Data() << endl;
return fName.Data();
}
char Char_t
const char Option_t
#define _(A, B)
virtual const char * GetName() const

This can be done as follows:

KVClassFactory fact("MyNewClass", "My latest creation");
fact.AddMethod("GetName", "const Char_t*", "public", kTRUE, kTRUE);
fact.AddMethodArgument("GetName", "Option_t*", "opt", "\"\"");
fact.AddMethodComment("Doxygen comments to document my new method");
KVString body;
body += " if( strcmp(opt,\"\") ) std::cout << \"Option : \" << opt << std::endl;\n";
body += " else std::cout << fName.Data() << std::endl;\n";
body += " return fName.Data();";
fact.AddMethodBody("GetName", body);
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition KVString.h:73

The addition of a new method may mean that it is necessary to add an '#include' directive to either the header or the implementation file of the new class. For example, in this case, the use of 'cout', 'endl' etc. may require to add an '#include <iostream>' to the '.cpp' file of the new class. This can be done as follows:

fact.AddImplIncludeFile("iostream");
fact.GenerateCode();

For another example of this kind of approach, see the method KVParticleCondition::Optimize.

Examples
KVClassFactory_examples.C.

Definition at line 86 of file KVClassFactory.h.

#include <KVClassFactory.h>

Inheritance diagram for KVClassFactory:

Classes

class  KVClassConstructor
 Constructor for a class generated with KVClassFactory. More...
 
class  KVClassDestructor
 Destructor for a class generated with KVClassFactory. More...
 
class  KVClassMember
 Member variable in a class generated with KVClassFactory. More...
 
class  KVClassMethod
 Method in a class generated with KVClassFactory. More...
 

Public Member Functions

 KVClassFactory ()
 Default ctor.
 
 KVClassFactory (const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="", Bool_t withTemplate=kFALSE, const Char_t *templateFile="")
 
 KVClassFactory (const KVClassFactory &)
 ctor par copie
 
virtual ~KVClassFactory ()
 
void AddAllBaseConstructors ()
 
KVClassConstructorAddConstructor (const Char_t *argument_type="", const Char_t *argument_name="", const Char_t *default_value="", const Char_t *access="public")
 
void AddDefaultConstructor ()
 
void AddDestructor (const TString &access="public")
 Add default destructor to class.
 
void AddGetSetMethods (const KVNameValueList &)
 For each named parameter in the list, we add protected member variables with the name and type of the parameter.
 
void AddHeaderIncludeFile (const Char_t *filename)
 
void AddImplIncludeFile (const Char_t *filename)
 
KVClassMemberAddMember (const Char_t *name, const Char_t *type, const Char_t *comment, const Char_t *access="protected")
 
KVClassMethodAddMethod (const Char_t *name, const Char_t *return_type, const Char_t *access="public", Bool_t isVirtual=kFALSE, Bool_t isConst=kFALSE)
 
void AddMethod (const KVClassMethod &kvcm)
 
void AddMethodArgument (const Char_t *method_name, const Char_t *argument_type, const Char_t *argument_name="", const Char_t *default_value="")
 
void AddMethodBody (const Char_t *method_name, const KVString &body)
 
void AddMethodComment (const Char_t *method_name, const KVString &comment)
 Set the comments for method 'method_name' added to the class using AddMethod.
 
void Copy (TObject &obj) const
 Copy the state of this KVClassFactory to the one referenced by 'obj'.
 
void GenerateCode ()
 Generate header and implementation file for currently-defined class.
 
const Char_tGetBaseClass () const
 
const Char_tGetClassDesc () const
 
const Char_tGetClassName () const
 
KVClassConstructorGetDefaultCtor () const
 
KVClassDestructorGetDestructor () const
 
const Char_tGetHeaderFileName () const
 
const Char_tGetImpFileName () const
 
const KVListGetListOfMembers () const
 
const KVListGetListOfMethods () const
 
KVClassMethodGetMethod (const Char_t *name) const
 
Int_t GetNumberOfMemberVariables () const
 
const Char_tGetOutputPath () const
 
const Char_tGetTemplateBase () const
 
void InlineAllConstructors (bool yes=true)
 
void InlineAllMethods (bool yes=true)
 
Bool_t IsBaseClassTObject () const
 
void Print (Option_t *opt="") const
 Print infos on object.
 
void SetBaseClass (const Char_t *b)
 
void SetClassDesc (const Char_t *d)
 
void SetClassName (const Char_t *n)
 
void SetInheritAllConstructors (Bool_t yes=kTRUE)
 
void SetOutputPath (const KVString &p)
 
void SetTemplate (Bool_t temp, const Char_t *temp_file)
 
Bool_t WithMultipleBaseClasses () const
 
Bool_t WithTemplate () const
 
- Public Member Functions inherited from TObject
 TObject ()
 
 TObject (const TObject &object)
 
virtual ~TObject ()
 
void AbstractMethod (const char *method) const
 
virtual void AppendPad (Option_t *option="")
 
virtual void Browse (TBrowser *b)
 
ULong_t CheckedHash ()
 
virtual const char * ClassName () const
 
virtual void Clear (Option_t *="")
 
virtual TObjectClone (const char *newname="") const
 
virtual Int_t Compare (const TObject *obj) const
 
virtual void Delete (Option_t *option="")
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 
virtual void Draw (Option_t *option="")
 
virtual void DrawClass () const
 
virtual TObjectDrawClone (Option_t *option="") const
 
virtual void Dump () const
 
virtual void Error (const char *method, const char *msgfmt,...) const
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 
virtual TObjectFindObject (const char *name) const
 
virtual TObjectFindObject (const TObject *obj) const
 
virtual Option_tGetDrawOption () const
 
virtual const char * GetIconName () const
 
virtual const char * GetName () const
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 
virtual Option_tGetOption () const
 
virtual const char * GetTitle () const
 
virtual UInt_t GetUniqueID () const
 
virtual Bool_t HandleTimer (TTimer *timer)
 
virtual ULong_t Hash () const
 
Bool_t HasInconsistentHash () const
 
virtual void Info (const char *method, const char *msgfmt,...) const
 
virtual Bool_t InheritsFrom (const char *classname) const
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 
virtual void Inspect () const
 
void InvertBit (UInt_t f)
 
virtual TClassIsA () const
 
Bool_t IsDestructed () const
 
virtual Bool_t IsEqual (const TObject *obj) const
 
virtual Bool_t IsFolder () const
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
virtual Bool_t IsSortable () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
virtual void ls (Option_t *option="") const
 
void MayNotUse (const char *method) const
 
virtual Bool_t Notify ()
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *vp)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, void *vp)
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 
virtual void Paint (Option_t *option="")
 
virtual void Pop ()
 
virtual Int_t Read (const char *name)
 
virtual void RecursiveRemove (TObject *obj)
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 
virtual void SetDrawOption (Option_t *option="")
 
virtual void SetUniqueID (UInt_t uid)
 
virtual void Streamer (TBuffer &)
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 

Static Public Member Functions

static void MakeClass (const Char_t *classname, const Char_t *classdesc, const Char_t *base_class="", Bool_t withTemplate=kFALSE, const Char_t *templateFile="")
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 
static Bool_t GetObjectStat ()
 
static void SetDtorOnly (void *obj)
 
static void SetObjectStat (Bool_t stat)
 

Private Member Functions

void AddAssignmentOperator ()
 
void AddCopyConstructor ()
 
void AddMemberInitialiserConstructor (KVClassConstructor *=nullptr)
 
void AddTObjectCopyMethod ()
 
Bool_t CheckTemplateFiles (const Char_t *base_class, const Char_t *templateFile)
 
Ssiz_t FindNextUncommentedLine (TString &, Ssiz_t beg=0)
 
void GenerateGettersAndSetters ()
 
void SetWhoWhen ()
 
void WriteClassDec (std::ofstream &)
 
void WriteClassHeader ()
 Write the class header file.
 
void WriteClassImp ()
 
void WriteClassWithTemplateHeader ()
 
void WriteClassWithTemplateImp ()
 Writes the implementation file for the class.
 
void WritePreProc (std::ofstream &)
 
void WriteWhoWhen (std::ofstream &)
 

Private Attributes

KVString fAuthor
 user who called ClassFactory to generate class
 
TClassfBaseClass
 description of base class
 
KVString fBaseClassName
 name of base class
 
Bool_t fBaseClassTObject
 kTRUE if class derived from TObject
 
KVString fClassDesc
 class description
 
KVString fClassName
 name of class to generate
 
KVString fClassPath
 directory in which to write source files, if not working directory
 
Bool_t fHasBaseClass
 kTRUE if class derived from another
 
KVList fHeadInc
 list of 'includes' to be added to header file
 
KVList fImpInc
 list of 'includes' to be added to implementation file
 
Bool_t fInheritAllCtors
 kTRUE if all ctor from base class should be inherited
 
Bool_t fInlineAllCtors
 kTRUE if all ctor implementations written in header
 
Bool_t fInlineAllMethods
 kTRUE if all (non-ctor) method implementations written in header
 
KVList fMembers
 list of member variables for class
 
KVList fMethods
 list of methods added to class
 
TDatime fNow
 for dating files
 
KVString fTemplateBase
 template base name passed to SetTemplate method
 
KVString fTemplateClassName
 name of template dummy class
 
KVString fTemplateCPP
 full path to template .cpp
 
KVString fTemplateH
 full path to template .h
 
Bool_t fWithTemplate
 true if class has a template
 

Additional Inherited Members

- Public Types inherited from TObject
enum  EDeprecatedStatusBits
 
enum  EStatusBits
 
- Public Attributes inherited from TObject
 kBitMask
 
 kCanDelete
 
 kCannotPick
 
 kHasUUID
 
 kInconsistent
 
 kInvalidObject
 
 kIsOnHeap
 
 kIsReferenced
 
 kMustCleanup
 
 kNoContextMenu
 
 kNotDeleted
 
 kObjInCanvas
 
 kOverwrite
 
 kSingleKey
 
 kWriteDelete
 
 kZombie
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 
void MakeZombie ()
 
- Protected Attributes inherited from TObject
 kOnlyPrepStep
 

Constructor & Destructor Documentation

◆ KVClassFactory() [1/3]

KVClassFactory::KVClassFactory ( )

Default ctor.

Definition at line 42 of file KVClassFactory.cpp.

◆ KVClassFactory() [2/3]

KVClassFactory::KVClassFactory ( const Char_t classname,
const Char_t classdesc,
const Char_t base_class = "",
Bool_t  withTemplate = kFALSE,
const Char_t templateFile = "" 
)

Create a new class with the following characteristics:

classname = name of new class classdesc = short (one line) description of class base_class = name of base class(es)* (if creating a derived class) withTemplate = kTRUE if template files for the '.h' and '.cpp' are to be used templateFile = base name of template files

*(if the class has several base classes, give a comma-separated list)

Only classname and classdesc have to be given. By default we create a new base class without use of template files.

If withTemplate=kTRUE, the base name for the template files must be given. We check that the template files exist. If they do not, an error message is printed and this object will be made a zombie (test IsZombie() after constructor). The template for the class structure is defined in a '.h' and a '.cpp' file, as follows:

if templateFile="" (default), we expect base_class!="", and template files with names base_classTemplate.h and base_classTemplate.cpp must be present in either $TEMPLATEDIR, $HOME or $PWD directories. the dummy classname "base_classTemplate" will be replaced everywhere by 'classname'

if templateFile="/absolute/path/classTemplate" we use classTemplate.h & classTemplate.cpp in the given directory. the dummy classname "classTemplate" will be replaced everywhere by 'classname'

if templateFile="classTemplate" we look for classTemplate.h & classTemplate.cpp in $TEMPLATEDIR, $HOME or $PWD directories. the dummy classname "classTemplate" will be replaced everywhere by 'classname'

Definition at line 81 of file KVClassFactory.cpp.

◆ KVClassFactory() [3/3]

KVClassFactory::KVClassFactory ( const KVClassFactory obj)

ctor par copie

Definition at line 216 of file KVClassFactory.cpp.

◆ ~KVClassFactory()

virtual KVClassFactory::~KVClassFactory ( )
inlinevirtual

Definition at line 423 of file KVClassFactory.h.

Member Function Documentation

◆ AddAllBaseConstructors()

void KVClassFactory::AddAllBaseConstructors ( )

Add constructors with the same signature as all base class constructors (apart from the default ctor or any copy constructors, which are a special case) If this class has its own member variables, we add them to the argument list of each base class constructor.

Definition at line 1995 of file KVClassFactory.cpp.

◆ AddAssignmentOperator()

void KVClassFactory::AddAssignmentOperator ( )
private

Add "ClassName& operator= (const ClassName&)" method if class has member variables

Definition at line 1572 of file KVClassFactory.cpp.

◆ AddConstructor()

KVClassFactory::KVClassConstructor * KVClassFactory::AddConstructor ( const Char_t argument_type = "",
const Char_t argument_name = "",
const Char_t default_value = "",
const Char_t access = "public" 
)

Add a constructor with or without arguments to the class. If no arguments are given, adds a default constructor (no arguments).

Optional argument 'access' determines access type (public, protected or private) [default: "public"]

If more than one argument is needed, user should keep the returned pointer to the new object and use KVClassMethod::AddArgument() in order to add further arguments.

In order to define the implementation of the ctor method, user should keep the returned pointer to the new object and use KVClassMethod::SetMethodBody(KVString&).

Definition at line 1225 of file KVClassFactory.cpp.

◆ AddCopyConstructor()

void KVClassFactory::AddCopyConstructor ( )
private

Adds copy constructor if class has member variables If class inherits from TObject, this just calls the Copy method

Definition at line 1498 of file KVClassFactory.cpp.

◆ AddDefaultConstructor()

void KVClassFactory::AddDefaultConstructor ( )

Definition at line 719 of file KVClassFactory.cpp.

◆ AddDestructor()

void KVClassFactory::AddDestructor ( const TString access = "public")

Add default destructor to class.

Definition at line 2035 of file KVClassFactory.cpp.

◆ AddGetSetMethods()

void KVClassFactory::AddGetSetMethods ( const KVNameValueList nvl)

For each named parameter in the list, we add protected member variables with the name and type of the parameter.

Definition at line 1386 of file KVClassFactory.cpp.

◆ AddHeaderIncludeFile()

void KVClassFactory::AddHeaderIncludeFile ( const Char_t filename)

Add a file which will appear in the 'includes' list of the '.h' file i.e. we will add a line #include "filename" to the .h file

Definition at line 1330 of file KVClassFactory.cpp.

◆ AddImplIncludeFile()

void KVClassFactory::AddImplIncludeFile ( const Char_t filename)

Add a file which will appear in the 'includes' list of the '.cpp' file i.e. we will add a line #include "filename" to the .cpp file

Definition at line 1348 of file KVClassFactory.cpp.

◆ AddMember()

KVClassFactory::KVClassMember * KVClassFactory::AddMember ( const Char_t name,
const Char_t type,
const Char_t comment,
const Char_t access = "protected" 
)

Add a member variable to the class, with name 'f[name]' according to ROOT convention. The access type is by default "protected", in accordance with OO-encapsulation.

Examples
KVClassFactory_examples.C.

Definition at line 781 of file KVClassFactory.cpp.

◆ AddMemberInitialiserConstructor()

void KVClassFactory::AddMemberInitialiserConstructor ( KVClassConstructor base_ctor = nullptr)
private

For classes with member variables, add a constructor which initialises the values of all member variables If base_ctor is non-null, it is assumed to point to a constructor which has been deduced from the base class' list of constructors; in this case we add our class' members to the beginning of the list of arguments so that if any of the base class ctor arguments have default values, they will be at the end of the list

Definition at line 1525 of file KVClassFactory.cpp.

◆ AddMethod() [1/2]

KVClassFactory::KVClassMethod * KVClassFactory::AddMethod ( const Char_t name,
const Char_t return_type,
const Char_t access = "public",
Bool_t  isVirtual = kFALSE,
Bool_t  isConst = kFALSE 
)

Add a method to the class. User must give return type and name of method. Optional arguments determine access type (public, protected or private) and if the method is 'virtual' and/or 'const'

If another method with the same name already exists, user should keep the returned pointer to the new KVClassMethod object and use KVClassMethod::AddArgument(), KVClassMethod::SetMethodBody() in order to define arguments, method body, etc. instead of using the AddMethodArgument, AddMethodBody methods

Definition at line 1186 of file KVClassFactory.cpp.

◆ AddMethod() [2/2]

void KVClassFactory::AddMethod ( const KVClassMethod kvcm)

A new KVClassMethod object will be created and added to the class, copying the informations held in kvcm

Definition at line 1163 of file KVClassFactory.cpp.

◆ AddMethodArgument()

void KVClassFactory::AddMethodArgument ( const Char_t method_name,
const Char_t argument_type,
const Char_t argument_name = "",
const Char_t default_value = "" 
)

Add an argument to the method 'method_name' added to the class using AddMethod. User must give type of argument. Optional argument argument_name gives name of argument (will be used in implementation declaration). Optional argument default_value gives default value.

Definition at line 1265 of file KVClassFactory.cpp.

◆ AddMethodBody()

void KVClassFactory::AddMethodBody ( const Char_t method_name,
const KVString body 
)

Set the body of the code for method 'method_name' added to the class using AddMethod. N.B. does not work for implementing constructors, see AddConstructor

Definition at line 1289 of file KVClassFactory.cpp.

◆ AddMethodComment()

void KVClassFactory::AddMethodComment ( const Char_t method_name,
const KVString comment 
)

Set the comments for method 'method_name' added to the class using AddMethod.

Definition at line 1308 of file KVClassFactory.cpp.

◆ AddTObjectCopyMethod()

void KVClassFactory::AddTObjectCopyMethod ( )
private

Adds skeleton standard ROOT Copy method if class has member variables

Definition at line 1450 of file KVClassFactory.cpp.

◆ CheckTemplateFiles()

Bool_t KVClassFactory::CheckTemplateFiles ( const Char_t base_class,
const Char_t templateFile 
)
private

Check that we have the necessary template files to generate the new class.

if templateFile="" (default), we expect base_class!="", and template files with names base_classTemplate.h and base_classTemplate.cpp must be present in either $TEMPLATEDIR, $HOME or $PWD directories. the dummy classname "base_classTemplate" will be replaced everywhere by the new class name

if templateFile="/absolute/path/classTemplate" we use classTemplate.h & classTemplate.cpp in the given directory. the dummy classname "classTemplate" will be replaced everywhere by the new class name

if templateFile="classTemplate" we look for classTemplate.h & classTemplate.cpp in $TEMPLATEDIR, $HOME or $PWD directories. the dummy classname "classTemplate" will be replaced everywhere by the new class name

if all goes well, this method returns kTRUE and fTemplateClassName contains the dummy class name which should be replaced in the template files with the name of the new class, while fTemplateH and fTemplateCPP contain the full paths to the template files.

Definition at line 1109 of file KVClassFactory.cpp.

◆ Copy()

void KVClassFactory::Copy ( TObject obj) const
virtual

Copy the state of this KVClassFactory to the one referenced by 'obj'.

Reimplemented from TObject.

Definition at line 189 of file KVClassFactory.cpp.

◆ FindNextUncommentedLine()

Ssiz_t KVClassFactory::FindNextUncommentedLine ( TString file,
Ssiz_t  beg = 0 
)
private

Return position of beginning of next uncommented line in file starting from position beg (default = 0). An uncommented line is a line outside of a " ... " block containing non-whitespace material before any '' or '//'. If no uncommented line is found we return -1.

Definition at line 870 of file KVClassFactory.cpp.

◆ GenerateCode()

void KVClassFactory::GenerateCode ( )

Generate header and implementation file for currently-defined class.

Examples
KVClassFactory_examples.C.

Definition at line 732 of file KVClassFactory.cpp.

◆ GenerateGettersAndSetters()

void KVClassFactory::GenerateGettersAndSetters ( )
private

for each member variable we generate inlined Get/Set methods for boolean members we generate Is/SetIs methods

Definition at line 797 of file KVClassFactory.cpp.

◆ GetBaseClass()

const Char_t * KVClassFactory::GetBaseClass ( ) const
inline

Definition at line 515 of file KVClassFactory.h.

◆ GetClassDesc()

const Char_t * KVClassFactory::GetClassDesc ( ) const
inline

Definition at line 501 of file KVClassFactory.h.

◆ GetClassName()

const Char_t * KVClassFactory::GetClassName ( ) const
inline
Examples
KVClassFactory_examples.C.

Definition at line 475 of file KVClassFactory.h.

◆ GetDefaultCtor()

KVClassConstructor * KVClassFactory::GetDefaultCtor ( ) const
inline

Definition at line 466 of file KVClassFactory.h.

◆ GetDestructor()

KVClassDestructor * KVClassFactory::GetDestructor ( ) const
inline
Examples
KVClassFactory_examples.C.

Definition at line 470 of file KVClassFactory.h.

◆ GetHeaderFileName()

const Char_t * KVClassFactory::GetHeaderFileName ( ) const
inline

Return name of header source file If path has been set with SetOutputPath() this is the full path to the file

Definition at line 483 of file KVClassFactory.h.

◆ GetImpFileName()

const Char_t * KVClassFactory::GetImpFileName ( ) const
inline

Return name of implemntation source file If path has been set with SetOutputPath() this is the full path to the file

Examples
KVClassFactory_examples.C.

Definition at line 490 of file KVClassFactory.h.

◆ GetListOfMembers()

const KVList * KVClassFactory::GetListOfMembers ( ) const
inline

Definition at line 458 of file KVClassFactory.h.

◆ GetListOfMethods()

const KVList * KVClassFactory::GetListOfMethods ( ) const
inline

Definition at line 454 of file KVClassFactory.h.

◆ GetMethod()

KVClassMethod * KVClassFactory::GetMethod ( const Char_t name) const
inline

Definition at line 462 of file KVClassFactory.h.

◆ GetNumberOfMemberVariables()

Int_t KVClassFactory::GetNumberOfMemberVariables ( ) const
inline

Definition at line 536 of file KVClassFactory.h.

◆ GetOutputPath()

const Char_t * KVClassFactory::GetOutputPath ( ) const
inline

Return output directory for generated source files Default [=""] is current working directory

Definition at line 555 of file KVClassFactory.h.

◆ GetTemplateBase()

const Char_t * KVClassFactory::GetTemplateBase ( ) const
inline

Definition at line 532 of file KVClassFactory.h.

◆ InlineAllConstructors()

void KVClassFactory::InlineAllConstructors ( bool  yes = true)
Parameters
yes=true: Write implementation of all constructors & the destructor in the header file of the class.
Examples
KVClassFactory_examples.C.

Definition at line 1432 of file KVClassFactory.cpp.

◆ InlineAllMethods()

void KVClassFactory::InlineAllMethods ( bool  yes = true)
Parameters
yes=true: Write implementation of all non-ctor/non-dtor methods in the header file of the class

Definition at line 1415 of file KVClassFactory.cpp.

◆ IsBaseClassTObject()

Bool_t KVClassFactory::IsBaseClassTObject ( ) const
inline

Definition at line 527 of file KVClassFactory.h.

◆ MakeClass()

void KVClassFactory::MakeClass ( const Char_t classname,
const Char_t classdesc,
const Char_t base_class = "",
Bool_t  withTemplate = kFALSE,
const Char_t templateFile = "" 
)
static

Static method for generating skeleton header and implementation files for a new class.

Give a name for the class and a short description, used for HTML doc.

The optional string 'base_class' gives the name(s) of the parent class(es)*, in case of inheritance; if not given, the new class will be a base class. *(in case of several base classes, give a comma-separated list)

if withTemplate=kTRUE, we use a template for the class structure, defined in a '.h' and a '.cpp' file, as follows:

  • if templateFile="" (default), we expect base_class!="", and template files with names base_classTemplate.h and base_classTemplate.cpp must be present in either $KVROOT/KVFiles, $HOME or $PWD directories. the dummy classname "base_classTemplate" will be replaced everywhere by 'classname'
  • if templateFile="/absolute/path/classTemplate" we use classTemplate.h & classTemplate.cpp in the given directory. the dummy classname "classTemplate" will be replaced everywhere by 'classname'
  • if templateFile="classTemplate" we look for classTemplate.h & classTemplate.cpp in $KVROOT/KVFiles, $HOME or $PWD directories. the dummy classname "classTemplate" will be replaced everywhere by 'classname'

Example of use:

KVClassFactory::MakeClass("MyClass", "A brand new class", "TObject")

will generate the following MyClass.h and MyClass.cpp files:

MyClass.h ======================================>>>>
//Created by KVClassFactory on Fri Mar 24 23:52:54 2006 (<-------creation date)
//Author: John Frankland (<----- full name of user who calls MakeClass method)
#ifndef __MYCLASS_H
#define __MYCLASS_H
#include <TObject.h> (<----- header file for parent class, if necessary)
class MyClass : public TObject
{
public:
MyClass();
virtual ~MyClass();
ClassDef(MyClass,1)//A brand new class (<------- class description)
};
#endif
<<<<<<===========================================
#define ClassDef(name, id)
MyClass.cpp=================================>>>>>>>
//Created by KVClassFactory on Fri Mar 24 23:52:54 2006
//Author: John Frankland (<----- full name of user who calls MakeClass method)
#include "MyClass.h"
ClassImp(MyClass)
// A brand new class (<------- class description)
MyClass::MyClass()
{
//Default constructor
}
MyClass::~MyClass()
{
//Destructor
}
ClassImp(TPyArg)

Definition at line 631 of file KVClassFactory.cpp.

◆ Print()

void KVClassFactory::Print ( Option_t opt = "") const
virtual

Print infos on object.

Reimplemented from TObject.

Definition at line 1365 of file KVClassFactory.cpp.

◆ SetBaseClass()

void KVClassFactory::SetBaseClass ( const Char_t b)
inline

Definition at line 505 of file KVClassFactory.h.

◆ SetClassDesc()

void KVClassFactory::SetClassDesc ( const Char_t d)
inline

Definition at line 497 of file KVClassFactory.h.

◆ SetClassName()

void KVClassFactory::SetClassName ( const Char_t n)
inline

Definition at line 479 of file KVClassFactory.h.

◆ SetInheritAllConstructors()

void KVClassFactory::SetInheritAllConstructors ( Bool_t  yes = kTRUE)
inline

Call with kFALSE to prevent class inheriting all constructors from base class

Definition at line 562 of file KVClassFactory.h.

◆ SetOutputPath()

void KVClassFactory::SetOutputPath ( const KVString p)
inline

Set output directory for generated source files Default is current working directory

Definition at line 548 of file KVClassFactory.h.

◆ SetTemplate()

void KVClassFactory::SetTemplate ( Bool_t  temp,
const Char_t templateFile 
)

If the class uses template files (temp=kTRUE), 'templateFile' is the base name used to find these files. The template for the class structure is defined in a '.h' and a '.cpp' file, as follows:

if templateFile="" (default), we expect a base class to have been given, and template files with names base_classTemplate.h and base_classTemplate.cpp must be present in either $TEMPLATEDIR, $HOME or $PWD directories. the dummy classname "base_classTemplate" will be replaced everywhere by 'classname'

if templateFile="/absolute/path/classTemplate" we use classTemplate.h & classTemplate.cpp in the given directory. the dummy classname "classTemplate" will be replaced everywhere by 'classname'

if templateFile="classTemplate" we look for classTemplate.h & classTemplate.cpp in $TEMPLATEDIR, $HOME or $PWD directories. the dummy classname "classTemplate" will be replaced everywhere by 'classname'

Definition at line 151 of file KVClassFactory.cpp.

◆ SetWhoWhen()

void KVClassFactory::SetWhoWhen ( )
private

Set date, time and user name based on current environment If available, we use the full name of the current user, otherwise we use the login name.

Definition at line 838 of file KVClassFactory.cpp.

◆ WithMultipleBaseClasses()

Bool_t KVClassFactory::WithMultipleBaseClasses ( ) const
inline

Definition at line 519 of file KVClassFactory.h.

◆ WithTemplate()

Bool_t KVClassFactory::WithTemplate ( ) const
inline

Definition at line 523 of file KVClassFactory.h.

◆ WriteClassDec()

void KVClassFactory::WriteClassDec ( std::ofstream &  )
private

Write the class declaration in the header file This will include a default constructor & destructor and any methods added using AddMethod, sorted according to their access type.

Definition at line 294 of file KVClassFactory.cpp.

◆ WriteClassHeader()

void KVClassFactory::WriteClassHeader ( )
private

Write the class header file.

Definition at line 535 of file KVClassFactory.cpp.

◆ WriteClassImp()

void KVClassFactory::WriteClassImp ( )
private

Write the class implementation file This includes a class description in pure HTML

Definition at line 469 of file KVClassFactory.cpp.

◆ WriteClassWithTemplateHeader()

void KVClassFactory::WriteClassWithTemplateHeader ( )
private

Writes the header file for a class using a template file. The ClassDef line in the template file will be replaced with one corresponding to the new class.

Definition at line 944 of file KVClassFactory.cpp.

◆ WriteClassWithTemplateImp()

void KVClassFactory::WriteClassWithTemplateImp ( )
private

Writes the implementation file for the class.

Definition at line 1037 of file KVClassFactory.cpp.

◆ WritePreProc()

void KVClassFactory::WritePreProc ( std::ofstream &  )
private

Write pre-processor directives in file i.e. '#ifndef __TOTO_H' etc. If this class has inheritance, we add '#include "base_class.h"' for each of the base classes. and any other include files added using AddHeaderIncludeFile

Definition at line 253 of file KVClassFactory.cpp.

◆ WriteWhoWhen()

void KVClassFactory::WriteWhoWhen ( std::ofstream &  )
private

Write a stub doxygen comment block to be used to document the file This will include class name, brief description, author name and date

Definition at line 234 of file KVClassFactory.cpp.

Member Data Documentation

◆ fAuthor

KVString KVClassFactory::fAuthor
private

user who called ClassFactory to generate class

Definition at line 96 of file KVClassFactory.h.

◆ fBaseClass

TClass* KVClassFactory::fBaseClass
private

description of base class

Definition at line 93 of file KVClassFactory.h.

◆ fBaseClassName

KVString KVClassFactory::fBaseClassName
private

name of base class

Definition at line 92 of file KVClassFactory.h.

◆ fBaseClassTObject

Bool_t KVClassFactory::fBaseClassTObject
private

kTRUE if class derived from TObject

Definition at line 95 of file KVClassFactory.h.

◆ fClassDesc

KVString KVClassFactory::fClassDesc
private

class description

Definition at line 91 of file KVClassFactory.h.

◆ fClassName

KVString KVClassFactory::fClassName
private

name of class to generate

Definition at line 90 of file KVClassFactory.h.

◆ fClassPath

KVString KVClassFactory::fClassPath
private

directory in which to write source files, if not working directory

Definition at line 109 of file KVClassFactory.h.

◆ fHasBaseClass

Bool_t KVClassFactory::fHasBaseClass
private

kTRUE if class derived from another

Definition at line 94 of file KVClassFactory.h.

◆ fHeadInc

KVList KVClassFactory::fHeadInc
private

list of 'includes' to be added to header file

Definition at line 105 of file KVClassFactory.h.

◆ fImpInc

KVList KVClassFactory::fImpInc
private

list of 'includes' to be added to implementation file

Definition at line 106 of file KVClassFactory.h.

◆ fInheritAllCtors

Bool_t KVClassFactory::fInheritAllCtors
private

kTRUE if all ctor from base class should be inherited

Definition at line 110 of file KVClassFactory.h.

◆ fInlineAllCtors

Bool_t KVClassFactory::fInlineAllCtors
private

kTRUE if all ctor implementations written in header

Definition at line 108 of file KVClassFactory.h.

◆ fInlineAllMethods

Bool_t KVClassFactory::fInlineAllMethods
private

kTRUE if all (non-ctor) method implementations written in header

Definition at line 107 of file KVClassFactory.h.

◆ fMembers

KVList KVClassFactory::fMembers
private

list of member variables for class

Definition at line 103 of file KVClassFactory.h.

◆ fMethods

KVList KVClassFactory::fMethods
private

list of methods added to class

Definition at line 104 of file KVClassFactory.h.

◆ fNow

TDatime KVClassFactory::fNow
private

for dating files

Definition at line 97 of file KVClassFactory.h.

◆ fTemplateBase

KVString KVClassFactory::fTemplateBase
private

template base name passed to SetTemplate method

Definition at line 99 of file KVClassFactory.h.

◆ fTemplateClassName

KVString KVClassFactory::fTemplateClassName
private

name of template dummy class

Definition at line 100 of file KVClassFactory.h.

◆ fTemplateCPP

KVString KVClassFactory::fTemplateCPP
private

full path to template .cpp

Definition at line 102 of file KVClassFactory.h.

◆ fTemplateH

KVString KVClassFactory::fTemplateH
private

full path to template .h

Definition at line 101 of file KVClassFactory.h.

◆ fWithTemplate

Bool_t KVClassFactory::fWithTemplate
private

true if class has a template

Definition at line 98 of file KVClassFactory.h.