Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ScopedCallback.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6
7
8/**
9 * Helper object for batching callback requests and firing on destruction of the FScopedCallback object.
10 * CallbackType is a class implementing a static method called FireCallback, which does the work.
11 */
12template< class CallbackType >
14{
15public:
16
18 : Counter(0)
19 { }
20
21 /** Fires a callback if outstanding requests exist. */
23 {
24 if (HasRequests())
25 {
27 }
28 }
29
30 /** Request a callback. */
31 void Request()
32 {
33 ++Counter;
34 }
35
36 /** Unrequest a callback. */
37 void Unrequest()
38 {
39 --Counter;
40 }
41
42 /**
43 * Checks whether this callback has outstanding requests.
44 *
45 * @return true if there are outstanding requests, false otherwise.
46 */
47 bool HasRequests() const
48 {
49 return Counter > 0;
50 }
51
52private:
53
54 /** Counts callback requests. */
55 int32 Counter;
56};
bool HasRequests() const