Blamite Game Engine - Blam (Core)
utilities.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Windows.h>
4 #include <string>
5 
6 #ifndef BLAM
7 #define BLAM
8 #endif
9 
10 namespace Blam
11 {
15  namespace Utils
16  {
22  BLAM void OpenWebURL(std::string url);
23 
29  BLAM void OpenLocalWebURL(std::string local_path);
30 
37  BLAM std::pair<float, float> GetSystemDpi();
38 
45  BLAM std::pair<float, float> GetEngineDpi();
46  }
47 }
48 
55 template <class Type> void SafeRelease(Type** pointer)
56 {
57  if (*pointer)
58  {
59  (*pointer)->Release();
60  *pointer = NULL;
61  }
62 }
63 
70 template <typename Type> Type* SafeAcquire(Type* newObject)
71 {
72  if (newObject != NULL)
73  {
74  newObject->AddRef();
75  }
76 
77  return newObject;
78 }
79 
87 template <typename Type> void SafeSet(Type** currentObject, Type* newObject)
88 {
89  SafeAcquire(newObject);
90  SafeRelease(&currentObject);
91  currentObject = newObject;
92 }
Blam
Namespace surrounding all major engine components.
Definition: blam_api.h:17
SafeRelease
void SafeRelease(Type **pointer)
Releases a pointer.
Definition: utilities.h:55
Blam::Utils::OpenLocalWebURL
BLAM void OpenLocalWebURL(std::string local_path)
Opens the specified relative path in the user's default web browser.
Definition: web.cpp:9
SafeAcquire
Type * SafeAcquire(Type *newObject)
Acquires an additional reference, if non-null.
Definition: utilities.h:70
Blam::Utils::GetEngineDpi
BLAM std::pair< float, float > GetEngineDpi()
Retrieve the game engine's DPI.
Definition: utilities.cpp:17
Blam::Utils::GetSystemDpi
BLAM std::pair< float, float > GetSystemDpi()
Retrieve the Windows system DPI.
Definition: utilities.cpp:6
SafeSet
void SafeSet(Type **currentObject, Type *newObject)
Sets a new COM object, releasing the old one.
Definition: utilities.h:87
BLAM
#define BLAM
Definition: utilities.h:7
Blam::Utils::OpenWebURL
BLAM void OpenWebURL(std::string url)
Opens the specified URL in the user's default web browser.
Definition: web.cpp:4