gwnavruntime/basesystem/iperfmarkerinterface.h Source File

iperfmarkerinterface.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
10 
11 namespace Kaim
12 {
13 
19 {
20 public:
23  {
24  static IPerfMarkerInterface* s_instance = nullptr;
25  return s_instance;
26  }
27 
28  virtual ~IPerfMarkerInterface() {}
29 
30 private:
32  virtual void Begin(const char* name) = 0;
33 
35  virtual void End() = 0;
36 
37 public:
39  static void BeginMarker(const char* name)
40  {
41  auto* instance = Instance();
42  if (instance)
43  instance->Begin(name);
44  }
45 
47  static void EndMarker()
48  {
49  auto* instance = Instance();
50  if (instance)
51  instance->End();
52  }
53 };
54 
57 {
58 public:
59  ScopedPerfMarker(const char* name) { IPerfMarkerInterface::BeginMarker(name); }
61 };
62 
63 } // Kaim
64 
65 #if defined(KY_PERF_MARKERS_ENABLED)
66 
68  #define KY_PERF_MARKER_BEGIN(name) Kaim::IPerfMarkerInterface::BeginMarker(name);
69 
71  #define KY_PERF_MARKER_END() Kaim::IPerfMarkerInterface::EndMarker();
72 
74  #define KY_SCOPED_PERF_MARKER(name) Kaim::ScopedPerfMarker scopedPerfMarker__(name);
75 
76 #else
77  #define KY_PERF_MARKER_BEGIN(name)
78  #define KY_PERF_MARKER_END()
79  #define KY_SCOPED_PERF_MARKER(name)
80 #endif
81 
82 
static IPerfMarkerInterface *& Instance()
Returns a reference to the singleton pointer. This function called in BaseSystem::Init() with the var...
Definition: iperfmarkerinterface.h:22
static void BeginMarker(const char *name)
calls Instance()->Begin(name);
Definition: iperfmarkerinterface.h:39
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
static void EndMarker()
calls Instance()->End(name);
Definition: iperfmarkerinterface.h:47
virtual void End()=0
End the current marker.
calls IPerfMarkerInterface::BeginMarker(name) in constructor, IPerfMarkerInterface::EndMarker() in de...
Definition: iperfmarkerinterface.h:56
virtual void Begin(const char *name)=0
Begin a new marker.
An abstract interface for performance tracking markers.
Definition: iperfmarkerinterface.h:18