gwnavruntime/basesystem/iperfmarkerinterface.h Source File

iperfmarkerinterface.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 #ifndef Navigation_IPerfMarkerInterface_H
9 #define Navigation_IPerfMarkerInterface_H
10 
12 
13 namespace Kaim
14 {
15 
20 class IPerfMarkerInterface
21 {
22 public:
24  static IPerfMarkerInterface*& Instance() { static IPerfMarkerInterface* s_instance = KY_NULL; return s_instance; }
25 
26  virtual ~IPerfMarkerInterface() {}
27 
33  virtual void Begin(const char* name) = 0;
34 
39  virtual void End() = 0;
40 
44  static void BeginMarker(const char* name) { if (Instance()) Instance()->Begin(name); }
45 
48  static void EndMarker() { if (Instance()) Instance()->End(); }
49 };
50 
51 
52 class ScopedPerfMarker
53 {
54 public:
55  ScopedPerfMarker(const char* name) { IPerfMarkerInterface::BeginMarker(name); }
56  ~ScopedPerfMarker() { IPerfMarkerInterface::EndMarker(); }
57 };
58 
59 
60 } // Kaim
61 
62 #if defined(KY_PERF_MARKERS_ENABLED)
63 
66  #define KY_PERF_MARKER_BEGIN(name) Kaim::IPerfMarkerInterface::BeginMarker(name)
67 
70  #define KY_PERF_MARKER_END() Kaim::IPerfMarkerInterface::EndMarker()
71 
76  #define KY_SCOPED_PERF_MARKER(name) Kaim::ScopedPerfMarker scopedPerfMarker__(name);
77 
78 #else
79 
80  #define KY_PERF_MARKER_BEGIN(name)
81  #define KY_PERF_MARKER_END()
82  #define KY_SCOPED_PERF_MARKER(name)
83 
84 #endif // defined(KY_PERF_MARKERS_ENABLED)
85 
86 
87 #endif // Navigation_IPerfMarkerInterface_H
static IPerfMarkerInterface *& Instance()
Retrieves the static instance of the IPerfMarkerInterface class managed by the BaseSystem.
Definition: iperfmarkerinterface.h:27
#define KY_NULL
Null value.
Definition: types.h:247
static void BeginMarker(const char *name)
Indicates to the IPerfMarkerInterface that a block of code has begun that it should track...
Definition: iperfmarkerinterface.h:50
Definition: gamekitcrowddispersion.h:20
static void EndMarker()
Indicates to the IPerfMarkerInterface that the currently tracked block of code has been completed...
Definition: iperfmarkerinterface.h:55
virtual void End()=0
Called by instrumented code to indicate that the currently tracked block of code has been completed...
virtual void Begin(const char *name)=0
Called by instrumented code to indicate that a tracked block of code has begun.
An abstract interface for an object that can respond to performance tracking markers.
Definition: iperfmarkerinterface.h:22