Merge branch 'development' into optimization/unused_files

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/IEditorImpl.cpp
#	Code/Editor/IEditorImpl.h
#	Gems/LmbrCentral/Code/Tests/lmbrcentral_editor_tests_files.cmake
This commit is contained in:
Esteban Papp
2022-01-25 15:40:30 -08:00
871 changed files with 19489 additions and 7437 deletions
@@ -177,6 +177,11 @@ namespace AWSCore
using OnSuccessFunction = AZStd::function<void(AwsApiRequestJob* job)>;
using OnFailureFunction = AZStd::function<void(AwsApiRequestJob* job)>;
class Function;
template<class Allocator = AZ::SystemAllocator>
static AwsApiRequestJob* Create(OnSuccessFunction onSuccess, OnFailureFunction onFailure = OnFailureFunction{}, IConfig* config = GetDefaultConfig());
static Config* GetDefaultConfig()
{
static AwsApiJobConfigHolder<Config> s_configHolder{};
@@ -188,32 +193,6 @@ namespace AWSCore
{
}
AwsApiRequestJob(bool queueOnSuccess,
OnSuccessFunction onSuccess,
bool queueOnFailure,
OnFailureFunction onFailure,
bool queueDelete,
IConfig* config = GetDefaultConfig()
) : AwsApiClientJobType(false, config)
, m_queueOnSuccess{ queueOnSuccess }
, m_onSuccess{ onSuccess }
, m_queueOnFailure{ queueOnFailure }
, m_onFailure{ onFailure }
, m_queueDelete{ queueDelete }
{
}
AwsApiRequestJob(OnSuccessFunction onSuccess,
OnFailureFunction onFailure,
IConfig* config = GetDefaultConfig()
) : AwsApiRequestJob(true, onSuccess, true, onFailure, true, config)
{
}
RequestType request;
ResultType result;
ErrorType error;
/// Override AZ:Job defined method to reset request state when
/// the job object is reused.
void Reset(bool isClearDependent) override
@@ -231,20 +210,11 @@ namespace AWSCore
return m_wasSuccess;
}
RequestType request;
ResultType result;
ErrorType error;
protected:
bool m_wasSuccess{ false };
// Flag and optional function call to queue for onSuccess events
bool m_queueOnSuccess{ false };
OnSuccessFunction m_onSuccess{};
// Flag and optional function call to queue for onFailure events
bool m_queueOnFailure{ false };
OnFailureFunction m_onFailure{};
// Flag to queue the delete during the DoCleanup calls
bool m_queueDelete{ false };
void Process() override
{
@@ -302,56 +272,86 @@ namespace AWSCore
/// Called when request has completed successfully.
virtual void OnSuccess()
{
if (m_queueOnSuccess)
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onSuccess)
{
m_onSuccess(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
}
/// Called when the request fails.
virtual void OnFailure()
{
if (m_queueOnFailure)
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onFailure)
{
m_onFailure(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
}
/// Called when request can't process and still requires cleanup (Specifically for our derived class Function which does not use auto delete)
/// Called when request can't process and still requires cleanup (Specifically for the derived class AwsApiRequestJob<RequestTraits>::Function which does not use auto delete)
virtual void DoCleanup()
{
if (m_queueDelete)
{
AZStd::function<void()> callbackHandler = [this]()
{
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
}
public:
template<class Allocator = AZ::SystemAllocator>
static AwsApiRequestJob* Create(OnSuccessFunction onSuccess, OnFailureFunction onFailure = OnFailureFunction{}, IConfig* config = GetDefaultConfig())
{
return azcreate(AwsApiRequestJob, (onSuccess, onFailure, config), Allocator);
}
bool m_wasSuccess{ false };
};
/// A specialization of AwsApiRequestJob that lets you provide functions
/// that are called on success or failure of the request.
template<class RequestTraits>
class AwsApiRequestJob<RequestTraits>::Function
: public AwsApiRequestJob
{
public:
// To use a different allocator, extend this class and use this macro.
AZ_CLASS_ALLOCATOR(Function, AZ::SystemAllocator, 0);
Function(OnSuccessFunction onSuccess, OnFailureFunction onFailure = OnFailureFunction{}, IConfig* config = GetDefaultConfig())
: AwsApiRequestJobType(
false, config) // No auto delete - we need to perform our callbacks on the main thread so we queue them through tickbus
, m_onSuccess{ onSuccess }
, m_onFailure{ onFailure }
{
}
private:
void OnSuccess() override
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onSuccess)
{
m_onSuccess(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
void OnFailure() override
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onFailure)
{
m_onFailure(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
// Code doesn't use auto delete - this allows code to make sure things get cleaned up in cases where success or failure can't be
// called.
void DoCleanup() override
{
AZStd::function<void()> callbackHandler = [this]()
{
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
OnSuccessFunction m_onSuccess;
OnFailureFunction m_onFailure;
};
template<class RequestTraits>
template<class Allocator>
AwsApiRequestJob<RequestTraits>* AwsApiRequestJob<RequestTraits>::Create(
OnSuccessFunction onSuccess, OnFailureFunction onFailure, IConfig* config)
{
return azcreate(Function, (onSuccess, onFailure, config), Allocator);
}
} // namespace AWSCore
@@ -150,6 +150,11 @@ namespace AWSCore
using OnSuccessFunction = AZStd::function<void(ServiceRequestJob* job)>;
using OnFailureFunction = AZStd::function<void(ServiceRequestJob* job)>;
class Function;
template<class Allocator = AZ::SystemAllocator>
static ServiceRequestJob* Create(OnSuccessFunction onSuccess, OnFailureFunction onFailure = OnFailureFunction{}, IConfig* config = GetDefaultConfig());
static Config* GetDefaultConfig()
{
static AwsApiJobConfigHolder<Config> s_configHolder{};
@@ -178,29 +183,6 @@ namespace AWSCore
}
}
ServiceRequestJob(bool queueOnSuccess,
OnSuccessFunction onSuccess,
bool queueOnFailure,
OnFailureFunction onFailure,
bool queueDelete,
IConfig* config = GetDefaultConfig()
) : ServiceClientJobType{ false, config }
, m_requestUrl{ config->GetRequestUrl() }
, m_queueOnSuccess{ queueOnSuccess }
, m_onSuccess{ onSuccess }
, m_queueOnFailure{ queueOnFailure }
, m_onFailure{ onFailure }
, m_queueDelete{ queueDelete }
{
}
ServiceRequestJob(OnSuccessFunction onSuccess,
OnFailureFunction onFailure,
IConfig* config = GetDefaultConfig()
) : ServiceRequestJob(true, onSuccess, true, onFailure, true, config)
{
}
bool HasCredentials(IConfig* config)
{
if (config == nullptr)
@@ -235,30 +217,6 @@ namespace AWSCore
}
protected:
/// The URL created by appending the API path to the service URL.
/// The path may contain {param} format parameters. The
/// RequestType::parameters.BuildRequest method is responsible
/// for replacing these parts of the url.
const Aws::String& m_requestUrl;
// Flag and optional function call to queue for onSuccess events
bool m_queueOnSuccess{ false };
OnSuccessFunction m_onSuccess{};
// Flag and optional function call to queue for onFailure events
bool m_queueOnFailure{ false };
OnFailureFunction m_onFailure{};
// Flag to queue the delete during the DoCleanup calls
bool m_queueDelete{ false };
std::shared_ptr<Aws::Client::AWSAuthV4Signer> m_AWSAuthSigner{ nullptr };
// Passed in configuration contains the AWS Credentials to use. If this request requires credentials
// check in the constructor and set this bool to indicate if we're not valid before placing the credentials
// in the m_AWSAuthSigner
bool m_missingCredentials{ false };
/// Called to prepare the request. By default no changes
/// are made to the parameters object. Override to defer the preparation
/// of parameters until running on the job's worker thread,
@@ -278,50 +236,31 @@ namespace AWSCore
/// Called when a request completes without error.
virtual void OnSuccess()
{
if (m_queueOnSuccess)
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onSuccess)
{
m_onSuccess(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
}
/// Called when an error occurs.
virtual void OnFailure()
{
if (m_queueOnFailure)
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onFailure)
{
m_onFailure(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
}
/// Provided so derived functions that do not auto delete can clean up
virtual void DoCleanup()
{
if (m_queueDelete)
{
AZStd::function<void()> callbackHandler = [this]()
{
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
}
/// The URL created by appending the API path to the service URL.
/// The path may contain {param} format parameters. The
/// RequestType::parameters.BuildRequest method is responsible
/// for replacing these parts of the url.
const Aws::String& m_requestUrl;
std::shared_ptr<Aws::Client::AWSAuthV4Signer> m_AWSAuthSigner{ nullptr };
// Passed in configuration contains the AWS Credentials to use. If this request requires credentials
// check in the constructor and set this bool to indicate if we're not valid before placing the credentials
// in the m_AWSAuthSigner
bool m_missingCredentials{ false };
private:
bool BuildRequest(RequestBuilder& request) override
{
@@ -666,13 +605,73 @@ namespace AWSCore
AZ_Printf(logRequestsChannel, "Response Body:\n");
PrintRequestOutput(responseContent);
}
public:
template<class Allocator = AZ::SystemAllocator>
static ServiceRequestJob* Create(OnSuccessFunction onSuccess, OnFailureFunction onFailure = OnFailureFunction{}, IConfig* config = GetDefaultConfig())
{
return azcreate(ServiceRequestJob, (onSuccess, onFailure, config), Allocator);
}
};
/// A derived class that calls lambda functions on job completion.
template<class RequestTraits>
class ServiceRequestJob<RequestTraits>::Function
: public ServiceRequestJob
{
public:
// To use a different allocator, extend this class and use this macro.
AZ_CLASS_ALLOCATOR(Function, AZ::SystemAllocator, 0);
Function(OnSuccessFunction onSuccess, OnFailureFunction onFailure = OnFailureFunction{}, IConfig* config = GetDefaultConfig())
: ServiceRequestJob(false, config) // No auto delete - The Function class will handle it with the DoCleanup() function
, m_onSuccess{ onSuccess }
, m_onFailure{ onFailure }
{
}
private:
void OnSuccess() override
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onSuccess)
{
m_onSuccess(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
void OnFailure() override
{
AZStd::function<void()> callbackHandler = [this]()
{
if (m_onFailure)
{
m_onFailure(this);
}
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
// Code doesn't use auto delete - this ensure things get cleaned up in cases when code can't call success or failure
void DoCleanup() override
{
AZStd::function<void()> callbackHandler = [this]()
{
delete this;
};
AZ::TickBus::QueueFunction(callbackHandler);
}
OnSuccessFunction m_onSuccess;
OnFailureFunction m_onFailure;
};
template<class RequestType>
template<class Allocator>
ServiceRequestJob<RequestType>* ServiceRequestJob<RequestType>::Create(
OnSuccessFunction onSuccess, OnFailureFunction onFailure, IConfig* config)
{
return azcreate(Function, (onSuccess, onFailure, config), Allocator);
}
} // namespace AWSCore