Skip to content

Commit

Permalink
fix doxygen
Browse files Browse the repository at this point in the history
fix observer reset
rename sth in main.cpp
  • Loading branch information
creatorlxd committed Sep 9, 2018
1 parent 81b8eca commit 4b7a8d8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 33 deletions.
10 changes: 5 additions & 5 deletions Doxyfile
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = .\Document\Reference
OUTPUT_DIRECTORY = ./Document/Reference

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -790,7 +790,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = .\Source
INPUT = ./Source

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -873,9 +873,9 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = .\Source\GameEngine\DDSTextureLoader \
.\Source\GameEngine\dxerr \
.\Source\GameEngine\ThirdParty
EXCLUDE = ./Source/GameEngine/DDSTextureLoader \
./Source/GameEngine/dxerr \
./Source/GameEngine/ThirdParty

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
Expand Down
44 changes: 24 additions & 20 deletions Source/GameEngine/Common/Observer.hpp
Expand Up @@ -31,10 +31,10 @@ namespace SpaceGameEngine
class RespondFunction :public std::function<void(T...)>
{
public:
RespondFunction()
inline RespondFunction()
:std::function<void(T...)>([]()->void {})
{}
RespondFunction& operator = (const std::function<void(T...)>& func)
inline RespondFunction& operator = (const std::function<void(T...)>& func)
{
std::function<void(T...)>::operator = (func);
return *this;
Expand All @@ -50,11 +50,11 @@ namespace SpaceGameEngine
{
public:
friend class Observer<T>;
Subject()
inline Subject()
{

}
~Subject()
inline ~Subject()
{
std::lock_guard<std::mutex> locker(m_Mutex);
for (auto i : m_Content)
Expand All @@ -64,12 +64,12 @@ namespace SpaceGameEngine
}
}
private:
void AddObserver(Observer<T>& ob)
inline void AddObserver(Observer<T>& ob)
{
std::lock_guard<std::mutex> locker(m_Mutex);
m_Content.push_back(&ob);
}
void DeleteObserver(Observer<T>& ob)
inline void DeleteObserver(Observer<T>& ob)
{
std::lock_guard<std::mutex> locker(m_Mutex);
auto iter = std::find(m_Content.begin(), m_Content.end(), &ob);
Expand Down Expand Up @@ -109,14 +109,14 @@ SpaceGameEngine::Subject<type>::m_Mutex.unlock();
{
public:
friend class Subject<T>;
Observer()
inline Observer()
{
m_pSubject = nullptr;
}
/*!
@brief 清空观察者的观察对象
*/
void Clear()
inline void Clear()
{
if (m_pSubject)
{
Expand All @@ -128,24 +128,26 @@ SpaceGameEngine::Subject<type>::m_Mutex.unlock();
@brief 重设观察者的观察对象
@param ptr 指向被观察者的指针(可为nullptr)
*/
void Reset(Subject<T>* ptr)
inline void Reset(Subject<T>* ptr)
{
if (ptr&&ptr != m_pSubject)
if (ptr == m_pSubject)
return;
if(ptr)
{
Clear();
m_pSubject = ptr;
m_pSubject->AddObserver(*this);
}
else if (ptr == nullptr)
else
Clear();
}
Observer(Subject<T>* ptr)
inline Observer(Subject<T>* ptr)
{
m_pSubject = ptr;
if (m_pSubject)
m_pSubject->AddObserver(*this);
}
~Observer()
inline ~Observer()
{
Clear();
}
Expand All @@ -171,36 +173,38 @@ class SpaceGameEngine::Observer<type>\
{\
public:\
friend class SpaceGameEngine::Subject<type>;\
Observer<type>()\
inline Observer<type>()\
{\
m_pSubject = nullptr;\
}\
void Clear()\
inline void Clear()\
{\
if (m_pSubject)\
{\
m_pSubject->DeleteObserver(*this);\
m_pSubject = nullptr;\
}\
}\
void Reset(SpaceGameEngine::Subject<type>* ptr)\
inline void Reset(SpaceGameEngine::Subject<type>* ptr)\
{\
if (ptr&&ptr != m_pSubject)\
if (ptr == m_pSubject)\
return;\
if(ptr)\
{\
Clear();\
m_pSubject = ptr;\
m_pSubject->AddObserver(*this);\
}\
else if (ptr == nullptr)\
else\
Clear();\
}\
Observer<type>(SpaceGameEngine::Subject<type>* ptr)\
inline Observer<type>(SpaceGameEngine::Subject<type>* ptr)\
{\
m_pSubject = ptr;\
if (m_pSubject)\
m_pSubject->AddObserver(*this);\
}\
~Observer<type>()\
inline ~Observer<type>()\
{\
Clear();\
}\
Expand Down
16 changes: 8 additions & 8 deletions Source/GameEngine/main.cpp
Expand Up @@ -24,30 +24,30 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
RenderInterface* pRenderInterface = MemoryManager::New<DX11RenderInterface>();
//test
RenderTarget render_target(ViewPort(0, 0, pWindow->GetWindowWidth(), pWindow->GetWindowHeight()));
Observer<Window> WindowConnection(pWindow);
Observer<RenderInterface> RenderInterfaceConnection(pRenderInterface);
WindowConnection.m_RespondStart = [&]() {
Observer<Window> WindowObserver(pWindow);
Observer<RenderInterface> RenderInterfaceObserver(pRenderInterface);
WindowObserver.m_RespondStart = [&]() {
pRenderInterface->Init();
};
WindowConnection.m_RespondRun = [&]() {
WindowObserver.m_RespondRun = [&]() {
pRenderInterface->BeginRender(render_target);
pRenderInterface->EndRender(render_target);
};
WindowConnection.m_RespondResize = [&]() {
WindowObserver.m_RespondResize = [&]() {
if (render_target.m_IfInitialized)
{
pRenderInterface->ResizeRenderTarget(render_target, ViewPort(0, 0, pWindow->GetWindowWidth(), pWindow->GetWindowHeight()));
pRenderInterface->BeginRender(render_target);
pRenderInterface->EndRender(render_target);
}
};
WindowConnection.m_RespondRelease = [&]() {
WindowObserver.m_RespondRelease = [&]() {

};
RenderInterfaceConnection.m_RespondStart = [&]() {
RenderInterfaceObserver.m_RespondStart = [&]() {
pRenderInterface->InitRenderTarget(render_target, pWindow->GetHwnd());
};
RenderInterfaceConnection.m_RespondRelease = [&]() {
RenderInterfaceObserver.m_RespondRelease = [&]() {
pRenderInterface->ReleaseRenderTarget(render_target);
};
//----
Expand Down

0 comments on commit 4b7a8d8

Please sign in to comment.