Line data Source code
1 : /*
2 : * Copyright (c) 2011-2015: 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 : #include "registry/registry.h"
34 : #include "bridge/bridge.h"
35 : #include <string>
36 : #include <sstream>
37 : #include <ctime>
38 : #include "common/util/string_util.h"
39 : #include "compile_info/compile_info.h"
40 : #include "common/util/crc32.h"
41 : #include "common/stopwatch.h"
42 : #include "ug.h"
43 :
44 : #ifdef UG_FOR_LUA
45 : #include "bindings/lua/lua_table_handle.h"
46 : #endif
47 :
48 : using namespace std;
49 :
50 : void ug_backtrace();
51 : namespace ug
52 : {
53 :
54 : void PrintLUA();
55 : namespace bridge
56 : {
57 : /// \addtogroup misc_bridge
58 : /// \{
59 :
60 0 : uint32 GetLogAssistantTag(const char *s)
61 : {
62 : /*if(strcmp(s, "MAIN") == 0) return LogAssistant::MAIN;
63 : if(strcmp(s, "APP") == 0) return LogAssistant::APP;
64 : if(strcmp(s, "LIB_GRID") == 0) return LogAssistant::LIB_GRID;
65 : if(strcmp(s, "LIB_GRID_REFINER") ==0) return LogAssistant::LIB_GRID_REFINER;
66 : if(strcmp(s, "LIB_DISC") == 0) return LogAssistant::LIB_DISC;
67 : if(strcmp(s, "LIB_DISC_ASSEMBLE") == 0) return LogAssistant::LIB_DISC_ASSEMBLE;
68 : if(strcmp(s, "LIB_DISC_D3F") == 0) return LogAssistant::LIB_DISC_D3F;
69 : if(strcmp(s, "LIB_DISC_MULTIGRID") == 0) return LogAssistant::LIB_DISC_MULTIGRID;
70 : if(strcmp(s, "LIB_DISC_NEWTON") == 0) return LogAssistant::LIB_DISC_NEWTON;
71 : if(strcmp(s, "LIB_DISC_LINKER") == 0) return LogAssistant::LIB_DISC_LINKER;
72 : if(strcmp(s, "LIB_DISC_TRANSFER") == 0) return LogAssistant::LIB_DISC_TRANSFER;
73 : if(strcmp(s, "LIB_DISC_DISCRETE_FUNCTION") == 0) return LogAssistant::LIB_DISC_DISCRETE_FUNCTION;
74 : if(strcmp(s, "LIB_DISC_OUTPUT") == 0) return LogAssistant::LIB_DISC_OUTPUT;
75 : if(strcmp(s, "LIB_DISC_OPERATOR_INVERSE") == 0) return LogAssistant::LIB_DISC_OPERATOR_INVERSE;
76 : if(strcmp(s, "LIB_ALG_LINEAR_OPERATOR") == 0) return LogAssistant::LIB_ALG_LINEAR_OPERATOR;
77 : if(strcmp(s, "LIB_ALG_LINEAR_SOLVER") == 0) return LogAssistant::LIB_ALG_LINEAR_SOLVER;
78 : if(strcmp(s, "LIB_ALG_VECTOR") == 0) return LogAssistant::LIB_ALG_VECTOR;
79 : if(strcmp(s, "LIB_ALG_MATRIX") == 0) return LogAssistant::LIB_ALG_MATRIX;
80 : if(strcmp(s, "LIB_ALG_AMG") == 0) return LogAssistant::LIB_ALG_AMG;
81 : if(strcmp(s, "LIB_PCL") == 0) return LogAssistant::LIB_PCL;*/
82 0 : if(GetDebugIDManager().debug_id_registered(s) == false)
83 : {
84 0 : UG_LOG("DebugID " << s << " not found!");
85 0 : return 0;
86 : }
87 0 : else return crc32(s);
88 : }
89 :
90 : ////////////////////////////////////////////////////////////////////////////////
91 : /*
92 : A bunch of methods used for printing build configuration
93 : (info for every primary and some dependent cmake setting(s)),
94 : order as by a plain 'cmake ../'
95 :
96 : (To generate a list of macro definitions:
97 : grep add_definitions cmake/ug_includes.cmake
98 : grep "\-D" cmake/ug_includes.cmake.)
99 : */
100 :
101 : // DIM:
102 :
103 :
104 : #ifdef UG_DIM_1
105 0 : bool IsDefinedUG_DIM_1() { return true; }
106 : #else
107 : bool IsDefinedUG_DIM_1() { return false; }
108 : #endif
109 :
110 : #ifdef UG_DIM_2
111 0 : bool IsDefinedUG_DIM_2() { return true; }
112 : #else
113 : bool IsDefinedUG_DIM_2() { return false; }
114 : #endif
115 :
116 : #ifdef UG_DIM_3
117 0 : bool IsDefinedUG_DIM_3() { return true; }
118 : #else
119 : bool IsDefinedUG_DIM_3() { return false; }
120 : #endif
121 :
122 : // CPU:
123 : #ifdef UG_CPU_1
124 0 : bool IsDefinedUG_CPU_1() { return true; }
125 : #else
126 : bool IsDefinedUG_CPU_1() { return false; }
127 : #endif
128 :
129 : #ifdef UG_CPU_2
130 0 : bool IsDefinedUG_CPU_2() { return true; }
131 : #else
132 : bool IsDefinedUG_CPU_2() { return false; }
133 : #endif
134 :
135 : #ifdef UG_CPU_3
136 0 : bool IsDefinedUG_CPU_3() { return true; }
137 : #else
138 : bool IsDefinedUG_CPU_3() { return false; }
139 : #endif
140 :
141 : #ifdef UG_CPU_4
142 : bool IsDefinedUG_CPU_4() { return true; }
143 : #else
144 0 : bool IsDefinedUG_CPU_4() { return false; }
145 : #endif
146 :
147 : #ifdef UG_CPU_5
148 : bool IsDefinedUG_CPU_5() { return true; }
149 : #else
150 0 : bool IsDefinedUG_CPU_5() { return false; }
151 : #endif
152 :
153 : #ifdef UG_CPU_6
154 : bool IsDefinedUG_CPU_6() { return true; }
155 : #else
156 0 : bool IsDefinedUG_CPU_6() { return false; }
157 : #endif
158 :
159 : #ifdef UG_CPU_VAR
160 : bool IsDefinedUG_CPU_VAR() { return true; }
161 : #else
162 0 : bool IsDefinedUG_CPU_VAR() { return false; }
163 : #endif
164 :
165 : // STATIC:
166 : #ifdef UG_STATIC
167 : bool IsDefinedUG_STATIC() { return true; }
168 : #else
169 0 : bool IsDefinedUG_STATIC() { return false; }
170 : #endif
171 :
172 : // DEBUG, DEBUG_LOGS:
173 : #ifdef UG_DEBUG
174 : bool IsDefinedUG_DEBUG() { return true; }
175 : #else
176 0 : bool IsDefinedUG_DEBUG() { return false; }
177 : #endif
178 :
179 : #ifdef UG_ENABLE_DEBUG_LOGS
180 : bool IsDefinedUG_ENABLE_DEBUG_LOGS() { return true; }
181 : #else
182 0 : bool IsDefinedUG_ENABLE_DEBUG_LOGS() { return false; }
183 : #endif
184 :
185 : // PARALLEL:
186 : #ifdef UG_PARALLEL
187 : bool IsDefinedUG_PARALLEL() { return true; }
188 : #else
189 0 : bool IsDefinedUG_PARALLEL() { return false; }
190 : #endif
191 :
192 : // PCL_DEBUG_BARRIER:
193 : #ifdef PCL_DEBUG_BARRIER_ENABLED
194 : bool IsDefinedPCL_DEBUG_BARRIER_ENABLED() { return true; }
195 : #else
196 0 : bool IsDefinedPCL_DEBUG_BARRIER_ENABLED() { return false; }
197 : #endif
198 :
199 : // PROFILE:
200 : #ifdef UG_PROFILER
201 : bool IsDefinedUG_PROFILER() { return true; }
202 : #else
203 0 : bool IsDefinedUG_PROFILER() { return false; }
204 : #endif
205 :
206 : // PROFILE_PCL:
207 : #ifdef PROFILE_PCL
208 : bool IsDefinedPROFILE_PCL() { return true; }
209 : #else
210 0 : bool IsDefinedPROFILE_PCL() { return false; }
211 : #endif
212 :
213 : // ALGEBRA - derived, no output by 'cmake' until now:
214 : #ifdef UG_ALGEBRA
215 0 : bool IsDefinedUG_ALGEBRA() { return true; }
216 : #else
217 : bool IsDefinedUG_ALGEBRA() { return false; }
218 : #endif
219 :
220 : // LAPACK_AVAILABLE - derived:
221 : #ifdef LAPACK_AVAILABLE
222 : bool IsDefinedLAPACK_AVAILABLE() { return true; }
223 : #else
224 0 : bool IsDefinedLAPACK_AVAILABLE() { return false; }
225 : #endif
226 :
227 : // BLAS_AVAILABLE - derived:
228 : #ifdef BLAS_AVAILABLE
229 : bool IsDefinedBLAS_AVAILABLE() { return true; }
230 : #else
231 0 : bool IsDefinedBLAS_AVAILABLE() { return false; }
232 : #endif
233 :
234 : // External libraries:
235 : #ifdef UG_TETGEN
236 : bool IsDefinedUG_TETGEN() { return true; }
237 : #else
238 0 : bool IsDefinedUG_TETGEN() { return false; }
239 : #endif
240 :
241 : #ifdef UG_HYPRE
242 : bool IsDefinedUG_HYPRE() { return true; }
243 : #else
244 0 : bool IsDefinedUG_HYPRE() { return false; }
245 : #endif
246 :
247 : #ifdef UG_HLIBPRO
248 : bool IsDefinedUG_HLIBPRO() { return true; }
249 : #else
250 0 : bool IsDefinedUG_HLIBPRO() { return false; }
251 : #endif
252 :
253 : // VRL - derived (depends on target):
254 : #ifdef UG_FOR_VRL
255 : bool IsDefinedUG_FOR_VRL() { return true; }
256 : #else
257 0 : bool IsDefinedUG_FOR_VRL() { return false; }
258 : #endif
259 :
260 : // PLUGIN - derived (depends on target)
261 : #ifdef UG_PLUGINS
262 0 : bool IsDefinedUG_PLUGINS() { return true; }
263 : #else
264 : bool IsDefinedUG_PLUGINS() { return false; }
265 : #endif
266 :
267 : // BRIDGE - derived (depends on target)
268 : #ifdef UG_BRIDGE
269 0 : bool IsDefinedUG_BRIDGE() { return true; }
270 : #else
271 : bool IsDefinedUG_BRIDGE() { return false; }
272 : #endif
273 :
274 : #ifdef UG_JSON
275 : bool IsDefinedUG_JSON() { return true; }
276 : #else
277 0 : bool IsDefinedUG_JSON() { return false; }
278 : #endif
279 :
280 : /// prints CMake build parameters in a quite compact (pairwise) form
281 0 : void PrintBuildConfiguration()
282 : {
283 0 : std::string aux_str("");
284 :
285 : UG_LOG("--------------------------------------------------------------------------------\n");
286 : UG_LOG("Build configuration:\n\n");
287 :
288 : // TODO: Maybe there is a nicer order for displaying the parameters!?
289 :
290 : // 1. Primary (direct, independent) cmake parameters:
291 : UG_LOG("1. Primary 'cmake' parameters:\n");
292 :
293 : // first pair
294 : aux_str = "";
295 0 : aux_str.append("TARGET: ").append(UG_TARGET);
296 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
297 : aux_str = "";
298 0 : aux_str.append("STATIC: ").append( (IsDefinedUG_STATIC() ? "ON " : "OFF") );
299 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
300 :
301 : // next pair
302 : aux_str = "";
303 0 : aux_str.append("PARALLEL: ").append( (IsDefinedUG_PARALLEL() ? "ON " : "OFF") );
304 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
305 : aux_str = "";
306 0 : aux_str.append("PCL_DEBUG_BARRIER: ").append( (IsDefinedPCL_DEBUG_BARRIER_ENABLED() ? "ON " : "OFF") );
307 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
308 :
309 : // next pair
310 : aux_str = "";
311 0 : aux_str.append("DEBUG: ").append( (IsDefinedUG_DEBUG() ? "ON " : "OFF") );
312 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
313 : aux_str = "";
314 0 : aux_str.append("DEBUG_LOGS: ").append( (IsDefinedUG_ENABLE_DEBUG_LOGS() ? "ON " : "OFF") );
315 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
316 :
317 : // next pair
318 : aux_str = "";
319 0 : aux_str.append("PROFILER: ").append( (IsDefinedUG_PROFILER() ? "ON " : "OFF") );
320 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
321 : aux_str = "";
322 0 : aux_str.append("PROFILE_PCL: ").append( (IsDefinedPROFILE_PCL() ? "ON " : "OFF") );
323 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
324 :
325 : // next pair
326 : // Please note that there are also independent cmake parameters 'LAPACK' and 'BLAS',
327 : // but we are only interested if LAPACK/BLAS was found or not (if requested).
328 : aux_str = "";
329 0 : aux_str.append("LAPACK available: ").append( (IsDefinedLAPACK_AVAILABLE() ? "YES" : "NO ") );
330 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
331 : aux_str = "";
332 0 : aux_str.append("BLAS available: ").append( (IsDefinedBLAS_AVAILABLE() ? "YES" : "NO ") );
333 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
334 :
335 : // DIM gets its own line
336 : UG_LOG("DIM: ");
337 0 : if (IsDefinedUG_DIM_1() && IsDefinedUG_DIM_2() && IsDefinedUG_DIM_3()) {
338 : UG_LOG("ALL");
339 : } else {
340 0 : UG_LOG( (IsDefinedUG_DIM_1() ? "1 " : "") ); // or maybe a "-" for dim not defined!?
341 0 : UG_LOG( (IsDefinedUG_DIM_2() ? "2 " : "") );
342 0 : UG_LOG( (IsDefinedUG_DIM_3() ? "3 " : "") );
343 : }
344 : UG_LOG("\n");
345 :
346 : // next pair
347 : aux_str = "";
348 0 : aux_str.append("CPU: ");
349 0 : aux_str.append( (IsDefinedUG_CPU_1() ? "1 " : "") );
350 0 : aux_str.append( (IsDefinedUG_CPU_2() ? "2 " : "") );
351 0 : aux_str.append( (IsDefinedUG_CPU_3() ? "3 " : "") );
352 0 : aux_str.append( (IsDefinedUG_CPU_4() ? "4 " : "") );
353 0 : aux_str.append( (IsDefinedUG_CPU_5() ? "5 " : "") );
354 0 : aux_str.append( (IsDefinedUG_CPU_VAR() ? "VAR" : "") );
355 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
356 :
357 : // We've decided so far not to display the following derived parameters!
358 :
359 : // 2. External stuff:
360 : UG_LOG("\n2. External libraries:\n");
361 :
362 : // next pair
363 : aux_str = "";
364 0 : aux_str.append("TETGEN: ").append( (IsDefinedUG_TETGEN() ? "ON " : "OFF") );
365 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
366 :
367 : aux_str = "";
368 0 : aux_str.append("HYPRE: ").append( (IsDefinedUG_HYPRE() ? "ON " : "OFF") );
369 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
370 :
371 : // next pair
372 : aux_str = "";
373 0 : aux_str.append("HLIBPRO: ").append( (IsDefinedUG_HLIBPRO() ? "ON " : "OFF") );
374 0 : UG_LOG(AppendSpacesToString(aux_str,40).append(""));
375 :
376 : aux_str = "";
377 : //aux_str.append("?: ").append( (IsDefinedUG_?() ? "ON " : "OFF") );
378 0 : UG_LOG(AppendSpacesToString(aux_str,40).append("\n"));
379 : UG_LOG("--------------------------------------------------------------------------------\n");
380 0 : }
381 :
382 0 : void PrintBuildConfigurationExtended()
383 : {
384 : // We've decided so far not to display the following derived parameters:
385 : // 2. Derived parameters (no direct parameters to cmake):
386 : UG_LOG("Derived parameters:\n");
387 : UG_LOG("Build for VRL: ");
388 0 : UG_LOG( (IsDefinedUG_FOR_VRL() ? "ON " : "OFF") );
389 : UG_LOG("\n");
390 :
391 : UG_LOG("PLUGIN: ");
392 0 : UG_LOG( (IsDefinedUG_PLUGINS() ? "ON " : "OFF") );
393 : UG_LOG("\n");
394 :
395 : UG_LOG("BRIDGE: ");
396 0 : UG_LOG( (IsDefinedUG_BRIDGE() ? "ON " : "OFF") );
397 : UG_LOG("\n");
398 :
399 : UG_LOG("ALGEBRA: ");
400 0 : UG_LOG( (IsDefinedUG_ALGEBRA() ? "ON " : "OFF") );
401 : UG_LOG("\n\n");
402 :
403 : // Derived parameters END
404 :
405 :
406 : UG_LOG("--------------------------------------------------------------------------------\n");
407 0 : }
408 :
409 : ////////////////////////////////////////////////////////////////////////////////
410 :
411 0 : void SetDebugLevel(const char* strTag, int level)
412 : {
413 : GetLogAssistant().set_debug_level(strTag, level);
414 0 : }
415 :
416 0 : string GetSVNRevision()
417 : {
418 0 : return string(UGSvnRevision());
419 : }
420 :
421 0 : string GetGITRevision()
422 : {
423 0 : return string(UGGitRevision());
424 : }
425 :
426 0 : string GetCompileDate()
427 : {
428 0 : return string(UGCompileDate());
429 : }
430 :
431 0 : string GetBuildHostname()
432 : {
433 0 : return string(UGBuildHost());
434 : }
435 :
436 : /// clock() and os.clock only returns CPU time.
437 : /// get_clock_s returns seconds since 1970.
438 0 : double GetClockS()
439 : {
440 0 : return get_clock_s();
441 : }
442 :
443 :
444 0 : string FilenameStringEscape(string s)
445 : {
446 0 : stringstream ss;
447 0 : for(size_t i=0; i<s.length(); i++)
448 : {
449 0 : char c = s[i];
450 0 : if( (c >= '0' && c <= '9' )
451 0 : || (c >= 'A' && c <= 'Z')
452 : || (c >= 'a' && c <= 'z')
453 : || c == '.' || c == '-' || c == '_'
454 : || c == '+' || c == '=')
455 : {
456 0 : ss << c;
457 : }
458 : else
459 : {
460 0 : ss << '_';
461 : }
462 : }
463 0 : return ss.str();
464 0 : }
465 :
466 0 : string GetOperatingSystem()
467 : {
468 : #if defined(__CYGWIN__)
469 : return "cygwin";
470 : #elif defined(__APPLE__)
471 : return "apple";
472 : #elif defined(__linux__)
473 0 : return "linux";
474 : #elif defined(__FreeBSD__)
475 : return "FreeBSD";
476 : #elif defined(_WIN32) || defined(_WIN64)
477 : return "windows";
478 : #endif
479 : }
480 :
481 0 : static void errlog(const char* msg)
482 : {
483 0 : UG_ERR_LOG(msg);
484 0 : }
485 :
486 1 : void RegisterBridge_Misc(Registry ®, string parentGroup)
487 : {
488 :
489 : {
490 2 : stringstream ss; ss << parentGroup << "/Util/Log";
491 : string grp = ss.str();
492 3 : reg.add_class_<LogAssistant>("LogAssistant", grp)
493 2 : .add_method("enable_file_output", &LogAssistant::enable_file_output,
494 : "", "bEnable#filename", "Please note that only the filename given at the first call is considered")
495 2 : .add_method("rename_log_file", &LogAssistant::rename_log_file,
496 : "", "filename", "Renames previously opened logfile to the name given")
497 2 : .add_method("enable_terminal_output", &LogAssistant::enable_terminal_output,
498 : "", "bEnable", "enables or disables terminal output (enabled by default)")
499 2 : .add_method("set_debug_levels", &LogAssistant::set_debug_levels, "", "lev", "sets the debug level of all tags to 'lev'")
500 :
501 3 : .add_method("set_debug_level", static_cast<bool (LogAssistant::*)(const char *, int)>(&LogAssistant::set_debug_level_noninline), "", "tag#lev", "sets the debug level of Tag 'tag' to level 'lev'")
502 4 : .add_method("get_debug_level", static_cast<int (LogAssistant::*)(const char *) const>(&LogAssistant::get_debug_level_noninline), "", "tag#lev", "gets the debug level of Tag 'tag'")
503 :
504 3 : .add_method("get_debug_IDs", &LogAssistant::get_registered_debug_IDs, "debug IDs")
505 :
506 2 : .add_method("set_output_process", &LogAssistant::set_output_process, "", "procRank", "Sets the process which shall output its data.")
507 2 : .add_method("get_output_process", &LogAssistant::get_output_process, "", "", "Returns the process which outputs its data.")
508 2 : .add_method("is_output_process", &LogAssistant::set_output_process, "", "procRank", "Returns whether the process outputs its data.")
509 2 : .add_method("flush", &LogAssistant::flush, "", "", "flush all buffers, especially the file buffer.")
510 : ;
511 3 : reg.add_function("GetLogAssistant", &GetLogAssistant, grp, "the log assistant");
512 : //reg.add_function("GetLogAssistantTag", &GetLogAssistantTag, grp, "integer tag for use int set_debug_level");
513 : //reg.add_function("SetDebugLevel", &SetDebugLevel, grp);
514 3 : reg.add_function("GetClockS", &GetClockS, grp, "seconds since 1970", "", "use this instead of os.clock() since os.clock only returns CPU time.");
515 3 : reg.add_function("PrintLUA", &PrintLUA, grp);
516 3 : reg.add_function("errlog", &errlog, grp, "", "msg",
517 : "prints the specified message to the error-stream.");
518 1 : }
519 :
520 : {
521 2 : stringstream ss; ss << parentGroup << "/Util/Internal";
522 : string grp = ss.str();
523 :
524 :
525 3 : reg.add_function("DefinedUG_DEBUG", &IsDefinedUG_DEBUG, grp, ""); // TODO: only for backward compatibility - remove if not / no longer used!
526 3 : reg.add_function("DefinedUG_ENABLE_DEBUG_LOGS", &IsDefinedUG_ENABLE_DEBUG_LOGS, grp, ""); // TODO: only for backward compatibility - remove if not / no longer used!
527 :
528 : #define ADD_DEFINED_FUNC(VAR) reg.add_function("IsDefined"#VAR, IsDefined##VAR, grp)
529 3 : ADD_DEFINED_FUNC(UG_DEBUG);
530 3 : ADD_DEFINED_FUNC(UG_PARALLEL);
531 3 : ADD_DEFINED_FUNC(UG_DIM_1);
532 3 : ADD_DEFINED_FUNC(UG_DIM_2);
533 3 : ADD_DEFINED_FUNC(UG_DIM_3);
534 3 : ADD_DEFINED_FUNC(UG_CPU_1);
535 3 : ADD_DEFINED_FUNC(UG_CPU_2);
536 3 : ADD_DEFINED_FUNC(UG_CPU_3);
537 3 : ADD_DEFINED_FUNC(UG_ENABLE_DEBUG_LOGS);
538 3 : ADD_DEFINED_FUNC(LAPACK_AVAILABLE);
539 3 : ADD_DEFINED_FUNC(BLAS_AVAILABLE);
540 3 : ADD_DEFINED_FUNC(UG_HYPRE);
541 3 : ADD_DEFINED_FUNC(UG_HLIBPRO);
542 3 : ADD_DEFINED_FUNC(UG_JSON);
543 :
544 3 : reg.add_function("PrintBuildConfiguration", &PrintBuildConfiguration, grp, "");
545 3 : reg.add_function("PrintBuildConfigurationExtended", &PrintBuildConfigurationExtended, grp, "");
546 :
547 :
548 :
549 3 : reg.add_function("GetSVNRevision", &GetSVNRevision, grp);
550 3 : reg.add_function("GetGITRevision", &GetGITRevision, grp);
551 3 : reg.add_function("GetCompileDate", &GetCompileDate, grp);
552 3 : reg.add_function("GetBuildHostname", &GetBuildHostname, grp);
553 3 : reg.add_function("GetOperatingSystem", &GetOperatingSystem, grp);
554 :
555 3 : reg.add_function("LevenshteinDistance", &LevenshteinDistance, grp, "Levenshtein distance of s1 and s2", "s1#s2");
556 3 : reg.add_function("WildcardMatch", &WildcardMatch, grp, "true if match", "str#pattern");
557 3 : reg.add_function("ReplaceAll", &ReplaceAll, grp, "replace string", "target#old#new");
558 3 : reg.add_function("XMLStringEscape", &XMLStringEscape, grp, "string usable in XML files", "str");
559 3 : reg.add_function("FilenameStringEscape", &FilenameStringEscape, grp, "string usable as filename", "str");
560 :
561 3 : reg.add_function("ug_backtrace", &ug_backtrace, grp, "", "", "prints lua/shiny/gcc backtrace information");
562 :
563 3 : reg.add_function("AbortRun", &AbortRun, grp, "", "", "Sets an internal variable to true, to indicate that the run should be aborted on the next call to TerminateAbortedRun.");
564 3 : reg.add_function("ClearAbortRunFlag", &ClearAbortRunFlag, grp, "", "", "Clear the abort-run-flag.");
565 3 : reg.add_function("TerminateAbortedRun", &TerminateAbortedRun, grp, "", "", "Terminates the current run if AbortRun() has been called before.");
566 1 : }
567 :
568 : #ifdef UG_FOR_LUA
569 : {
570 2 : stringstream ss; ss << parentGroup << "/Util/Lua";
571 : string grp = ss.str();
572 : typedef LuaTableHandle T;
573 3 : reg.add_class_<T /*, TBase*/>("LuaTableHandle", grp)
574 2 : .add_method("size", &T::size)
575 1 : .set_construct_as_smart_pointer(true) // really?
576 : ;
577 1 : }
578 : #endif
579 :
580 1 : } // RegisterBridge_Misc
581 :
582 : // end group misc_bridge
583 : /// \}
584 :
585 : } // end namespace bridge
586 :
587 : } // end namespace ug
|