Graphite  Version 3
An experimental 3D geometry processing program
OGF::ModuleMaker Class Reference

Generates plugins using skeletons in lib/devel/. More...

#include <OGF/devel/types/module_maker.h>

Public Member Functions

 ModuleMaker ()
 ModuleMaker constructor.
 
bool create_module (const std::string &module_name, const std::string &author_name)
 Creates a new module (a plugin). More...
 
void create_file (const std::string &module_name, const std::string &subdirectory, const std::string &file_name, const std::string &header_skel="devel/file.h.skel", const std::string &source_skel="devel/file.cpp.skel")
 Creates a new C++ source in a module. More...
 
void create_class (const std::string &module_name, const std::string &subdirectory, const std::string &class_name, const std::string &header_skel="devel/class.h.skel", const std::string &source_skel="devel/class.cpp.skel")
 Creates sources for a new C++ class in a module. More...
 
bool create_gom_class (const std::string &module_name, const std::string &subdirectory, const std::string &base_class_name, const std::string &class_name, const std::string &header_skel="devel/gom_class.h.skel", const std::string &source_skel="devel/gom_class.cpp.skel")
 Creates sources for a new C++ GOM class in a module. More...
 
bool create_gom_class (const std::string &module_name, const std::string &subdirectory, const std::string &base_class_name, const std::string &class_name, const std::string &header_skel, const std::string &source_skel, TextUtils::Environment &env)
 Creates sources for a new C++ GOM class in a module. More...
 
void create_commands (const std::string &module_name, const std::string &grob_class_name, const std::string &commands_name)
 Creates source files for a new Commands class. More...
 
void create_shader (const std::string &module_name, const std::string &grob_class_name, const std::string &shader_name, const std::string &base_class_name="")
 Creates source files for a new Shader class. More...
 
void create_tool (const std::string &module_name, const std::string &grob_class_name, const std::string &tool_name, const std::string &base_class_name="")
 Creates source files for a new Tool class. More...
 
void create_grob (const std::string &module_name, const std::string &grob_name, const std::string &file_extension="", const std::string &base_class_name="OGF::Grob")
 Creates source files for a new Grob class. More...
 

Protected Member Functions

bool set_module (const std::string &module_name, bool check=true)
 Sets the name of the current module where files should be generated. More...
 
void set_module_name (TextUtils::Environment &env)
 Sets the substitution rules deduced from the name of the current module. More...
 
bool create_file_from_skel (const std::string &file_name, const std::string &skel_name, const TextUtils::Environment &env, bool insert_header=false)
 Creates a file from an skeleton file and a set of substitution rules. More...
 
bool create_directory (const std::string &dir_name)
 Creates a new directory. More...
 
std::string class_name_to_file_name (const std::string &class_name)
 Converts a class name to a file name. More...
 
std::string file_name_to_include_guard (const std::string &file_name)
 Converts a file name to an include guard. More...
 
bool insert (const std::string &file_name, const std::string &insertion_point, const std::string &line)
 Inserts a new line in a file. More...
 
void add_directory_to_cmake (const std::string &directory)
 Adds a directory to the list of directories where source files should be gathered in the CMake file. More...
 
void touch_root_cmake ()
 Changes the modification time of the root CMakeLists.txt in order to trigger recompilation.
 

Detailed Description

Generates plugins using skeletons in lib/devel/.

Automates the generation of all the tedious to write code for creating new object types, commands, shaders and tools.

Definition at line 55 of file module_maker.h.

Member Function Documentation

◆ add_directory_to_cmake()

void OGF::ModuleMaker::add_directory_to_cmake ( const std::string &  directory)
protected

Adds a directory to the list of directories where source files should be gathered in the CMake file.

Parameters
[in]directorythe directory to be added, relative to the path of the current module

◆ class_name_to_file_name()

std::string OGF::ModuleMaker::class_name_to_file_name ( const std::string &  class_name)
protected

Converts a class name to a file name.

Parameters
[in]class_namethe class name, possibly with the "OGF::" prefix, and in CamelCase
Returns
the file name, all lower case, with one underscore between each word

◆ create_class()

void OGF::ModuleMaker::create_class ( const std::string &  module_name,
const std::string &  subdirectory,
const std::string &  class_name,
const std::string &  header_skel = "devel/class.h.skel",
const std::string &  source_skel = "devel/class.cpp.skel" 
)

Creates sources for a new C++ class in a module.

