UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
App.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
7#include "CoreGlobals.h"
8#include "CoreTypes.h"
10#include "HAL/PlatformCrt.h"
11#include "HAL/PlatformMisc.h"
12#include "HAL/PlatformProcess.h"
13#include "Misc/Build.h"
14#include "Misc/CString.h"
15#include "Misc/CommandLine.h"
16#include "Misc/CoreMisc.h"
17#include "Misc/FrameRate.h"
18#include "Misc/Guid.h"
19#include "Misc/Optional.h"
20#include "Misc/Parse.h"
22#include "Misc/Timecode.h"
24#include "UObject/NameTypes.h"
25
26#include <atomic>
27#include <optional>
28
29class FCbObjectId;
30
34class FApp
35{
36public:
37
43 static CORE_API FString GetBranchName();
44
51
58
59#if UE_BUILD_DEVELOPMENT
65 static CORE_API void SetDebugGame(bool bIsDebugGame);
66#endif
67
68 /*
69 * Gets the unique version string for this build. This string is not assumed to have any particular format other being a unique identifier for the build.
70 *
71 * @return The build version
72 */
73 static CORE_API const TCHAR* GetBuildVersion();
74
75 /*
76 * Gets the URL for a job which created these binaries.
77 * This may not be accessible if you are not part of the organization that created this build.
78 * May be overridden with FCoreDelegates::OnGetBuildURL
79 */
80 static CORE_API const TCHAR* GetBuildURL();
81
82 /*
83 * Gets the URL for the currently running Horde job/step if any.
84 * May be overridden with FCoreDelegates::OnGetExecutingJobURL
85 */
86 static CORE_API const TCHAR* GetExecutingJobURL();
87
88 /* Returns whether the binaries were built with debug info */
89 static CORE_API bool GetIsWithDebugInfo();
90
96 static CORE_API FString GetBuildDate();
97
103 static CORE_API FString GetGraphicsRHI();
104
108 static CORE_API void SetGraphicsRHI(FString RHIString);
109
110
115
119 static CORE_API FString GetEpicProductIdentifier();
120
127 {
129 }
130
137 static FString GetName()
138 {
139 FString ExecutableName = FPlatformProcess::ExecutableName();
140
141 int32 ChopIndex = ExecutableName.Find(TEXT("-"));
142
143 if (ExecutableName.FindChar(TCHAR('-'), ChopIndex))
144 {
145 return ExecutableName.Left(ChopIndex);
146 }
147
148 if (ExecutableName.FindChar(TCHAR('.'), ChopIndex))
149 {
150 return ExecutableName.Left(ChopIndex);
151 }
152
153 return ExecutableName;
154 }
155
162 {
163 return (IsProjectNameEmpty() == false) && (FCString::Stricmp(GInternalProjectName, TEXT("None")) != 0);
164 }
165
175 FORCEINLINE static bool IsGame()
176 {
177#if WITH_EDITOR
179#else
180 return true;
181#endif
182 }
183
190 {
191 return (GInternalProjectName[0] == 0);
192 }
193
200 {
201 // At the moment Strcpy is not safe as we don't check the buffer size on all platforms, so we use strncpy here.
203 // And make sure the ProjectName string is null terminated.
205 }
206
207public:
208
215 FORCEINLINE static void AuthorizeUser(const FString& UserName)
216 {
217 SessionUsers.AddUnique(UserName);
218 }
219
226 {
227 SessionUsers.Empty();
228 }
229
236 FORCEINLINE static void DenyUser(const FString& UserName)
237 {
238 SessionUsers.Remove(UserName);
239 }
240
248
249#if PLATFORM_DESKTOP
257#endif
258
269
277 static FString GetInstanceName()
278 {
280 }
281
294 {
295 return SessionId;
296 }
297
305
312 {
313 return SessionName;
314 }
315
327 {
328 return SessionOwner;
329 }
330
334 static CORE_API void InitializeSession();
335
343 FORCEINLINE static bool IsAuthorizedUser(const FString& UserName)
344 {
345 return ((FPlatformProcess::UserName(false) == UserName) || (SessionOwner == UserName) || SessionUsers.Contains(UserName));
346 }
347
357 {
358 return Standalone;
359 }
360
368 {
369 return (InInstanceId == GetInstanceId());
370 };
371
378 FORCEINLINE static void SetSessionName(const FString& NewName)
379 {
380 SessionName = NewName;
381 }
382
389 FORCEINLINE static void SetSessionOwner(const FString& NewOwner)
390 {
391 SessionOwner = NewOwner;
392 }
393
394public:
395
396// MSVC 16.4 (1924) has a bug that does not properly handle the local static bool in CanEverRender. This will be fixed in 16.5. Working around by using FORCENOINLINE.
397// MSVC 16.6 (1926) fixes the problem so inlning can be enabled again from that point onwards.
398#if !UE_SERVER && defined(_MSC_VER) && _MSC_VER >= 1924 && _MSC_VER <= 1925
399#define INLINE_CANEVERRENDER FORCENOINLINE
400#else
401#define INLINE_CANEVERRENDER FORCEINLINE
402#endif
403
412 {
413#if UE_SERVER
414 return false;
415#else
418#endif // UE_SERVER
419 }
420
431 {
432 return !FPlatformProperties::RequiresCookedData() || FApp::CanEverRender();
433 }
434
443 {
444#if UE_SERVER
445 return false;
446#else
447 static bool bHasNoAudioOnCommandline = FParse::Param(FCommandLine::Get(), TEXT("nosound")) && !FParse::Param(FCommandLine::Get(), TEXT("enablesound"));
450#endif // UE_SERVER
451 }
452
465 {
466 static bool bMuteAudio = FParse::Param(FCommandLine::Get(), TEXT("muteaudio"));
467 return bMuteAudio;
468 }
469
484 static CORE_API bool IsInstalled();
485
496 static CORE_API bool IsEngineInstalled();
497
506 static CORE_API bool IsUnattended();
507
516 static CORE_API bool AllowUnattendedInput();
517
527
531 static CORE_API bool IsMultithreadServer();
532
539 {
540 return bIsBenchmarking;
541 }
542
548 static void SetBenchmarking(bool bVal)
549 {
550 bIsBenchmarking = bVal;
551 }
552
559 {
560 return FixedDeltaTime.load(std::memory_order_relaxed);
561 }
562
568 static void SetFixedDeltaTime(double Seconds)
569 {
570 FixedDeltaTime.store(Seconds, std::memory_order_relaxed);
571 }
572
578 static bool UseFixedTimeStep()
579 {
580#if WITH_FIXED_TIME_STEP_SUPPORT
581 return bUseFixedTimeStep;
582#else
583 return false;
584#endif
585 }
586
592 static void SetUseFixedTimeStep(bool bVal)
593 {
594 bUseFixedTimeStep = bVal;
595 }
596
603 {
604 return CurrentTime.load(std::memory_order_relaxed);
605 }
606
612 static void SetCurrentTime(double Seconds)
613 {
614 CurrentTime.store(Seconds, std::memory_order_relaxed);
615 }
616
622 FORCEINLINE static double GetLastTime()
623 {
624 return LastTime.load(std::memory_order_relaxed);
625 }
626
628 static void UpdateLastTime()
629 {
630 // Not an atomic operation, but preferred to a compare and swap
631 LastTime.store(CurrentTime.load(std::memory_order_relaxed), std::memory_order_relaxed);
632 }
633
639 FORCEINLINE static double GetDeltaTime()
640 {
641 return DeltaTime.load(std::memory_order_relaxed);
642 }
643
649 static void SetDeltaTime(double Seconds)
650 {
651 DeltaTime.store(Seconds, std::memory_order_relaxed);
652 }
653
659 FORCEINLINE static double GetIdleTime()
660 {
661 return IdleTime.load(std::memory_order_relaxed);
662 }
663
669 static void SetIdleTime(double Seconds)
670 {
671 IdleTime.store(Seconds, std::memory_order_relaxed);
672 }
673
679 FORCEINLINE static double GetGameTime()
680 {
681 return GameTime.load(std::memory_order_relaxed);
682 }
683
689 static void SetGameTime(double Seconds)
690 {
691 GameTime.store(Seconds, std::memory_order_relaxed);
692 }
693
700 {
701 return IdleTimeOvershoot.load(std::memory_order_relaxed);
702 }
703
709 static void SetIdleTimeOvershoot(double Seconds)
710 {
711 IdleTimeOvershoot.store(Seconds, std::memory_order_relaxed);
712 }
713
721
729
738 {
739 return CurrentFrameTime;
740 }
741
748 UE_DEPRECATED(4.25, "Please use SetQualifiedFrameTime")
753
760 {
761 CurrentFrameTime = InFrameTime;
762 }
763
766 {
767 CurrentFrameTime.Reset();
768 }
769
776 {
777 return VolumeMultiplier;
778 }
779
786 {
787 VolumeMultiplier = InVolumeMultiplier;
788 }
789
796
801
807 static CORE_API void SetUseVRFocus(bool bInUseVRFocus);
808
813 {
814 return bUseVRFocus;
815 }
822 static CORE_API void SetHasVRFocus(bool bInHasVRFocus);
823
829 {
830 return bHasVRFocus;
831 }
832
838 static CORE_API void SetHasFocusFunction(bool (*InHasFocusFunction)());
839
844 static CORE_API bool HasFocus();
845
846 /* If the random seed started with a constant or on time, can be affected by -FIXEDSEED or -BENCHMARK */
848
849 /* Print all initial startup logging */
850 static CORE_API void PrintStartupLogMessages();
851
852private:
853
854#if UE_BUILD_DEVELOPMENT
856 static CORE_API bool bIsDebugGame;
857#endif
858
860 static CORE_API FGuid SessionId;
861
863 static CORE_API FString SessionName;
864
866 static CORE_API FString SessionOwner;
867
869 static CORE_API FString GraphicsRHI;
870
872 static CORE_API TArray<FString> SessionUsers;
873
875 static CORE_API bool Standalone;
876
878 static CORE_API bool bIsBenchmarking;
879
881 static CORE_API bool bUseFixedTimeStep;
882
884 static CORE_API std::atomic<double> FixedDeltaTime;
885
887 static CORE_API std::atomic<double> CurrentTime;
888
890 static CORE_API std::atomic<double> LastTime;
891
893 static CORE_API std::atomic<double> DeltaTime;
894
896 static CORE_API std::atomic<double> IdleTime;
897
899 static CORE_API std::atomic<double> IdleTimeOvershoot;
900
902 static CORE_API std::atomic<double> GameTime;
903
905 static CORE_API TOptional<FQualifiedFrameTime> CurrentFrameTime;
906
908 static CORE_API float VolumeMultiplier;
909
911 static CORE_API float UnfocusedVolumeMultiplier;
912
914 static CORE_API bool bUseVRFocus;
915
917 static CORE_API bool bHasVRFocus;
918
920 static CORE_API bool (*HasFocusFunction)();
921};
922
923
926
927
931CORE_API bool IsServerForOnlineSubsystems(FName WorldContextHandle);
932
#define FORCEINLINE
Definition AndroidPlatform.h:140
CORE_API bool IsServerForOnlineSubsystems(FName WorldContextHandle)
Definition CoreMisc.cpp:230
CORE_API void SetIsServerForOnlineSubsystemsDelegate(FQueryIsRunningServer NewDelegate)
Definition CoreMisc.cpp:242
#define INLINE_CANEVERRENDER
Definition App.h:401
#define USE_NULL_RHI
Definition Build.h:197
TCHAR GInternalProjectName[64]
Definition CoreGlobals.cpp:284
bool GIsPlayInEditorWorld
Definition CoreGlobals.cpp:403
FORCEINLINE bool IsRunningCommandlet()
Definition CoreGlobals.h:247
FORCEINLINE bool IsAllowCommandletRendering()
Definition CoreGlobals.h:309
FORCEINLINE bool IsAllowCommandletAudio()
Definition CoreGlobals.h:318
#define GIsEditor
Definition CoreGlobals.h:233
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
bool IsRunningGame()
Definition CoreMisc.h:177
bool IsRunningDedicatedServer()
Definition CoreMisc.h:152
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DELEGATE_RetVal_OneParam(ReturnValueType, DelegateName, Param1Type)
Definition DelegateCombinations.h:54
EBuildConfiguration
Definition GenericPlatformMisc.h:59
EBuildTargetType
Definition GenericPlatformMisc.h:158
const bool
Definition NetworkReplayStreaming.h:178
TStringView< TCHAR > FStringView
Definition StringFwd.h:45
#define UE_ARRAY_COUNT(array)
Definition UnrealTemplate.h:212
Definition App.h:35
static void InvalidateCurrentFrameTime()
Definition App.h:765
static CORE_API float GetUnfocusedVolumeMultiplier()
Definition App.cpp:339
static FORCEINLINE double GetDeltaTime()
Definition App.h:639
static FORCEINLINE bool IsAuthorizedUser(const FString &UserName)
Definition App.h:343
static FORCEINLINE double GetIdleTime()
Definition App.h:659
static FORCEINLINE double GetCurrentTime()
Definition App.h:602
static FORCEINLINE const TCHAR * GetProjectName()
Definition App.h:126
static FORCEINLINE void DenyAllUsers()
Definition App.h:225
static CORE_API FString GetEpicProductIdentifier()
Definition App.cpp:122
static INLINE_CANEVERRENDER bool CanEverRenderAudio()
Definition App.h:442
static void UpdateLastTime()
Definition App.h:628
static CORE_API bool IsEngineInstalled()
Definition App.cpp:255
static void SetGameTime(double Seconds)
Definition App.h:689
static CORE_API void SetGraphicsRHI(FString RHIString)
Definition App.cpp:180
static CORE_API bool IsMultithreadServer()
Definition App.cpp:314
static CORE_API bool GetIsWithDebugInfo()
Definition App.cpp:82
static FORCEINLINE void AuthorizeUser(const FString &UserName)
Definition App.h:215
static void SetCurrentFrameTime(FQualifiedFrameTime InFrameTime)
Definition App.h:759
static void SetUseFixedTimeStep(bool bVal)
Definition App.h:592
static FORCEINLINE bool IsProjectNameEmpty()
Definition App.h:189
static CORE_API int32 GetEngineIsPromotedBuild()
Definition App.cpp:77
static FORCEINLINE float GetVolumeMultiplier()
Definition App.h:775
static FORCEINLINE double GetIdleTimeOvershoot()
Definition App.h:699
static CORE_API FString GetGraphicsRHI()
Definition App.cpp:175
static CORE_API EBuildTargetType GetBuildTargetType()
Definition App.cpp:146
static CORE_API void SetUnfocusedVolumeMultiplier(float InVolumeMultiplier)
Definition App.cpp:349
static FORCEINLINE bool IsStandalone()
Definition App.h:356
static CORE_API void InitializeSession()
Definition App.cpp:185
static CORE_API bool IsInstalled()
Definition App.cpp:222
static FORCEINLINE bool IsGame()
Definition App.h:175
static FORCEINLINE void SetProjectName(const TCHAR *InProjectName)
Definition App.h:199
static CORE_API bool bUseFixedSeed
Definition App.h:847
static FORCEINLINE void SetSessionOwner(const FString &NewOwner)
Definition App.h:389
static CORE_API bool ShouldUseThreadingForPerformance()
Definition App.cpp:300
static CORE_API const TCHAR * GetBuildVersion()
Definition App.cpp:63
static FString GetInstanceName()
Definition App.h:277
static void SetIdleTimeOvershoot(double Seconds)
Definition App.h:709
static FORCEINLINE bool UseVRFocus()
Definition App.h:812
static CORE_API FString GetBuildDate()
Definition App.cpp:170
static void SetFixedDeltaTime(double Seconds)
Definition App.h:568
static CORE_API void SetHasVRFocus(bool bInHasVRFocus)
Definition App.cpp:362
static FORCEINLINE void SetVolumeMultiplier(float InVolumeMultiplier)
Definition App.h:785
static FORCEINLINE double GetFixedDeltaTime()
Definition App.h:558
static FORCEINLINE bool IsThisInstance(const FGuid &InInstanceId)
Definition App.h:367
static bool UseFixedTimeStep()
Definition App.h:578
static CORE_API void SetUseVRFocus(bool bInUseVRFocus)
Definition App.cpp:356
static CORE_API FString GetBranchName()
Definition App.cpp:58
static FORCEINLINE FString GetSessionOwner()
Definition App.h:326
static FORCEINLINE void SetSessionName(const FString &NewName)
Definition App.h:378
static FString GetName()
Definition App.h:137
static FORCEINLINE bool HasProjectName()
Definition App.h:161
static CORE_API FGuid GetInstanceId()
Definition App.cpp:517
static FORCEINLINE FString GetSessionName()
Definition App.h:311
static FORCEINLINE double GetLastTime()
Definition App.h:622
static CORE_API bool HasFocus()
Definition App.cpp:373
static FORCEINLINE FGuid GetSessionId()
Definition App.h:293
static FORCEINLINE bool HasVRFocus()
Definition App.h:828
static FORCEINLINE bool IsBenchmarking()
Definition App.h:538
static CORE_API FString GetZenStoreProjectId(FStringView SubProject=FStringView())
Definition App.cpp:469
static CORE_API const FCbObjectId & GetSessionObjectId()
Definition App.cpp:523
static CORE_API bool IsUnattended()
Definition App.cpp:284
static FORCEINLINE TOptional< FQualifiedFrameTime > GetCurrentFrameTime()
Definition App.h:737
static CORE_API void PrintStartupLogMessages()
Definition App.cpp:397
static void SetCurrentTime(double Seconds)
Definition App.h:612
static void SetDeltaTime(double Seconds)
Definition App.h:649
static CORE_API FTimecode GetTimecode()
Definition App.cpp:320
static CORE_API FFrameRate GetTimecodeFrameRate()
Definition App.cpp:329
static INLINE_CANEVERRENDER bool CanEverRenderOrProduceRenderData()
Definition App.h:430
static void SetTimecodeAndFrameRate(FTimecode InTimecode, FFrameRate InTimecodeFrameRate)
Definition App.h:749
static void SetIdleTime(double Seconds)
Definition App.h:669
static CORE_API void SetHasFocusFunction(bool(*InHasFocusFunction)())
Definition App.cpp:368
static CORE_API const TCHAR * GetBuildURL()
Definition App.cpp:68
static FORCEINLINE void DenyUser(const FString &UserName)
Definition App.h:236
static CORE_API EBuildConfiguration GetBuildConfiguration()
Definition App.cpp:127
static CORE_API const TCHAR * GetExecutingJobURL()
Definition App.cpp:87
static FORCEINLINE double GetGameTime()
Definition App.h:679
static void SetBenchmarking(bool bVal)
Definition App.h:548
static INLINE_CANEVERRENDER bool IsAudioMuted()
Definition App.h:464
static CORE_API bool AllowUnattendedInput()
Definition App.cpp:292
static INLINE_CANEVERRENDER bool CanEverRender()
Definition App.h:411
Definition CompactBinary.h:479
Definition NameTypes.h:617
Definition Array.h:670
SizeType Remove(const ElementType &Item)
Definition Array.h:3091
bool Contains(const ComparisonType &Item) const
Definition Array.h:1518
UE_FORCEINLINE_HINT SizeType AddUnique(ElementType &&Item)
Definition Array.h:2993
void Empty(SizeType Slack=0)
Definition Array.h:2273
static CORE_API const TCHAR * ExecutableName(bool bRemoveExtension=true)
Definition AndroidPlatformProcess.cpp:107
static CORE_API uint32 GetCurrentProcessId()
Definition AndroidPlatformProcess.cpp:90
static CORE_API const TCHAR * ComputerName()
Definition AndroidPlatformProcess.cpp:65
static CORE_API const TCHAR * Get()
Definition CommandLine.cpp:61
Definition FrameRate.h:21
static CORE_API const TCHAR * UserName(bool bOnlyAlphaNumeric=true)
Definition GenericPlatformProcess.cpp:146
Definition Guid.h:109
static CORE_API bool Param(const TCHAR *Stream, const TCHAR *Param)
Definition Parse.cpp:325
Definition QualifiedFrameTime.h:13
Definition Timecode.h:19
static UE_FORCEINLINE_HINT int32 Stricmp(const CharType *String1, const CharType *String2)
Definition CString.h:1030
static CharType * Strncpy(CharType *Dest, const CharType *Src, SIZE_T MaxLen)
Definition CString.h:991
Definition Optional.h:131
void Reset()
Definition Optional.h:306