Loading [MathJax]/extensions/tex2jax.js
Plugins
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cpp_generator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2016: G-CSC, Goethe University Frankfurt
3 * Author: Torbjörn Klatt
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __UG__REGDOCU__CPP_GENERATOR_H
34#define __UG__REGDOCU__CPP_GENERATOR_H
35
36#include <vector> // std::vector
37#include <map> // std::map
38#include <set> // std::set
39#include <string> // std::string
40
41#ifdef UG_BRIDGE
42# include "bridge/bridge.h"
43#endif
44#include "registry/registry.h"
47
48namespace ug
49{
50namespace DocuGen
51{
52
53using namespace std;
54
57
65{
66 public:
72 CppGenerator( const string dir, ClassHierarchyProvider &chp, bool silent=false );
78
82 void generate_cpp_files();
83
84 private:
86
103
105
108 void generate_class_docu();
114 void generate_class_cpp();
116
118
135
137
147 template< class TEntity >
148 void write_brief_detail_docu( const TEntity &entity );
160 template< class TFunction >
161 void write_parameter_docu( const TFunction &function );
175 template< class TFunction >
176 void write_generic_function( const TFunction &function, bool constant=false );
183
185
199 template< class TFunction >
200 string generate_parameter_list( const TFunction &func );
218
220
228 inline string name_to_id( const string& str );
237 string parameter_to_string( const bridge::ParameterInfo &par, const int i ) const;
248 inline string sanitize_parameter_name( const string &param ) const;
258 inline string sanitize_docstring( const string &docstring, bool is_brief=false );
267 inline string sanitize_docu( const string &param_docu ) const;
274 vector<string> split_group_hieararchy( const string group );
283 string write_group_namespaces( vector<string> group_hierarchy, bool is_global_func=false );
285
286 private:
288
293
304
308 map<string, string> m_written_classes;
309
311 fstream m_curr_file;
312
314};
315
316// end group apps_ugdocu
318
319} // end namespace DocuGen
320} // end namespace ug
321
322#endif // __UG__REGDOCU__CPP_GENERATOR_H
Definition class_hierarchy_provider.h:51
Generator to produce valid but dummy C++ files from registered classes and functions.
Definition cpp_generator.h:65
void generate_class_public_members()
Generates documentation and C++ signature for all public members of current class.
Definition cpp_generator.cpp:328
void generate_cpp_files()
Generates C++ files for all registered classes and functions.
Definition cpp_generator.cpp:93
map< string, string > m_written_classes
Map for keeping track of already processed classes.
Definition cpp_generator.h:308
string write_group_namespaces(vector< string > group_hierarchy, bool is_global_func=false)
Converts group hierarchy into namespaces and writes them to file.
Definition cpp_generator.cpp:543
ClassHierarchyProvider & mr_chp
Reference to a helper for retrieving the class group of a class.
Definition cpp_generator.h:292
void generate_class_docu()
Writes documentation for current class to current file.
Definition cpp_generator.cpp:239
string sanitize_docstring(const string &docstring, bool is_brief=false)
Detects empty tooltips and help and fills it with dummy content.
Definition cpp_generator.cpp:502
string sanitize_parameter_name(const string &param) const
Tunes parameter names to be valid C++ variable names.
Definition cpp_generator.cpp:494
string sanitize_docu(const string &param_docu) const
Tunes parameter name to be rendered in docu.
Definition cpp_generator.cpp:514
bool m_is_global
Whether the currently processed function is global.
Definition cpp_generator.h:303
string m_curr_group_name
Name of current group as in ug4 itself (including namespaces)
Definition cpp_generator.h:299
string generate_parameter_list(const TFunction &func)
Generates parameter list for the given function.
Definition cpp_generator.cpp:389
bridge::IExportedClass * m_curr_class
Pointer to the currently processed class (if applicable)
Definition cpp_generator.h:295
string m_output_dir
Definition cpp_generator.h:287
void write_parameter_docu(const TFunction &function)
Writes documentation for input parameters of given function.
Definition cpp_generator.cpp:345
vector< string > split_group_hieararchy(const string group)
Tokenizes given group name into its separate parts.
Definition cpp_generator.cpp:520
bool m_silent
Definition cpp_generator.h:313
void generate_class_cpp()
Writes C++ code for current class to current file.
Definition cpp_generator.cpp:259
void generate_class_group()
Generates C++ files for all classes in class groups.
Definition cpp_generator.cpp:147
bridge::Registry & mr_reg
Reference to the registry (to save countless calls to ug::bridge::GetUGRegistry())
Definition cpp_generator.h:290
bool m_is_plugin
Whether the currently processed class or function is registered by a plugin.
Definition cpp_generator.h:301
void generate_class_constructors()
Writes documentation and declarations of constructors of current class.
Definition cpp_generator.cpp:280
void generate_class_public_methods()
Generates documentation and declarations for all methods of current class.
Definition cpp_generator.cpp:307
void write_brief_detail_docu(const TEntity &entity)
Writes brief and detailed documentation for an entity.
Definition cpp_generator.cpp:335
bridge::ClassGroupDesc * m_curr_group
Pointer to the currently processed group (if applicable)
Definition cpp_generator.h:297
string name_to_id(const string &str)
Converts a group or class name to a portable ID.
Definition cpp_generator.cpp:433
void write_generic_function(const TFunction &function, bool constant=false)
Writes documentation and declaration of given function.
Definition cpp_generator.cpp:354
string generate_return_value(const bridge::ExportedFunctionBase &method)
Writes docu on return value and returns return value as string.
Definition cpp_generator.cpp:409
void write_group_definitions()
Writes some general docu on parent namespace.
Definition cpp_generator.cpp:222
string parameter_to_string(const bridge::ParameterInfo &par, const int i) const
Converts a value type to a string representation.
Definition cpp_generator.cpp:442
void generate_global_functions()
Generates C++ code for all global functions.
Definition cpp_generator.cpp:192
~CppGenerator()
Destructor.
Definition cpp_generator.cpp:88
fstream m_curr_file
Current file stream to write to.
Definition cpp_generator.h:311