kodi
AddonUtils.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 /*
12  * addon.h
13  *
14  * Created on: Aug 21, 2010
15  * Author: jim
16  */
17 
18 //#define ENABLE_XBMC_TRACE_API
19 
20 #include "threads/CriticalSection.h"
21 
22 #include <memory>
23 #include <mutex>
24 #include <vector>
25 
26 #ifdef TARGET_WINDOWS
27 #define __PRETTY_FUNCTION__ __FUNCTION__
28 #endif
29 
35 namespace XBMCAddon
36 {
37 class LanguageHook;
38 }
39 
40 namespace XBMCAddonUtils
41 {
42  class GuiLock
43  {
44  public:
45  GuiLock(XBMCAddon::LanguageHook* languageHook, bool offScreen);
46  ~GuiLock();
47 
48  protected:
49  XBMCAddon::LanguageHook* m_languageHook = nullptr;
50  bool m_offScreen = false;
51  };
52 
54  {
55  std::unique_lock<CCriticalSection>& lock;
56 
57  public:
58  explicit InvertSingleLockGuard(std::unique_lock<CCriticalSection>& _lock) : lock(_lock)
59  {
60  lock.unlock();
61  }
62  ~InvertSingleLockGuard() { lock.lock(); }
63  };
64 
65 
66  /*
67  * Looks in references.xml for image name
68  * If none exist return default image name
69  */
70  const char *getDefaultImage(const char* cControlType, const char* cTextureType);
71 
72 #ifdef ENABLE_XBMC_TRACE_API
73  class TraceGuard
74  {
75  const char* function;
76  public:
77  TraceGuard* parent;
78  int depth;
79 
80  const char* getSpaces();
81 
82  explicit TraceGuard(const char* _function);
83  TraceGuard();
84  ~TraceGuard();
85  };
86 #endif
87 }
88 
89 #ifdef ENABLE_XBMC_TRACE_API
90 #define XBMC_TRACE XBMCAddonUtils::TraceGuard _tg(__PRETTY_FUNCTION__)
91 #else
92 #define XBMC_TRACE
93 #endif
94 
95 
Definition: AddonUtils.cpp:19
Definition: AddonUtils.h:53
Defining LOG_LIFECYCLE_EVENTS will log all instantiations, deletions and also reference countings (in...
Definition: Addon.cpp:25
Definition: AddonUtils.h:42
Definition: LanguageHook.h:29