gtsam  4.0.0
gtsam
debug.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #include <gtsam/base/FastMap.h>
20 #include <gtsam/global_includes.h>
21 #include <string>
22 
23 
24 // This file defines granular debugging flags that may be switched on and off
25 // at run time. Typical usage is 'if(ISDEBUG("myFunction"))' to check if the
26 // 'myFunction' flag is enabled, and SETDEBUG("myFunction", true) to enable
27 // this flag, or SETDEBUG("myFunction", false) to disable it.
28 //
29 // Debug flags are created automatically as they are accessed, so they can be
30 // used immediately without explicitly creating them. Each flag defaults to
31 // 'false', i.e. disabled.
32 //
33 // For these macro to have any effect, granular debugging must be enabled by
34 // defining GTSAM_ENABLE_DEBUG. If NDEBUG is not defined, then
35 // GTSAM_ENABLE_DEBUG will be automatically defined and thus granular
36 // debugging enabled.
37 
38 #ifndef NDEBUG
39 #ifndef GTSAM_ENABLE_DEBUG
40 #define GTSAM_ENABLE_DEBUG
41 #endif
42 #endif
43 
44 namespace gtsam {
45  GTSAM_EXTERN_EXPORT FastMap<std::string, ValueWithDefault<bool,false> > debugFlags;
46 
47  // Non-guarded use led to crashes, and solved in commit cd35db2
48  bool GTSAM_EXPORT guardedIsDebug(const std::string& s);
49  void GTSAM_EXPORT guardedSetDebug(const std::string& s, const bool v);
50 }
51 
52 #undef ISDEBUG
53 #undef SETDEBUG
54 
55 #ifdef GTSAM_ENABLE_DEBUG
56 
57 #define ISDEBUG(S) (gtsam::guardedIsDebug(S))
58 #define SETDEBUG(S,V) ((void)(gtsam::guardedSetDebug(S,V)))
59 
60 #else
61 
62 #define ISDEBUG(S) (false)
63 #define SETDEBUG(S,V) ((void)false)
64 
65 #endif
66 
Included from all GTSAM files.
A thin wrapper around std::map that uses boost's fast_pool_allocator.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28