Plugins
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"
45 #include "registry/class_helper.h"
47 
48 namespace ug
49 {
50 namespace DocuGen
51 {
52 
53 using namespace std;
54 
57 
65 {
66  public:
72  CppGenerator( const string dir, ClassHierarchyProvider &chp, bool silent=false );
77  ~CppGenerator();
78 
82  void generate_cpp_files();
83 
84  private:
86 
95  void generate_class_group();
101  void generate_global_functions();
103 
105 
108  void generate_class_docu();
114  void generate_class_cpp();
116 
118 
124  void generate_class_constructors();
128  void generate_class_public_methods();
133  void generate_class_public_members();
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 );
181  void write_group_definitions();
183 
185 
199  template< class TFunction >
200  string generate_parameter_list( const TFunction &func );
216  string generate_return_value( const bridge::ExportedFunctionBase &method );
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:
287  string m_output_dir;
288 
293 
304 
308  map<string, string> m_written_classes;
309 
311  fstream m_curr_file;
312 
313  bool m_silent;
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
map< string, string > m_written_classes
Map for keeping track of already processed classes.
Definition: cpp_generator.h:308
ClassHierarchyProvider & mr_chp
Reference to a helper for retrieving the class group of a class.
Definition: cpp_generator.h:292
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
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
bool m_silent
Definition: cpp_generator.h:313
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
bridge::ClassGroupDesc * m_curr_group
Pointer to the currently processed group (if applicable)
Definition: cpp_generator.h:297
fstream m_curr_file
Current file stream to write to.
Definition: cpp_generator.h:311