Shared.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Core.h"
4 #include "Engine.h"
5 
6 #include <exception>
7 #include <vector>
8 #include <map>
9 
10 #include "RealSenseNative.h"
11 #include "RealSensePlugin.h"
12 
13 #pragma warning(disable: 4101) // unreferenced local variable
14 
15 DECLARE_LOG_CATEGORY_EXTERN(LogRealSense, Log, All);
16 #define REALSENSE_ERR(Format, ...) UE_LOG(LogRealSense, Error, Format, ## __VA_ARGS__)
17 
18 #if UE_BUILD_SHIPPING
19  #define REALSENSE_TRACE(Format, ...)
20 #else
21  #define REALSENSE_TRACE(Format, ...) UE_LOG(LogRealSense, Display, Format, ## __VA_ARGS__)
22 #endif
23 
24 #if 0
25  // DEV MODE
26  #define PROF_ENABLED
27  #define PROF_CHAR TCHAR
28  #define PROF_TEXT _T
29  #define PROF_LOG(Format, ...) UE_LOG(LogRealSense, Display, Format, __VA_ARGS__)
30  #include "Profiler.h"
31 #else
32  #define INIT_PROFILER
33  #define SHUT_PROFILER
34  #define NAMED_PROFILER(name)
35  #define SCOPED_PROFILER
36 #endif
37 
38 inline FString uestr(const char* str) { return FString(ANSI_TO_TCHAR(str)); }
39 inline FString uestr(const std::string& str) { return FString(ANSI_TO_TCHAR(str.c_str())); }
40 
41 template<typename T>
42 inline T* NewNamedObject(UObject* Owner, const TCHAR* Name)
43 {
44  int Id = IRealSensePlugin::Get().GenId();
45  auto UniqName = FString::Printf(TEXT("%s_UID%d"), Name, Id);
46  //REALSENSE_TRACE(TEXT("NewObject %s"), *UniqName);
47  auto Object = NewObject<T>((Owner ? Owner : GetTransientPackage()), FName(*UniqName), RF_NoFlags); // RF_Standalone
48  return Object;
49 }
50 
52 {
53 public:
56  bool TryLock(FCriticalSection* Mutex) { Unlock(); if (Mutex->TryLock()) { _Mutex = Mutex; return true; } return false; }
57  void Unlock() { if (_Mutex) { _Mutex->Unlock(); _Mutex = nullptr; } }
58  bool IsLocked() const { return _Mutex ? true : false; }
59 private:
61  void operator=(const FScopedTryLock&);
62  FCriticalSection* _Mutex = nullptr;
63 };
::rosgraph_msgs::Log_< std::allocator< void > > Log
Definition: Log.h:88
static IRealSensePlugin & Get()
GLsizei const GLchar *const * string
FCriticalSection * _Mutex
Definition: Shared.h:62
void Unlock()
Definition: Shared.h:57
FScopedTryLock()
Definition: Shared.h:54
base::threading::internal::NoMutex Mutex
bool TryLock(FCriticalSection *Mutex)
Definition: Shared.h:56
T * NewNamedObject(UObject *Owner, const TCHAR *Name)
Definition: Shared.h:42
void operator=(const FScopedTryLock &)
DECLARE_LOG_CATEGORY_EXTERN(LogRealSense, Log, All)
bool IsLocked() const
Definition: Shared.h:58
FString uestr(const char *str)
Definition: Shared.h:38
virtual int GenId()=0
~FScopedTryLock()
Definition: Shared.h:55


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41