Line data Source code
1 : /*
2 : * Copyright (c) 2010-2013: G-CSC, Goethe University Frankfurt
3 : * Author: Martin Rupp
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 : /**
34 : * \file class_helper.h
35 : *
36 : * \author Martin Rupp
37 : *
38 : * \date 20.10.2010
39 : *
40 : * ClassHierarchy implementation, GetClassHierarchy, FindClass
41 : *
42 : * Goethe-Center for Scientific Computing 2009-2010.
43 : */
44 :
45 : #ifndef __H__UG_BRIDGE__CLASS_HELPER__
46 : #define __H__UG_BRIDGE__CLASS_HELPER__
47 :
48 : #include <string>
49 : #include "common/ug_config.h"
50 :
51 : #include "registry.h"
52 : #include "class.h"
53 : #include "global_function.h"
54 :
55 : namespace ug
56 : {
57 : namespace bridge
58 : {
59 :
60 : /// \addtogroup registry
61 : /// \{
62 :
63 : // ClassHierarchy
64 : //--------------
65 : /**
66 : * \brief Class Hierarchy Helper Class for UG Registry
67 : * This class stores class names and their subclasses
68 : * \sa GetClassHierarchy
69 : */
70 0 : class UG_API ClassHierarchy
71 : {
72 : public:
73 0 : ClassHierarchy() : name(), bGroup(false), subclasses() {}
74 :
75 : /**
76 : * adds the class c to the class hierarchy by attaching it to its base
77 : * hierarchy (base hierarchy taken from c->class_names()). automatically
78 : * creates nonexisting base hierarchy.
79 : * \param c Class to be inserted
80 : */
81 : void insert_class(const IExportedClass &c);
82 :
83 : /**
84 : * searches the hierarchy for the classname name.
85 : * \param name class name to be searched
86 : * \return NULL if class name not found,
87 : * otherwise ClassHierarchy with the class as base
88 : * (find_class(name)->name() == name)
89 : */
90 : ClassHierarchy *find_class(const char *name);
91 :
92 : bool operator < (const ClassHierarchy &other) const
93 : {
94 0 : return name < other.name;
95 : }
96 :
97 : void sort();
98 :
99 : std::string name;
100 : bool bGroup;
101 : std::vector<ClassHierarchy> subclasses;
102 : };
103 : /**
104 : * inits hierarchy with all classes of UGBridge
105 : */
106 : UG_API void GetClassHierarchy(ClassHierarchy &hierarchy, const Registry ®);
107 :
108 : /**
109 : * Finds the class classname in the default ug registry and returns
110 : * IExportedClass pointer if found, otherwise NULL
111 : */
112 : UG_API std::string FunctionInfo(const Registry ®, const char *functionname);
113 :
114 : UG_API std::string FunctionInfo(const ExportedFunctionBase &thefunc, bool isConst=false,
115 : const char *classname=NULL, const char *highlightclassname=NULL, bool bPrintHelp=false);
116 : UG_API std::string ConstructorInfo(const ExportedConstructor &constr, const char *classname,
117 : const char *highlightclassname=NULL);
118 :
119 : UG_API std::string ClassHierarchyString(const Registry ®, const char *classname);
120 : UG_API std::string ClassInfo(const IExportedClass &c);
121 : UG_API std::string ClassInfo(const Registry ®, const char *classname);
122 : UG_API std::string ClassUsageExact(const Registry ®, const char *classname, bool OutParameters);
123 : UG_API const ExportedFunction *FindFunction(const Registry ®, const char *functionname);
124 : UG_API std::string ParameterToString(const ParameterInfo &par, int i);
125 : UG_API bool IsClassInParameters(const ParameterInfo &par, const char *classname);
126 :
127 : // end group registry
128 : /// \}
129 :
130 : } // end namespace
131 : } // end namespace
132 :
133 : #endif
|