Base class for code generators. More...
#include <generator.h>
Public Types | |
enum | ExistingPolicy { OVERWRITE, KEEP, BLEND } |
how to deal with existing files | |
typedef Generator *(* | generatorFactory )(Project *p, const QString &s_name) |
function capable of creating a generator | |
Public Member Functions | |
Generator (Project *p, const QString &s_name) | |
constructor | |
virtual | ~Generator (void) |
destructor; | |
Project * | parent (void) const |
parent project | |
const QString & | name (void) const |
the name of this generator | |
QString | outputPath (void) const |
where we should generate content | |
ExistingPolicy | overwriteMode (void) const |
how to deal with existing files | |
void | setOverwriteMode (ExistingPolicy new_p) |
set how to deal with existing files | |
To be implemented | |
Inheritants must implement these methods | |
virtual bool | addTemplate (const QString &s_path)=0 |
add a template (TEMPL command uses this) More... | |
virtual bool | generate (void)=0 |
generate content | |
Static Public Member Functions | |
Factory | |
Management of the factory methods and names used with them. | |
static void | addGeneratorFactory (const QString &s_gen_name, generatorFactory factory) |
add a generator | |
static void | remGeneratorFactory (const QString &s_gen_name) |
remove a generator | |
static generatorFactory | factory (const QString &s_name) |
get generator factory for given name of NULL | |
Base class for code generators.
Generators are created using GEN command that takes one argument: the name. That name is looked up in the list of known generators with factory() and, if found, an instance is created by associated callback. Plug-ins may register names and callback factories using addGeneratorFactory() and an entry may be removed with remGeneratorFactory().
This base class retains both the name() and the parent() project for later reference.
|
pure virtual |
add a template (TEMPL command uses this)
Informs the generator that a template was added to it. Each generator may support zero, one or more templates and is free to throw an error in response to this call.
The Generator should expect the caller to add the path to GEN::TEMPLATES variable and should not add it itself. Also, the caller should check that this is an actual directory.
s_path | the path to the template |
Implemented in scaffold::GenBasic.