Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ConsoleManager.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"
6#include "Containers/Map.h"
7#include "Containers/UnrealString.h"
8#include "CoreTypes.h"
9#include "HAL/CriticalSection.h"
10#include "HAL/IConsoleManager.h"
11
12class FOutputDevice;
13class UWorld;
14
16{
17public:
18 /** constructor */
20 : bHistoryWasLoaded(false)
23 {
24 }
25
26 /** destructor */
28 {
29 for(TMap<FString, IConsoleObject*>::TConstIterator PairIt(ConsoleObjects); PairIt; ++PairIt)
30 {
31 IConsoleObject* Var = PairIt.Value();
32
33 delete Var;
34 }
35 }
36
37 // internally needed or ECVF_RenderThreadSafe
39 // internally needed or ECVF_RenderThreadSafe
41
42 /** @param InVar must not be 0 */
43 virtual FString FindConsoleObjectName(const IConsoleObject* Obj) const override;
44
45 /** Can be moved out into some automated testing system */
46 void Test();
47
49
50 virtual FConsoleVariableMulticastDelegate& OnCVarUnregistered()override;
51
52 // interface IConsoleManager -----------------------------------
53
54 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, bool DefaultValue, const TCHAR* Help, uint32 Flags) override;
55 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, int32 DefaultValue, const TCHAR* Help, uint32 Flags) override;
56 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, float DefaultValue, const TCHAR* Help, uint32 Flags) override;
57 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, const TCHAR* DefaultValue, const TCHAR* Help, uint32 Flags) override;
58 virtual IConsoleVariable* RegisterConsoleVariable(const TCHAR* Name, const FString& DefaultValue, const TCHAR* Help, uint32 Flags) override;
59
60 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, bool& RefValue, const TCHAR* Help, uint32 Flags) override;
61 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, int32& RefValue, const TCHAR* Help, uint32 Flags) override;
62 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, float& RefValue, const TCHAR* Help, uint32 Flags) override;
63 virtual IConsoleVariable* RegisterConsoleVariableRef(const TCHAR* Name, FString& RefValue, const TCHAR* Help, uint32 Flags) override;
64 virtual IConsoleVariable* RegisterConsoleVariableBitRef(const TCHAR* CVarName, const TCHAR* FlagName, uint32 BitNumber, uint8* Force0MaskPtr, uint8* Force1MaskPtr, const TCHAR* Help, uint32 Flags) override;
65
66 virtual void CallAllConsoleVariableSinks() override;
67
68 virtual FConsoleVariableSinkHandle RegisterConsoleVariableSink_Handle(const FConsoleCommandDelegate& Command) override;
70
71 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandDelegate& Command, uint32 Flags) override;
72 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsDelegate& Command, uint32 Flags) override;
73 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldDelegate& Command, uint32 Flags) override;
74 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldAndArgsDelegate& Command, uint32 Flags) override;
75 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithArgsAndOutputDeviceDelegate& Command, uint32 Flags) override;
76 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithWorldArgsAndOutputDeviceDelegate& Command, uint32 Flags) override;
77 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, const FConsoleCommandWithOutputDeviceDelegate& Command, uint32 Flags) override;
78 virtual IConsoleCommand* RegisterConsoleCommand(const TCHAR* Name, const TCHAR* Help, uint32 Flags) override;
79 virtual IConsoleObject* FindConsoleObject(const TCHAR* Name, bool bTrackFrequentCalls = true) const override;
80 virtual IConsoleVariable* FindConsoleVariable(const TCHAR* Name, bool bTrackFrequentCalls = true) const override;
81 virtual void ForEachConsoleObjectThatStartsWith(const FConsoleObjectVisitor& Visitor, const TCHAR* ThatStartsWith) const override;
82 virtual void ForEachConsoleObjectThatContains(const FConsoleObjectVisitor& Visitor, const TCHAR* ThatContains) const override;
83 virtual bool ProcessUserConsoleInput(const TCHAR* InInput, FOutputDevice& Ar, UWorld* InWorld) override;
84 virtual void AddConsoleHistoryEntry(const TCHAR* Key, const TCHAR* Input) override;
85 virtual void GetConsoleHistory(const TCHAR* Key, TArray<FString>& Out) override;
86 virtual bool IsNameRegistered(const TCHAR* Name) const override;
87 virtual void RegisterThreadPropagation(uint32 ThreadId, IConsoleThreadPropagation* InCallback) override;
88 virtual void UnregisterConsoleObject( IConsoleObject* Object, bool bKeepState) override;
89
90private: // ----------------------------------------------------
91
92 /** Map of console variables and commands, indexed by the name of that command or variable */
93 // [name] = pointer (pointer must not be 0)
95
99
100 FConsoleVariableMulticastDelegate ConsoleVariableUnregisteredDelegate;
101
103
104 // if true the next call to CallAllConsoleVariableSinks() we will call all registered sinks
106
107 /**
108 * Used to prevent concurrent access to ConsoleObjects.
109 * We don't aim to solve all concurrency problems (for example registering and unregistering a cvar on different threads, or reading a cvar from one thread while writing it from a different thread).
110 * Rather we just ensure that operations on a cvar from one thread will not conflict with operations on another cvar from another thread.
111 **/
113
114 /**
115 * @param Name must not be 0, must not be empty
116 * @param Obj must not be 0
117 * @return 0 if the name was already in use
118 */
120
121 /**
122 * @param Stream must not be 0
123 * @param Pattern must not be 0
124 */
125 static bool MatchPartialName(const TCHAR* Stream, const TCHAR* Pattern);
126
127 /** Returns true if Pattern is found in Stream, case insensitive. */
128 static bool MatchSubstring(const TCHAR* Stream, const TCHAR* Pattern);
129
130 /**
131 * Get string till whitespace, jump over whitespace
132 * inefficient but this code is not performance critical
133 */
134 static FString GetTextSection(const TCHAR* &It);
135
136 /** same as FindConsoleObject() but ECVF_CreatedFromIni are not filtered out (for internal use) */
138
139 /**
140 * Unregisters a console variable or command, if that object was registered. For console variables, this will
141 * actually only "deactivate" the variable so if it becomes registered again the state may persist
142 * (unless bKeepState is false).
143 *
144 * @param Name Name of the console object to remove (not case sensitive)
145 * @param bKeepState if the current state is kept in memory until a cvar with the same name is registered
146 */
147 void UnregisterConsoleObject(const TCHAR* Name, bool bKeepState);
148
149 // reads HistoryEntriesMap from the .ini file (if not already loaded)
151
152 // writes HistoryEntriesMap to the .ini file
154};
FWindowsCriticalSection FCriticalSection
static bool MatchPartialName(const TCHAR *Stream, const TCHAR *Pattern)
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, int32 &RefValue, const TCHAR *Help, uint32 Flags) override
IConsoleThreadPropagation * GetThreadPropagationCallback()
static FString GetTextSection(const TCHAR *&It)
virtual FConsoleVariableMulticastDelegate & OnCVarUnregistered() override
IConsoleObject * FindConsoleObjectUnfiltered(const TCHAR *Name) const
void OnCVarChanged()
virtual IConsoleObject * FindConsoleObject(const TCHAR *Name, bool bTrackFrequentCalls=true) const override
virtual void UnregisterConsoleObject(IConsoleObject *Object, bool bKeepState) override
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, const TCHAR *DefaultValue, const TCHAR *Help, uint32 Flags) override
FConsoleVariableMulticastDelegate ConsoleVariableUnregisteredDelegate
virtual IConsoleCommand * RegisterConsoleCommand(const TCHAR *Name, const TCHAR *Help, uint32 Flags) override
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, bool &RefValue, const TCHAR *Help, uint32 Flags) override
virtual bool IsNameRegistered(const TCHAR *Name) const override
virtual void GetConsoleHistory(const TCHAR *Key, TArray< FString > &Out) override
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, float &RefValue, const TCHAR *Help, uint32 Flags) override
IConsoleObject * AddConsoleObject(const TCHAR *Name, IConsoleObject *Obj)
TMap< FString, TArray< FString > > HistoryEntriesMap
TArray< FConsoleCommandDelegate > ConsoleVariableChangeSinks
void LoadHistoryIfNeeded()
void UnregisterConsoleObject(const TCHAR *Name, bool bKeepState)
bool IsThreadPropagationThread()
IConsoleThreadPropagation * ThreadPropagationCallback
FCriticalSection ConsoleObjectsSynchronizationObject
virtual void RegisterThreadPropagation(uint32 ThreadId, IConsoleThreadPropagation *InCallback) override
static bool MatchSubstring(const TCHAR *Stream, const TCHAR *Pattern)
virtual void CallAllConsoleVariableSinks() override
virtual FConsoleVariableSinkHandle RegisterConsoleVariableSink_Handle(const FConsoleCommandDelegate &Command) override
virtual IConsoleVariable * RegisterConsoleVariableBitRef(const TCHAR *CVarName, const TCHAR *FlagName, uint32 BitNumber, uint8 *Force0MaskPtr, uint8 *Force1MaskPtr, const TCHAR *Help, uint32 Flags) override
virtual IConsoleCommand * RegisterConsoleCommand(const TCHAR *Name, const TCHAR *Help, const FConsoleCommandDelegate &Command, uint32 Flags) override
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, float DefaultValue, const TCHAR *Help, uint32 Flags) override
virtual IConsoleVariable * FindConsoleVariable(const TCHAR *Name, bool bTrackFrequentCalls=true) const override
virtual IConsoleVariable * RegisterConsoleVariableRef(const TCHAR *Name, FString &RefValue, const TCHAR *Help, uint32 Flags) override
virtual FString FindConsoleObjectName(const IConsoleObject *Obj) const override
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, const FString &DefaultValue, const TCHAR *Help, uint32 Flags) override
virtual void ForEachConsoleObjectThatContains(const FConsoleObjectVisitor &Visitor, const TCHAR *ThatContains) const override
virtual bool ProcessUserConsoleInput(const TCHAR *InInput, FOutputDevice &Ar, UWorld *InWorld) override
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, bool DefaultValue, const TCHAR *Help, uint32 Flags) override
TMap< FString, IConsoleObject * > ConsoleObjects
virtual void ForEachConsoleObjectThatStartsWith(const FConsoleObjectVisitor &Visitor, const TCHAR *ThatStartsWith) const override
bool bCallAllConsoleVariableSinks
virtual IConsoleVariable * RegisterConsoleVariable(const TCHAR *Name, int32 DefaultValue, const TCHAR *Help, uint32 Flags) override
virtual void AddConsoleHistoryEntry(const TCHAR *Key, const TCHAR *Input) override
virtual void UnregisterConsoleVariableSink_Handle(FConsoleVariableSinkHandle Handle) override