Browse Source

Add generic accessors for Core-related API

core_refactor
Anton Tarasenko 2 years ago
parent
commit
290f756264
  1. 5
      sources/ClientRealm/ClientGlobal.uc
  2. 26
      sources/CoreRealm/CoreGlobal.uc
  3. 7
      sources/ServerRealm/ServerGlobal.uc

5
sources/ClientRealm/ClientGlobal.uc

@ -29,6 +29,11 @@ var public ClientUnrealAPI unreal;
var private LoggerAPI.Definition fatBadAdapterClass, errNoInteraction; var private LoggerAPI.Definition fatBadAdapterClass, errNoInteraction;
public function UnrealAPI unreal_api()
{
return unreal;
}
public final static function ClientGlobal GetInstance() public final static function ClientGlobal GetInstance()
{ {
if (default.myself == none) if (default.myself == none)

26
sources/CoreRealm/CoreGlobal.uc

@ -2,7 +2,7 @@
* Base class for objects that will provide an access to a Acedia's client- and * Base class for objects that will provide an access to a Acedia's client- and
* server-specific functionality by giving a reference to this object to all * server-specific functionality by giving a reference to this object to all
* Acedia's objects and actors, emulating a global API namespace. * Acedia's objects and actors, emulating a global API namespace.
* Copyright 2022 Anton Tarasenko * Copyright 2022-2023 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Acedia. * This file is part of Acedia.
* *
@ -29,6 +29,30 @@ var public TimeAPI time;
var private LoggerAPI.Definition fatNoAdapterClass; var private LoggerAPI.Definition fatNoAdapterClass;
/**
* Accessor to the generic `UnrealAPI`.
*/
public function UnrealAPI unreal_api()
{
return none;
}
public final static function CoreGlobal GetGenericInstance()
{
local ServerGlobal serverAPI;
local ClientGlobal clientAPI;
serverAPI = class'ServerGlobal'.static.GetInstance();
if (serverAPI != none && serverAPI.IsAvailable()) {
return serverAPI;
}
clientAPI = class'ClientGlobal'.static.GetInstance();
if (clientAPI != none && clientAPI.IsAvailable()) {
return clientAPI;
}
return none;
}
/** /**
* This method must perform initialization of the caller `...Global` instance. * This method must perform initialization of the caller `...Global` instance.
* *

7
sources/ServerRealm/ServerGlobal.uc

@ -2,7 +2,7 @@
* Class for an object that will provide an access to a Acedia's * Class for an object that will provide an access to a Acedia's
* server-specific functionality by giving a reference to this object to all * server-specific functionality by giving a reference to this object to all
* Acedia's objects and actors, emulating a global API namespace. * Acedia's objects and actors, emulating a global API namespace.
* Copyright 2022 Anton Tarasenko * Copyright 2022-2023 Anton Tarasenko
*------------------------------------------------------------------------------ *------------------------------------------------------------------------------
* This file is part of Acedia. * This file is part of Acedia.
* *
@ -30,6 +30,11 @@ var public ServerUnrealAPI unreal;
var private LoggerAPI.Definition fatBadAdapterClass; var private LoggerAPI.Definition fatBadAdapterClass;
public function UnrealAPI unreal_api()
{
return unreal;
}
public final static function ServerGlobal GetInstance() public final static function ServerGlobal GetInstance()
{ {
if (default.myself == none) if (default.myself == none)

Loading…
Cancel
Save