1 //*****************************************************************************
2 // FILE: ossimTrace.h
3 //
4 // License:  See top level LICENSE.txt file.
5 //
6 // DESCRIPTION:
7 //   Contains declaration of class ossimTrace. Used for tracing code execution.
8 //   Implemented as a singluy linked list of ossimTrace objects.
9 //
10 // SOFTWARE HISTORY:
11 //   24Apr2001  Oscar Kramer
12 //              Initial coding.
13 //*****************************************************************************
14 // $Id: ossimTrace.h 11650 2007-08-24 12:02:47Z dburken $
15 
16 #ifndef ossimTrace_HEADER
17 #define ossimTrace_HEADER
18 
19 #include <ossim/base/ossimString.h>
20 #include <ossim/base/ossimNotify.h>
21 
22 // Macro for use with trace...
23 #define CLOG ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " (\"" __FILE__ "\", line " << __LINE__ << ") DEBUG: "
24 
25 
26 class OSSIMDLLEXPORT ossimTrace
27 {
28 public:
29    ossimTrace( const ossimString& trace_name );
30    ~ossimTrace();
31 
32    /**
33     * @returns true if enabled false if not.
34     */
isEnabled()35    bool isEnabled() const { return theEnabledFlag; }
36 
37    /**
38     * Returns "theTraceName" as an ossimString.
39     */
getTraceName()40    ossimString getTraceName() const { return theTraceName; }
41 
42 
43    /**
44     * Sets "theEnabled" flag.
45     *
46     * @param flag true == enabled, false == disabled.
47     */
setTraceFlag(bool flag)48    void setTraceFlag(bool flag) { theEnabledFlag = flag; }
49 
50    /**
51     * Operator() for ossimTrace.  Given the static instance:
52     * static ossimTrace traceDebug("myTrace");
53     *
54     * You can do:
55     * if (traceDebug())
56     * {
57     *     CLOG << "Your trace stuff goes here..." << std::endl;
58     * }
59     */
operator()60    bool operator()() const { return theEnabledFlag; }
61 
62 private:
63    ossimString                theTraceName;
64    bool                       theEnabledFlag;
65 };
66 
67 #endif
68