The generated files are named like the class, with underscore-separated words (instead of camel-case). In the skeleton files, the variables "class_name", "file", "FILE", "package", "Package", "PACKAGE", "PACKAGE_API" and "author" are substituted.

Parameters
[in]module_namename of the module
[in]subdirectorysubdirectory where the file will be created. If the subdirectory does not exist, it will be created as well
[in]class_namename of the class
[in]header_skelname of the skeleton to be used for the header, relative to the lib/ subdirectory of Graphite
[in]source_skelname of the skeleton to be used for the source, relative to the lib/ subdirectory of Graphite

◆ create_commands()

void OGF::ModuleMaker::create_commands ( const std::string &  module_name,
const std::string &  grob_class_name,
const std::string &  commands_name 
)

Creates source files for a new Commands class.

It also inserts the code to register the created Commands class in the initializer of the library.

Parameters
[in]module_namename of the module
[in]grob_class_namename of the Grob class these Commands should be attached to, with the "OGF::" prefix
[in]commands_namename of the commands without any prefix/suffix (e.g., use "Remesh" for "OGF::MeshGrobRemeshCommands").

◆ create_directory()

bool OGF::ModuleMaker::create_directory ( const std::string &  dir_name)
protected

Creates a new directory.

The created directory is added to the list of directories where source files should be gathered in the CMake file.

Parameters
[in]dir_namedirectory to be created, relative to the path of the current module
Return values
trueif the directory could be created or already exists
falseotherwise

◆ create_file()

void OGF::ModuleMaker::create_file ( const std::string &  module_name,
const std::string &  subdirectory,
const std::string &  file_name,
const std::string &  header_skel = "devel/file.h.skel",
const std::string &  source_skel = "devel/file.cpp.skel" 
)

Creates a new C++ source in a module.

In the skeleton files, the variables "file", "FILE", "package", "Package", "PACKAGE", "PACKAGE_API" and "author" are substituted.

Parameters
[in]module_namename of the module
[in]subdirectorysubdirectory where the file will be created. If the subdirectory does not exist, it will be created as well
[in]file_namename of the file, without the extension
[in]header_skelname of the skeleton to be used for the header, relative to the lib/ subdirectory of Graphite
[in]source_skelname of the skeleton to be used for the source, relative to the lib/ subdirectory of Graphite

◆ create_file_from_skel()

bool OGF::ModuleMaker::create_file_from_skel ( const std::string &  file_name,
const std::string &  skel_name,
const TextUtils::Environment env,
bool  insert_header = false 
)
protected

Creates a file from an skeleton file and a set of substitution rules.

Parameters
[in]file_namename of the file to be created, relative to the path of the current module
[in]skel_namename of the skeleton file, relative to lib/devel
[in]enva const reference to a TextUtils::Environment, with the substitution rules
[in]insert_headerif true, the C++ header (with the copyright, author information etc...) is inserted at the beginning of the generated file
Return values
trueif the file could be created and the skeleton file exists
falseotherwise

◆ create_gom_class() [1/2]

bool OGF::ModuleMaker::create_gom_class ( const std::string &  module_name,
const std::string &  subdirectory,
const std::string &  base_class_name,
const std::string &  class_name,
const std::string &  header_skel,
const std::string &  source_skel,
TextUtils::Environment env 
)

Creates sources for a new C++ GOM class in a module.

The generated files are named like the class, with underscore-separated words (instead of camel-case). In the skeleton files, the variables "class_name", "base_class_name", "base_class_header_file", "file", "FILE", "package", "Package", "PACKAGE", "PACKAGE_API", "author" as well as the ones specified in env are substituted.

Parameters
[in]module_namename of the module
[in]subdirectorysubdirectory where the file will be created. If the subdirectory does not exist, it will be created as well
[in]base_class_namename of the base class (inherited by the class)
[in]class_namename of the class
[in]header_skelname of the skeleton to be used for the header, relative to the lib/ subdirectory of Graphite
[in]source_skelname of the skeleton to be used for the source, relative to the lib/ subdirectory of Graphite
[in]enva reference to a TextUtils::Environment used to specified additional substitutions

◆ create_gom_class() [2/2]

bool OGF::ModuleMaker::create_gom_class ( const std::string &  module_name,
const std::string &  subdirectory,
const std::string &  base_class_name,
const std::string &  class_name,
const std::string &  header_skel = "devel/gom_class.h.skel",
const std::string &  source_skel = "devel/gom_class.cpp.skel" 
)

