Since a clearer pattern of class formatting has started to emerge (see style guide), it's now started to become burdensome and tedious to type out all of the class member variables and functions, getters, setters, etc. At this point, a generator is warranted.
There is also president to shorthand the definition of the generated classes. With this, a separate definition file (of some yet-to-be-known-format) would become the quintessence for a generated class's source code. This will allow for more robust value validations when saving class data, and standardized behavior (exceptions on errors? return false? return 0? etc).
To make this a reality, the actual generator will need to be broken down into several components.
Definition of a Class Property
To start with, a definition of a single class property (private, static, has_getter, etc.) will need to be defined. The ClassAttributeProperties class is used to maintain all configuration data for a single class property.
Dependencies of a Symbol
When using some symbols - std::string, std::vector, etc - these require the appropriate inclusion of their respective header files. That is, if a shorthand class definition were to include the std::string type, then the generator would need to know to #include <string>.
The class SymbolDependencies is used to maintain a list of known dependencies.
To abstract the concept further, other symbols (like al_get_bitmap()) also require linking a library at compile time. The class SymbolDependencies has been abstracted to include a needed linked library flag, along with the include directory of the library. Hopefully this abstraction will enable the generation of a g++ compile command (along with generating the class source code), by knowing which appropriate dependencies and header paths are needed.
C++ Class Generator
And finally, the class that is responsible for generating the C++ source, header, ~and test~ files is included as CppClassGenerator.
Class Generators
Since a clearer pattern of class formatting has started to emerge (see style guide), it's now started to become burdensome and tedious to type out all of the class member variables and functions, getters, setters, etc. At this point, a generator is warranted.
There is also president to shorthand the definition of the generated classes. With this, a separate definition file (of some yet-to-be-known-format) would become the quintessence for a generated class's source code. This will allow for more robust value validations when saving class data, and standardized behavior (exceptions on errors? return false? return 0? etc).
To make this a reality, the actual generator will need to be broken down into several components.
Definition of a Class Property
To start with, a definition of a single class property (private, static, has_getter, etc.) will need to be defined. The
ClassAttributeProperties
class is used to maintain all configuration data for a single class property.Dependencies of a Symbol
When using some symbols -
std::string
,std::vector
, etc - these require the appropriate inclusion of their respective header files. That is, if a shorthand class definition were to include thestd::string
type, then the generator would need to know to#include <string>
.The class
SymbolDependencies
is used to maintain a list of known dependencies.To abstract the concept further, other symbols (like
al_get_bitmap()
) also require linking a library at compile time. The classSymbolDependencies
has been abstracted to include a needed linked library flag, along with the include directory of the library. Hopefully this abstraction will enable the generation of ag++
compile command (along with generating the class source code), by knowing which appropriate dependencies and header paths are needed.C++ Class Generator
And finally, the class that is responsible for generating the C++ source, header, ~and test~ files is included as
CppClassGenerator
.