Spinning Topp Logo BlackTopp Studios
inc
logtools.h
Go to the documentation of this file.
1 // The DAGFrameScheduler is a Multi-Threaded lock free and wait free scheduling library.
2 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
3 /* This file is part of The DAGFrameScheduler.
4 
5  The DAGFrameScheduler is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  The DAGFrameScheduler is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with The DAGFrameScheduler. If not, see <http://www.gnu.org/licenses/>.
17 */
18 /* The original authors have included a copy of the license specified above in the
19  'doc' folder. See 'gpl.txt'
20 */
21 /* We welcome the use of the DAGFrameScheduler to anyone, including companies who wish to
22  Build professional software and charge for their product.
23 
24  However there are some practical restrictions, so if your project involves
25  any of the following you should contact us and we will try to work something
26  out:
27  - DRM or Copy Protection of any kind(except Copyrights)
28  - Software Patents You Do Not Wish to Freely License
29  - Any Kind of Linking to Non-GPL licensed Works
30  - Are Currently In Violation of Another Copyright Holder's GPL License
31  - If You want to change our code and not add a few hundred MB of stuff to
32  your distribution
33 
34  These and other limitations could cause serious legal problems if you ignore
35  them, so it is best to simply contact us or the Free Software Foundation, if
36  you have any questions.
37 
38  Joseph Toppi - toppij@gmail.com
39  John Blackwood - makoenergy02@gmail.com
40 */
41 #ifndef _logtools_h
42 #define _logtools_h
43 
44 #include "datatypes.h"
45 
46 //#if !(defined(SWIG) && !defined(SWIG_THREADING)) // Do not read when in swig and not in the threading module
47 #if !defined(SWIG) || defined(SWIG_THREADING) // Do not read when in swig and not in the threading module
48 #include "systemcalls.h"
49 #endif
50 
51 #ifndef SWIG
52 #include <iostream>
53 #endif
54 
55 /// @file
56 /// @brief The definitions of the logging tools
57 
58 namespace Mezzanine
59 {
60  namespace Threading
61  {
62 #ifndef SWIG
63  #ifndef SCOPEDTIMER
64  /// @def SCOPEDTIMER
65  /// @brief The easiest way to time the given scope
66  /// @param Stream
67  #ifdef __FUNCTION__
68  #define SCOPEDTIMER(Stream) ScopedTimer TimeThisScope( Stream, __FUNCTION__, __FILE__, __LINE__ );
69  #else
70  #define SCOPEDTIMER(Stream) ScopedTimer TimeThisScope( Stream, __func__, __FILE__, __LINE__ );
71  #endif
72  #endif
73 #endif
74  /// @brief Used to time from this objects creation to its destruction
76  {
77  private:
78  /// @brief The place to send the data.
79  std::ostream& LogTarget;
80 
81  /// @brief Name of the function this was created in.
82  String ScopeName;
83 
84  /// @brief Either empty of the name of the file the scope is in.
85  String FileName;
86 
87  /// @brief A timestamp in microseconds set on creation.
88  MaxInt StartTime;
89 
90  /// @brief The line this was instantiated on or 0.
91  Whole Line;
92 
93  public:
94  /// @brief In a ScopedTimerBegin xml element this logs every parameter and the current timestamp.
95  /// @param LogSink The target to send log messages to.
96  /// @param ScopeToMeasure The name of the current function or a user provided name.
97  /// @param ScopeFile Defaults to an empty string, should be set to __FILE__ or similar.
98  /// @param CurrentLine Defaults to 0, should be set to __LINE__ or similar.
99  ScopedTimer(std::ostream& LogSink = std::cout,
100  String ScopeToMeasure = "UnknownScope",
101  String ScopeFile = String(),
102  Whole CurrentLine = 0
103  );
104 
105  /// @brief Destructor, logs duration and current timestamp in ScopedTimerEnd xml element
106  ~ScopedTimer();
107 
108  };
109  }//Threading
110 }//Mezzanine
111 #endif
All the definitions for datatypes as well as some basic conversion functions are defined here...
This file defines a minimalistic cross-platform thread that the scheduler uses to schedule tasks...
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
long long MaxInt
A large integer type suitable for compile time math and long term microsecond time keeping...
Definition: datatypes.h:190
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Used to time from this objects creation to its destruction.
Definition: logtools.h:75
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159