Creates sources for a new C++ GOM class in a module.

The generated files are named like the class, with underscore-separated words (instead of camel-case). In the skeleton files, the variables "class_name", "base_class_name", "base_class_header_file", "file", "FILE", "package", "Package", "PACKAGE", "PACKAGE_API" and "author" are substituted.

Parameters
[in]module_namename of the module
[in]subdirectorysubdirectory where the file will be created. If the subdirectory does not exist, it will be created as well
[in]base_class_namename of the base class (inherited by the class), with the "OGF::" prefix
[in]class_namename of the class
[in]header_skelname of the skeleton to be used for the header, relative to the lib/ subdirectory of Graphite
[in]source_skelname of the skeleton to be used for the source, relative to the lib/ subdirectory of Graphite

◆ create_grob()

void OGF::ModuleMaker::create_grob ( const std::string &  module_name,
const std::string &  grob_name,
const std::string &  file_extension = "",
const std::string &  base_class_name = "OGF::Grob" 
)

Creates source files for a new Grob class.

It also inserts the code to register the created Grob class in the initializer of the library.

Parameters
[in]module_namename of the module
[in]grob_namename of the Grob class without the "OGF::" prefix
[in]file_extensionextension of the files used to save/load objects with this Grob class
[in]base_class_nameoptional name of the base class (inherited by the class), with the "OGF::" prefix

◆ create_module()

bool OGF::ModuleMaker::create_module ( const std::string &  module_name,
const std::string &  author_name 
)

Creates a new module (a plugin).

Generates C++ sources and configuration files for a new module.

Parameters
[in]module_namename of the module
[in]author_namename of the author, to be copied in header files and in generated module information

◆ create_shader()

void OGF::ModuleMaker::create_shader ( const std::string &  module_name,
const std::string &  grob_class_name,
const std::string &  shader_name,
const std::string &  base_class_name = "" 
)

Creates source files for a new Shader class.

It also inserts the code to register the created Commands class in the initializer of the library.

Parameters
[in]module_namename of the module
[in]grob_class_namename of the Grob class these Commands should be attached to, with the "OGF::" prefix
[in]shader_namename of the shader without any prefix/suffix (e.g., use "Param" for "OGF::ParamSurfaceShader").
[in]base_class_namename of the base class (inherited by the class), with the "OGF::" prefix

◆ create_tool()

void OGF::ModuleMaker::create_tool ( const std::string &  module_name,
const std::string &  grob_class_name,
const std::string &  tool_name,
const std::string &  base_class_name = "" 
)

Creates source files for a new Tool class.

It also inserts the code to register the created Tool class in the initializer of the library.

Parameters
[in]module_namename of the module
[in]grob_class_namename of the Grob class this Tool should be attached to, with the "OGF::" prefix
[in]tool_namename of the commands without any prefix/suffix (e.g., use "Edit" for "OGF::MeshGrobEditTool").
[in]base_class_namename of the base class (inherited by the class), with the "OGF::" prefix

◆ file_name_to_include_guard()

std::string OGF::ModuleMaker::file_name_to_include_guard ( const std::string &  file_name)
protected

Converts a file name to an include guard.

Parameters
[in]file_namethe file name
Returns
the include guard, all upper case, with slashes converted into underscores, a "__OGF_" prefix and a "__" suffix

◆ insert()

bool OGF::ModuleMaker::insert ( const std::string &  file_name,
const std::string &  insertion_point,
const std::string &  line 
)
protected

Inserts a new line in a file.

Parameters
[in]file_namethe name of the file, relative to the path of the current module.
[in]insertion_pointa string to be recognized in the file, that indicates where the line should be inserted. It will be inserted before the insertion point.
[in]linethe line to be inserted
Return values
trueif the line could be inserted
falseotherwise

◆ set_module()

bool OGF::ModuleMaker::set_module ( const std::string &  module_name,
bool  check = true 
)
protected

Sets the name of the current module where files should be generated.

Parameters
[in]module_namethe name of the module
[in]checkif true, test whether the module already exists
Return values
trueif the module already exists or if check is false
falseif the module does not exist and check is true

◆ set_module_name()

void OGF::ModuleMaker::set_module_name ( TextUtils::Environment env)
protected

Sets the substitution rules deduced from the name of the current module.

This sets "package", "Package", "PACKAGE", "PACKAGE_API" and "author".

Parameters
[out]envwhere to store the substitution rules
See also
set_module()

The documentation for this class was generated from the following file: