Component rename to Module
This commit is contained in:
parent
93e97c60c2
commit
72f8fd5e12
|
|
@ -2,7 +2,7 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\kiwano-audio\libraries.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\AudioEngine.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\AudioModule.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\kiwano-audio.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\Sound.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\SoundPlayer.h" />
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano-audio\libraries.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\AudioEngine.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\AudioModule.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\Sound.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\SoundPlayer.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\Transcoder.cpp" />
|
||||
|
|
@ -110,4 +110,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
@ -2,17 +2,17 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\kiwano-audio\kiwano-audio.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\AudioEngine.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\Sound.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\SoundPlayer.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\Transcoder.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\libraries.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-audio\AudioModule.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano-audio\AudioEngine.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\Sound.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\SoundPlayer.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\Transcoder.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\libraries.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-audio\AudioModule.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpClient.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpModule.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpRequest.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpResponse.hpp" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\kiwano-network.h" />
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano-network\HttpClient.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-network\HttpModule.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-network\HttpRequest.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\kiwano-network\kiwano-network.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpClient.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpRequest.h" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpResponse.hpp" />
|
||||
<ClInclude Include="..\..\src\kiwano-network\HttpModule.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano-network\HttpClient.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-network\HttpRequest.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano-network\HttpModule.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
<ClInclude Include="..\..\src\kiwano\2d\TextActor.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\2d\Transition.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\AsyncTask.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\Component.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\Module.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\EventDispatcher.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\EventListener.h" />
|
||||
<ClInclude Include="..\..\src\kiwano\core\Logger.h" />
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
<ClCompile Include="..\..\src\kiwano\2d\TextActor.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\2d\Transition.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\AsyncTask.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Component.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Module.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\Director.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\EventDispatcher.cpp" />
|
||||
<ClCompile Include="..\..\src\kiwano\core\EventListener.cpp" />
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@
|
|||
<ClInclude Include="..\..\src\kiwano\2d\Transition.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\Component.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\EventDispatcher.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -303,6 +300,9 @@
|
|||
<ClInclude Include="..\..\src\kiwano\core\Runner.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\kiwano\core\Module.h">
|
||||
<Filter>core</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\kiwano\2d\Canvas.cpp">
|
||||
|
|
@ -386,9 +386,6 @@
|
|||
<ClCompile Include="..\..\src\kiwano\core\ObjectBase.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\Component.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\utils\LocalStorage.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
|
|
@ -512,5 +509,8 @@
|
|||
<ClCompile Include="..\..\src\kiwano\render\Layer.cpp">
|
||||
<Filter>render</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\kiwano\core\Module.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -2312,7 +2312,7 @@ typedef enum {
|
|||
|
||||
|
||||
/*****************************************************************************
|
||||
* SetupComponent defines, protos etc for the sharing stuff.
|
||||
* Setup defines, protos etc for the sharing stuff.
|
||||
*/
|
||||
|
||||
/* Different data locks for a single share */
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano-audio/AudioEngine.h>
|
||||
#include <kiwano-audio/AudioModule.h>
|
||||
#include <kiwano-audio/libraries.h>
|
||||
#include <kiwano/core/Logger.h>
|
||||
#include <kiwano/core/Exception.h>
|
||||
|
|
@ -27,15 +27,15 @@ namespace kiwano
|
|||
{
|
||||
namespace audio
|
||||
{
|
||||
AudioEngine::AudioEngine()
|
||||
AudioModule::AudioModule()
|
||||
: x_audio2_(nullptr)
|
||||
, mastering_voice_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
AudioEngine::~AudioEngine() {}
|
||||
AudioModule::~AudioModule() {}
|
||||
|
||||
void AudioEngine::SetupComponent()
|
||||
void AudioModule::SetupModule()
|
||||
{
|
||||
KGE_SYS_LOG("Creating audio resources");
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ void AudioEngine::SetupComponent()
|
|||
ThrowIfFailed(hr, "Create audio resources failed");
|
||||
}
|
||||
|
||||
void AudioEngine::DestroyComponent()
|
||||
void AudioModule::DestroyModule()
|
||||
{
|
||||
KGE_SYS_LOG("Destroying audio resources");
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ void AudioEngine::DestroyComponent()
|
|||
dlls::MediaFoundation::Get().MFShutdown();
|
||||
}
|
||||
|
||||
bool AudioEngine::CreateSound(Sound& sound, const Transcoder::Buffer& buffer)
|
||||
bool AudioModule::CreateSound(Sound& sound, const Transcoder::Buffer& buffer)
|
||||
{
|
||||
KGE_ASSERT(x_audio2_ && "AudioEngine hasn't been initialized!");
|
||||
KGE_ASSERT(x_audio2_ && "AudioModule hasn't been initialized!");
|
||||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
|
|
@ -109,17 +109,17 @@ bool AudioEngine::CreateSound(Sound& sound, const Transcoder::Buffer& buffer)
|
|||
return true;
|
||||
}
|
||||
|
||||
void AudioEngine::Open()
|
||||
void AudioModule::Open()
|
||||
{
|
||||
KGE_ASSERT(x_audio2_ && "AudioEngine hasn't been initialized!");
|
||||
KGE_ASSERT(x_audio2_ && "AudioModule hasn't been initialized!");
|
||||
|
||||
if (x_audio2_)
|
||||
x_audio2_->StartEngine();
|
||||
}
|
||||
|
||||
void AudioEngine::Close()
|
||||
void AudioModule::Close()
|
||||
{
|
||||
KGE_ASSERT(x_audio2_ && "AudioEngine hasn't been initialized!");
|
||||
KGE_ASSERT(x_audio2_ && "AudioModule hasn't been initialized!");
|
||||
|
||||
if (x_audio2_)
|
||||
x_audio2_->StopEngine();
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
#include <kiwano-audio/Sound.h>
|
||||
#include <kiwano-audio/Transcoder.h>
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
#include <xaudio2.h>
|
||||
|
||||
namespace kiwano
|
||||
|
|
@ -32,7 +32,7 @@ namespace audio
|
|||
|
||||
/**
|
||||
* \~chinese
|
||||
* \defgroup Audio 音频引擎
|
||||
* \defgroup Audio 音频模块
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -42,13 +42,13 @@ namespace audio
|
|||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 音频引擎
|
||||
* @brief 音频模块
|
||||
*/
|
||||
class KGE_API AudioEngine
|
||||
: public Singleton<AudioEngine>
|
||||
, public ComponentBase
|
||||
class KGE_API AudioModule
|
||||
: public Singleton<AudioModule>
|
||||
, public Module
|
||||
{
|
||||
friend Singleton<AudioEngine>;
|
||||
friend Singleton<AudioModule>;
|
||||
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
@ -64,14 +64,14 @@ public:
|
|||
bool CreateSound(Sound& sound, const Transcoder::Buffer& buffer);
|
||||
|
||||
public:
|
||||
void SetupComponent() override;
|
||||
void SetupModule() override;
|
||||
|
||||
void DestroyComponent() override;
|
||||
void DestroyModule() override;
|
||||
|
||||
private:
|
||||
AudioEngine();
|
||||
AudioModule();
|
||||
|
||||
~AudioEngine();
|
||||
~AudioModule();
|
||||
|
||||
private:
|
||||
IXAudio2* x_audio2_;
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano-audio/AudioEngine.h>
|
||||
#include <kiwano-audio/AudioModule.h>
|
||||
#include <kiwano-audio/Sound.h>
|
||||
#include <kiwano/core/Logger.h>
|
||||
#include <kiwano/platform/FileSystem.h>
|
||||
|
|
@ -83,7 +83,7 @@ bool Sound::Load(String const& file_path)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!AudioEngine::GetInstance().CreateSound(*this, transcoder_.GetBuffer()))
|
||||
if (!AudioModule::GetInstance().CreateSound(*this, transcoder_.GetBuffer()))
|
||||
{
|
||||
Close();
|
||||
return false;
|
||||
|
|
@ -107,7 +107,7 @@ bool Sound::Load(Resource const& res)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!AudioEngine::GetInstance().CreateSound(*this, transcoder_.GetBuffer()))
|
||||
if (!AudioModule::GetInstance().CreateSound(*this, transcoder_.GetBuffer()))
|
||||
{
|
||||
Close();
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace kiwano
|
|||
{
|
||||
namespace audio
|
||||
{
|
||||
class AudioEngine;
|
||||
class AudioModule;
|
||||
|
||||
KGE_DECLARE_SMART_PTR(Sound);
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ KGE_DECLARE_SMART_PTR(Sound);
|
|||
*/
|
||||
class KGE_API Sound : public virtual ObjectBase
|
||||
{
|
||||
friend class AudioEngine;
|
||||
friend class AudioModule;
|
||||
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <kiwano-audio/AudioEngine.h>
|
||||
#include <kiwano-audio/AudioModule.h>
|
||||
#include <kiwano-audio/Sound.h>
|
||||
#include <kiwano-audio/SoundPlayer.h>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ ImGuiModule::ImGuiModule()
|
|||
{
|
||||
}
|
||||
|
||||
void ImGuiModule::SetupComponent()
|
||||
void ImGuiModule::SetupModule()
|
||||
{
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
|
|
@ -58,7 +58,7 @@ void ImGuiModule::SetupComponent()
|
|||
ImGui_Impl_Init();
|
||||
}
|
||||
|
||||
void ImGuiModule::DestroyComponent()
|
||||
void ImGuiModule::DestroyModule()
|
||||
{
|
||||
ImGui_Impl_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
@ -33,18 +33,18 @@ namespace imgui
|
|||
*/
|
||||
class ImGuiModule
|
||||
: public Singleton<ImGuiModule>
|
||||
, public RenderComponent
|
||||
, public UpdateComponent
|
||||
, public EventComponent
|
||||
, public RenderModule
|
||||
, public UpdateModule
|
||||
, public EventModule
|
||||
{
|
||||
friend Singleton<ImGuiModule>;
|
||||
|
||||
public:
|
||||
ImGuiModule();
|
||||
|
||||
void SetupComponent() override;
|
||||
void SetupModule() override;
|
||||
|
||||
void DestroyComponent() override;
|
||||
void DestroyModule() override;
|
||||
|
||||
void BeforeRender() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#include <kiwano/platform/Application.h>
|
||||
#include <kiwano-network/HttpRequest.h>
|
||||
#include <kiwano-network/HttpResponse.hpp>
|
||||
#include <kiwano-network/HttpClient.h>
|
||||
#include <kiwano-network/HttpModule.h>
|
||||
#include <3rd-party/curl/curl.h> // CURL
|
||||
|
||||
namespace
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
bool Init(HttpClient* client, Vector<String> const& headers, String const& url, String* response_data,
|
||||
bool Init(HttpModule* client, Vector<String> const& headers, String const& url, String* response_data,
|
||||
String* response_header, char* error_buffer)
|
||||
{
|
||||
if (!SetOption(CURLOPT_ERRORBUFFER, error_buffer))
|
||||
|
|
@ -132,7 +132,7 @@ public:
|
|||
}
|
||||
|
||||
public:
|
||||
static inline bool GetRequest(HttpClient* client, Vector<String> const& headers, String const& url,
|
||||
static inline bool GetRequest(HttpModule* client, Vector<String> const& headers, String const& url,
|
||||
long* response_code, String* response_data, String* response_header,
|
||||
char* error_buffer)
|
||||
{
|
||||
|
|
@ -141,7 +141,7 @@ public:
|
|||
&& curl.SetOption(CURLOPT_FOLLOWLOCATION, true) && curl.Perform(response_code);
|
||||
}
|
||||
|
||||
static inline bool PostRequest(HttpClient* client, Vector<String> const& headers, String const& url,
|
||||
static inline bool PostRequest(HttpModule* client, Vector<String> const& headers, String const& url,
|
||||
String const& request_data, long* response_code, String* response_data,
|
||||
String* response_header, char* error_buffer)
|
||||
{
|
||||
|
|
@ -151,7 +151,7 @@ public:
|
|||
&& curl.SetOption(CURLOPT_POSTFIELDSIZE, request_data.size()) && curl.Perform(response_code);
|
||||
}
|
||||
|
||||
static inline bool PutRequest(HttpClient* client, Vector<String> const& headers, String const& url,
|
||||
static inline bool PutRequest(HttpModule* client, Vector<String> const& headers, String const& url,
|
||||
String const& request_data, long* response_code, String* response_data,
|
||||
String* response_header, char* error_buffer)
|
||||
{
|
||||
|
|
@ -162,7 +162,7 @@ public:
|
|||
&& curl.SetOption(CURLOPT_POSTFIELDSIZE, request_data.size()) && curl.Perform(response_code);
|
||||
}
|
||||
|
||||
static inline bool DeleteRequest(HttpClient* client, Vector<String> const& headers, String const& url,
|
||||
static inline bool DeleteRequest(HttpModule* client, Vector<String> const& headers, String const& url,
|
||||
long* response_code, String* response_data, String* response_header,
|
||||
char* error_buffer)
|
||||
{
|
||||
|
|
@ -182,26 +182,26 @@ namespace kiwano
|
|||
{
|
||||
namespace network
|
||||
{
|
||||
HttpClient::HttpClient()
|
||||
HttpModule::HttpModule()
|
||||
: timeout_for_connect_(30000 /* 30 seconds */)
|
||||
, timeout_for_read_(60000 /* 60 seconds */)
|
||||
{
|
||||
}
|
||||
|
||||
void HttpClient::SetupComponent()
|
||||
void HttpModule::SetupModule()
|
||||
{
|
||||
::curl_global_init(CURL_GLOBAL_ALL);
|
||||
|
||||
std::thread thread(Closure(this, &HttpClient::NetworkThread));
|
||||
std::thread thread(Closure(this, &HttpModule::NetworkThread));
|
||||
thread.detach();
|
||||
}
|
||||
|
||||
void HttpClient::DestroyComponent()
|
||||
void HttpModule::DestroyModule()
|
||||
{
|
||||
::curl_global_cleanup();
|
||||
}
|
||||
|
||||
void HttpClient::Send(HttpRequestPtr request)
|
||||
void HttpModule::Send(HttpRequestPtr request)
|
||||
{
|
||||
if (!request)
|
||||
return;
|
||||
|
|
@ -213,7 +213,7 @@ void HttpClient::Send(HttpRequestPtr request)
|
|||
sleep_condition_.notify_one();
|
||||
}
|
||||
|
||||
void HttpClient::NetworkThread()
|
||||
void HttpModule::NetworkThread()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -235,11 +235,11 @@ void HttpClient::NetworkThread()
|
|||
response_queue_.push(response);
|
||||
response_mutex_.unlock();
|
||||
|
||||
Application::GetInstance().PreformInMainThread(Closure(this, &HttpClient::DispatchResponseCallback));
|
||||
Application::GetInstance().PreformInMainThread(Closure(this, &HttpModule::DispatchResponseCallback));
|
||||
}
|
||||
}
|
||||
|
||||
void HttpClient::Perform(HttpRequestPtr request, HttpResponsePtr response)
|
||||
void HttpModule::Perform(HttpRequestPtr request, HttpResponsePtr response)
|
||||
{
|
||||
bool ok = false;
|
||||
long response_code = 0;
|
||||
|
|
@ -273,7 +273,7 @@ void HttpClient::Perform(HttpRequestPtr request, HttpResponsePtr response)
|
|||
ok = Curl::DeleteRequest(this, headers, url, &response_code, &response_data, &response_header, error_message);
|
||||
break;
|
||||
default:
|
||||
KGE_ERROR("HttpClient: unknown request type, only GET, POST, PUT or DELETE is supported");
|
||||
KGE_ERROR("HttpModule: unknown request type, only GET, POST, PUT or DELETE is supported");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ void HttpClient::Perform(HttpRequestPtr request, HttpResponsePtr response)
|
|||
}
|
||||
}
|
||||
|
||||
void HttpClient::DispatchResponseCallback()
|
||||
void HttpModule::DispatchResponseCallback()
|
||||
{
|
||||
HttpResponsePtr response;
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
#pragma once
|
||||
#include <condition_variable>
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace kiwano
|
||||
|
|
@ -40,13 +40,13 @@ namespace network
|
|||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief HTTP客户端
|
||||
* @brief HTTP模块
|
||||
*/
|
||||
class KGE_API HttpClient
|
||||
: public Singleton<HttpClient>
|
||||
, public ComponentBase
|
||||
class KGE_API HttpModule
|
||||
: public Singleton<HttpModule>
|
||||
, public Module
|
||||
{
|
||||
friend Singleton<HttpClient>;
|
||||
friend Singleton<HttpModule>;
|
||||
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
@ -80,12 +80,12 @@ public:
|
|||
String const& GetSSLVerification() const;
|
||||
|
||||
public:
|
||||
virtual void SetupComponent() override;
|
||||
virtual void SetupModule() override;
|
||||
|
||||
virtual void DestroyComponent() override;
|
||||
virtual void DestroyModule() override;
|
||||
|
||||
private:
|
||||
HttpClient();
|
||||
HttpModule();
|
||||
|
||||
void NetworkThread();
|
||||
|
||||
|
|
@ -110,32 +110,32 @@ private:
|
|||
|
||||
/** @} */
|
||||
|
||||
inline void HttpClient::SetTimeoutForConnect(Duration timeout)
|
||||
inline void HttpModule::SetTimeoutForConnect(Duration timeout)
|
||||
{
|
||||
timeout_for_connect_ = timeout;
|
||||
}
|
||||
|
||||
inline Duration HttpClient::GetTimeoutForConnect() const
|
||||
inline Duration HttpModule::GetTimeoutForConnect() const
|
||||
{
|
||||
return timeout_for_connect_;
|
||||
}
|
||||
|
||||
inline void HttpClient::SetTimeoutForRead(Duration timeout)
|
||||
inline void HttpModule::SetTimeoutForRead(Duration timeout)
|
||||
{
|
||||
timeout_for_read_ = timeout;
|
||||
}
|
||||
|
||||
inline Duration HttpClient::GetTimeoutForRead() const
|
||||
inline Duration HttpModule::GetTimeoutForRead() const
|
||||
{
|
||||
return timeout_for_read_;
|
||||
}
|
||||
|
||||
inline void HttpClient::SetSSLVerification(String const& root_certificate_path)
|
||||
inline void HttpModule::SetSSLVerification(String const& root_certificate_path)
|
||||
{
|
||||
ssl_verification_ = root_certificate_path;
|
||||
}
|
||||
|
||||
inline String const& HttpClient::GetSSLVerification() const
|
||||
inline String const& HttpModule::GetSSLVerification() const
|
||||
{
|
||||
return ssl_verification_;
|
||||
}
|
||||
|
|
@ -22,4 +22,4 @@
|
|||
|
||||
#include <kiwano-network/HttpRequest.h>
|
||||
#include <kiwano-network/HttpResponse.hpp>
|
||||
#include <kiwano-network/HttpClient.h>
|
||||
#include <kiwano-network/HttpModule.h>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
#include <kiwano/2d/Actor.h>
|
||||
#include <kiwano/2d/Stage.h>
|
||||
#include <kiwano/2d/Transition.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
@ -34,9 +34,9 @@ namespace kiwano
|
|||
*/
|
||||
class KGE_API Director
|
||||
: public Singleton<Director>
|
||||
, public UpdateComponent
|
||||
, public RenderComponent
|
||||
, public EventComponent
|
||||
, public UpdateModule
|
||||
, public RenderModule
|
||||
, public EventModule
|
||||
{
|
||||
friend Singleton<Director>;
|
||||
|
||||
|
|
@ -92,9 +92,9 @@ public:
|
|||
void ClearStages();
|
||||
|
||||
public:
|
||||
void SetupComponent() override {}
|
||||
void SetupModule() override {}
|
||||
|
||||
void DestroyComponent() override {}
|
||||
void DestroyModule() override {}
|
||||
|
||||
void OnUpdate(Duration dt) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,39 +18,29 @@
|
|||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include <kiwano/core/Component.h>
|
||||
|
||||
#define KGE_DEFINE_COMPONENT_FLAG(OFFSET) (0x01 << (OFFSET % 32))
|
||||
#include <kiwano/core/Module.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
const int RenderComponent::flag = KGE_DEFINE_COMPONENT_FLAG(0);
|
||||
const int UpdateComponent::flag = KGE_DEFINE_COMPONENT_FLAG(1);
|
||||
const int EventComponent::flag = KGE_DEFINE_COMPONENT_FLAG(2);
|
||||
|
||||
ComponentBase::ComponentBase()
|
||||
Module::Module()
|
||||
: flag_(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool ComponentBase::Check(const int flag)
|
||||
RenderModule::RenderModule()
|
||||
{
|
||||
return !!(flag_ & flag);
|
||||
flag_ |= ModuleFlag<RenderModule>::value;
|
||||
}
|
||||
|
||||
RenderComponent::RenderComponent()
|
||||
UpdateModule::UpdateModule()
|
||||
{
|
||||
flag_ |= flag;
|
||||
flag_ |= ModuleFlag<UpdateModule>::value;
|
||||
}
|
||||
|
||||
UpdateComponent::UpdateComponent()
|
||||
EventModule::EventModule()
|
||||
{
|
||||
flag_ |= flag;
|
||||
}
|
||||
|
||||
EventComponent::EventComponent()
|
||||
{
|
||||
flag_ |= flag;
|
||||
flag_ |= ModuleFlag<EventModule>::value;
|
||||
}
|
||||
|
||||
} // namespace kiwano
|
||||
|
|
@ -20,32 +20,40 @@
|
|||
|
||||
#pragma once
|
||||
#include <kiwano/core/Time.h>
|
||||
#include <kiwano/macros.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
class RenderContext;
|
||||
class Event;
|
||||
|
||||
template <typename _CompTy>
|
||||
struct ModuleFlag;
|
||||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 基础功能组件
|
||||
* @brief 基础模块
|
||||
*/
|
||||
class KGE_API ComponentBase
|
||||
class KGE_API Module
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
/// @brief 启动组件
|
||||
virtual void SetupComponent() = 0;
|
||||
/// @brief 启动模块
|
||||
virtual void SetupModule() {}
|
||||
|
||||
/// \~chinese
|
||||
/// @brief 销毁组件
|
||||
virtual void DestroyComponent() = 0;
|
||||
/// @brief 销毁模块
|
||||
virtual void DestroyModule() {}
|
||||
|
||||
bool Check(const int flag);
|
||||
template <typename _CompTy>
|
||||
_CompTy* Cast()
|
||||
{
|
||||
if (flag_ & ModuleFlag<_CompTy>::value)
|
||||
return dynamic_cast<_CompTy*>(this);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
ComponentBase();
|
||||
Module();
|
||||
|
||||
protected:
|
||||
int flag_;
|
||||
|
|
@ -53,9 +61,9 @@ protected:
|
|||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 渲染支持组件
|
||||
* @brief 渲染模块
|
||||
*/
|
||||
class KGE_API RenderComponent : public virtual ComponentBase
|
||||
class KGE_API RenderModule : public virtual Module
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
@ -72,16 +80,14 @@ public:
|
|||
virtual void AfterRender() {}
|
||||
|
||||
public:
|
||||
static const int flag;
|
||||
|
||||
RenderComponent();
|
||||
RenderModule();
|
||||
};
|
||||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 更新支持组件
|
||||
* @brief 更新模块
|
||||
*/
|
||||
class KGE_API UpdateComponent : public virtual ComponentBase
|
||||
class KGE_API UpdateModule : public virtual Module
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
@ -98,16 +104,14 @@ public:
|
|||
virtual void AfterUpdate() {}
|
||||
|
||||
public:
|
||||
static const int flag;
|
||||
|
||||
UpdateComponent();
|
||||
UpdateModule();
|
||||
};
|
||||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 事件支持组件
|
||||
* @brief 事件模块
|
||||
*/
|
||||
class KGE_API EventComponent : public virtual ComponentBase
|
||||
class KGE_API EventModule : public virtual Module
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
@ -116,8 +120,29 @@ public:
|
|||
virtual void HandleEvent(Event* evt) {}
|
||||
|
||||
public:
|
||||
static const int flag;
|
||||
|
||||
EventComponent();
|
||||
EventModule();
|
||||
};
|
||||
|
||||
#define KGE_DEFINE_COMPONENT_FLAG(OFFSET) (0x01 << (OFFSET % 32))
|
||||
|
||||
template <>
|
||||
struct ModuleFlag<RenderModule>
|
||||
{
|
||||
static constexpr int value = KGE_DEFINE_COMPONENT_FLAG(0);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ModuleFlag<UpdateModule>
|
||||
{
|
||||
static constexpr int value = KGE_DEFINE_COMPONENT_FLAG(1);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ModuleFlag<EventModule>
|
||||
{
|
||||
static constexpr int value = KGE_DEFINE_COMPONENT_FLAG(2);
|
||||
};
|
||||
|
||||
#undef KGE_DEFINE_COMPONENT_FLAG
|
||||
|
||||
} // namespace kiwano
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/macros.h>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,19 +32,19 @@ Application::Application()
|
|||
: quiting_(false)
|
||||
, time_scale_(1.f)
|
||||
{
|
||||
Use(&Renderer::GetInstance());
|
||||
Use(&Input::GetInstance());
|
||||
Use(&Director::GetInstance());
|
||||
Use(Renderer::GetInstance());
|
||||
Use(Input::GetInstance());
|
||||
Use(Director::GetInstance());
|
||||
}
|
||||
|
||||
Application::~Application() {}
|
||||
|
||||
void Application::Run(Runner& runner, bool debug)
|
||||
{
|
||||
// Setup all components
|
||||
for (auto c : comps_)
|
||||
// Setup all modules
|
||||
for (auto c : modules_)
|
||||
{
|
||||
c->SetupComponent();
|
||||
c->SetupModule();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
|
|
@ -100,35 +100,22 @@ void Application::Destroy()
|
|||
ResourceCache::GetInstance().Clear();
|
||||
TextureCache::GetInstance().Clear();
|
||||
|
||||
for (auto iter = comps_.rbegin(); iter != comps_.rend(); ++iter)
|
||||
for (auto iter = modules_.rbegin(); iter != modules_.rend(); ++iter)
|
||||
{
|
||||
(*iter)->DestroyComponent();
|
||||
(*iter)->DestroyModule();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::Use(ComponentBase* component)
|
||||
void Application::Use(Module& module)
|
||||
{
|
||||
if (component)
|
||||
{
|
||||
|
||||
#if defined(KGE_DEBUG)
|
||||
if (std::find(comps_.begin(), comps_.end(), component) != comps_.end())
|
||||
{
|
||||
KGE_ASSERT(false && "Component already exists!");
|
||||
}
|
||||
if (std::find(modules_.begin(), modules_.end(), &module) != modules_.end())
|
||||
{
|
||||
KGE_ASSERT(false && "Module already exists!");
|
||||
}
|
||||
#endif
|
||||
|
||||
comps_.push_back(component);
|
||||
|
||||
if (component->Check(RenderComponent::flag))
|
||||
render_comps_.push_back(dynamic_cast<RenderComponent*>(component));
|
||||
|
||||
if (component->Check(UpdateComponent::flag))
|
||||
update_comps_.push_back(dynamic_cast<UpdateComponent*>(component));
|
||||
|
||||
if (component->Check(EventComponent::flag))
|
||||
event_comps_.push_back(dynamic_cast<EventComponent*>(component));
|
||||
}
|
||||
modules_.push_back(&module);
|
||||
}
|
||||
|
||||
void Application::SetTimeScale(float scale_factor)
|
||||
|
|
@ -139,9 +126,12 @@ void Application::SetTimeScale(float scale_factor)
|
|||
void Application::Update()
|
||||
{
|
||||
// Before update
|
||||
for (auto c : update_comps_)
|
||||
for (auto comp : modules_)
|
||||
{
|
||||
c->BeforeUpdate();
|
||||
if (auto update_comp = comp->Cast<UpdateModule>())
|
||||
{
|
||||
update_comp->BeforeUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
// perform functions
|
||||
|
|
@ -171,16 +161,22 @@ void Application::Update()
|
|||
|
||||
last_update_time_ = now;
|
||||
|
||||
for (auto c : update_comps_)
|
||||
for (auto comp : modules_)
|
||||
{
|
||||
c->OnUpdate(dt);
|
||||
if (auto update_comp = comp->Cast<UpdateModule>())
|
||||
{
|
||||
update_comp->OnUpdate(dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After update
|
||||
for (auto rit = update_comps_.rbegin(); rit != update_comps_.rend(); ++rit)
|
||||
for (auto rit = modules_.rbegin(); rit != modules_.rend(); ++rit)
|
||||
{
|
||||
(*rit)->AfterUpdate();
|
||||
if (auto update_comp = (*rit)->Cast<UpdateModule>())
|
||||
{
|
||||
update_comp->AfterUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -190,23 +186,32 @@ void Application::Render()
|
|||
renderer.Clear();
|
||||
|
||||
// Before render
|
||||
for (auto c : render_comps_)
|
||||
for (auto comp : modules_)
|
||||
{
|
||||
c->BeforeRender();
|
||||
if (auto render_comp = comp->Cast<RenderModule>())
|
||||
{
|
||||
render_comp->BeforeRender();
|
||||
}
|
||||
}
|
||||
|
||||
// Rendering
|
||||
renderer.BeginDraw();
|
||||
for (auto c : render_comps_)
|
||||
for (auto comp : modules_)
|
||||
{
|
||||
c->OnRender(renderer.GetContext());
|
||||
if (auto render_comp = comp->Cast<RenderModule>())
|
||||
{
|
||||
render_comp->OnRender(renderer.GetContext());
|
||||
}
|
||||
}
|
||||
renderer.EndDraw();
|
||||
|
||||
// After render
|
||||
for (auto rit = render_comps_.rbegin(); rit != render_comps_.rend(); ++rit)
|
||||
for (auto rit = modules_.rbegin(); rit != modules_.rend(); ++rit)
|
||||
{
|
||||
(*rit)->AfterRender();
|
||||
if (auto render_comp = (*rit)->Cast<RenderModule>())
|
||||
{
|
||||
render_comp->AfterRender();
|
||||
}
|
||||
}
|
||||
|
||||
renderer.Present();
|
||||
|
|
@ -214,9 +219,12 @@ void Application::Render()
|
|||
|
||||
void Application::DispatchEvent(Event* evt)
|
||||
{
|
||||
for (auto c : event_comps_)
|
||||
for (auto comp : modules_)
|
||||
{
|
||||
c->HandleEvent(evt);
|
||||
if (auto event_comp = comp->Cast<EventModule>())
|
||||
{
|
||||
event_comp->HandleEvent(evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#pragma once
|
||||
#include <mutex>
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
#include <kiwano/core/Time.h>
|
||||
#include <kiwano/core/Runner.h>
|
||||
#include <kiwano/core/Singleton.h>
|
||||
|
|
@ -67,10 +67,10 @@ public:
|
|||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 添加功能组件
|
||||
* @param[in] component 功能组件
|
||||
* @brief 添加模块
|
||||
* @param[in] module 模块
|
||||
*/
|
||||
void Use(ComponentBase* component);
|
||||
void Use(Module& module);
|
||||
|
||||
/**
|
||||
* \~chinese
|
||||
|
|
@ -84,7 +84,7 @@ public:
|
|||
/**
|
||||
* \~chinese
|
||||
* @brief 分发事件
|
||||
* @details 将事件分发给所有事件功能组件
|
||||
* @details 将事件分发给所有事件功能模块
|
||||
* @param evt 事件
|
||||
*/
|
||||
void DispatchEvent(Event* evt);
|
||||
|
|
@ -100,26 +100,23 @@ public:
|
|||
private:
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 更新所有组件
|
||||
* @brief 更新所有模块
|
||||
*/
|
||||
void Update();
|
||||
|
||||
/**
|
||||
* \~chinese
|
||||
* @brief 渲染所有组件
|
||||
* @brief 渲染所有模块
|
||||
*/
|
||||
void Render();
|
||||
|
||||
private:
|
||||
bool quiting_;
|
||||
float time_scale_;
|
||||
Time last_update_time_;
|
||||
Vector<ComponentBase*> comps_;
|
||||
Vector<RenderComponent*> render_comps_;
|
||||
Vector<UpdateComponent*> update_comps_;
|
||||
Vector<EventComponent*> event_comps_;
|
||||
std::mutex perform_mutex_;
|
||||
Queue<Function<void()>> functions_to_perform_;
|
||||
bool quiting_;
|
||||
float time_scale_;
|
||||
Time last_update_time_;
|
||||
List<Module*> modules_;
|
||||
std::mutex perform_mutex_;
|
||||
Queue<Function<void()>> functions_to_perform_;
|
||||
};
|
||||
|
||||
} // namespace kiwano
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include <kiwano/core/Common.h>
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
#include <kiwano/core/Keys.h>
|
||||
#include <kiwano/core/event/Event.h>
|
||||
#include <kiwano/macros.h>
|
||||
|
|
@ -34,8 +34,8 @@ namespace kiwano
|
|||
*/
|
||||
class KGE_API Input
|
||||
: public Singleton<Input>
|
||||
, public UpdateComponent
|
||||
, public EventComponent
|
||||
, public UpdateModule
|
||||
, public EventModule
|
||||
{
|
||||
friend Singleton<Input>;
|
||||
|
||||
|
|
@ -103,9 +103,9 @@ public:
|
|||
Point GetMousePos() const;
|
||||
|
||||
public:
|
||||
void SetupComponent() override {}
|
||||
void SetupModule() override {}
|
||||
|
||||
void DestroyComponent() override {}
|
||||
void DestroyModule() override {}
|
||||
|
||||
void AfterUpdate() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ RendererImpl::RendererImpl()
|
|||
render_ctx_ = new RenderContextImpl;
|
||||
}
|
||||
|
||||
void RendererImpl::SetupComponent()
|
||||
void RendererImpl::SetupModule()
|
||||
{
|
||||
KGE_SYS_LOG("Creating device resources");
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ void RendererImpl::SetupComponent()
|
|||
ThrowIfFailed(hr, "Create render resources failed");
|
||||
}
|
||||
|
||||
void RendererImpl::DestroyComponent()
|
||||
void RendererImpl::DestroyModule()
|
||||
{
|
||||
KGE_SYS_LOG("Destroying device resources");
|
||||
|
||||
|
|
|
|||
|
|
@ -103,9 +103,9 @@ public:
|
|||
ID3DDeviceResources* GetD3DDeviceResources();
|
||||
|
||||
public:
|
||||
void SetupComponent() override;
|
||||
void SetupModule() override;
|
||||
|
||||
void DestroyComponent() override;
|
||||
void DestroyModule() override;
|
||||
|
||||
void HandleEvent(Event* evt) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <kiwano/core/Component.h>
|
||||
#include <kiwano/core/Module.h>
|
||||
#include <kiwano/render/Font.h>
|
||||
#include <kiwano/render/GifImage.h>
|
||||
#include <kiwano/render/TextStyle.hpp>
|
||||
|
|
@ -43,7 +43,7 @@ namespace kiwano
|
|||
* \~chinese
|
||||
* @brief 渲染器
|
||||
*/
|
||||
class KGE_API Renderer : public EventComponent
|
||||
class KGE_API Renderer : public EventModule
|
||||
{
|
||||
public:
|
||||
/// \~chinese
|
||||
|
|
|
|||
Loading…
Reference in New Issue