diff --git a/2nd Study/Example/Json/Json.vcxproj.filters b/2nd Study/Example/Json/Json.vcxproj.filters deleted file mode 100644 index 39f883c..0000000 --- a/2nd Study/Example/Json/Json.vcxproj.filters +++ /dev/null @@ -1,92 +0,0 @@ - - - - - {25b504ff-5a84-4bd1-bde6-16679e21e450} - - - {d8faf697-314d-410b-b328-8f9272226e00} - - - {0a9371f7-0ceb-44a7-856a-dff242732a25} - - - {febb6c4b-50cf-4b6b-b1ee-f1ac0f0241fa} - - - {78aa2407-f693-415e-91a3-aa6da41f6a6d} - - - {cdbbe9a0-5197-4aa7-ba14-a5cabe3c85ad} - - - - - test - - - test - - - test - - - json\parser - - - json\parser - - - json\parser - - - json\parser - - - json\types - - - json\types - - - json\types - - - - - json - - - json - - - json\parser - - - json\parser - - - json\parser - - - json\parser - - - json\types - - - json\types - - - json\types - - - - - docs\Catch - - - docs\Catch - - - \ No newline at end of file diff --git a/2nd Study/Example/README.md b/2nd Study/Example/README.md index 8c42e25..877cd17 100644 --- a/2nd Study/Example/README.md +++ b/2nd Study/Example/README.md @@ -3,34 +3,28 @@ > ### 작성자 > 박 동하 ( luncliff@gmail.com ) > ### 갱신일 -> 16/08/19 +> 16/09/30 ## 0. 요약 2주차 디자인 패턴 스터디에서 사용하는 패턴들이 반영된 예제 코드입니다. -### `Json` +### - Json + +> 5주차 스터디에서 다시 사용되었습니다. +> 해당 폴더를 확인해주세요. :D + Adpater, Bridge, Prototype 패턴을 적용한 코드 -### `Nana` +### - Nana Composite 패턴을 적용한 코드 -## 1. 의존성 +## 1. 외부 라이브러리 -### 외부 라이브러리 - -#### Catch +### - Catch Macro 기반 C++ Testing 라이브러리입니다. 예제코드의 Unit Test를 위해 사용하였습니다. -#### Nana -[Project Home](), [Repo]() +### - Nana +[Project Home](http://nanapro.org/en-us/), [Repo](https://github.com/cnjinhao/nana) Modern C++를 사용한 GUI 라이브러리입니다. - - -## 2. 코드 설명 - -### `Json` - - -### `Nana` diff --git a/2nd Study/Week2.pptx b/2nd Study/Week2.pptx index cf33997..c08d4f7 100644 Binary files a/2nd Study/Week2.pptx and b/2nd Study/Week2.pptx differ diff --git a/5th Study/Example/.gitattributes b/5th Study/Example/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/5th Study/Example/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/5th Study/Example/.gitignore b/5th Study/Example/.gitignore new file mode 100644 index 0000000..6c5009c --- /dev/null +++ b/5th Study/Example/.gitignore @@ -0,0 +1,301 @@ + +# Created by https://www.gitignore.io/api/visualstudio,visualstudiocode,c++ + +### Project Library ### +lib/bin/ + + +### VisualStudioCode ### +.vscode + + + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml diff --git a/5th Study/Example/Example.sln b/5th Study/Example/Example.sln new file mode 100644 index 0000000..6509c68 --- /dev/null +++ b/5th Study/Example/Example.sln @@ -0,0 +1,64 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{434EF148-FBDC-48F7-B16D-096B71E2559A}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + README.md = README.md + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Observer", "Observer\Observer.vcxproj", "{992FA038-9497-4951-B1AF-5F0F700741C1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "State", "State\State.vcxproj", "{02ED96A0-3ACD-4887-8E62-90E0C027DE4E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mediator", "Mediator\Mediator.vcxproj", "{7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Memento", "Memento\Memento.vcxproj", "{FFCFF21C-0705-46C9-BAAD-30A579F5F60F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {992FA038-9497-4951-B1AF-5F0F700741C1}.Debug|x64.ActiveCfg = Debug|x64 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Debug|x64.Build.0 = Debug|x64 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Debug|x86.ActiveCfg = Debug|Win32 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Debug|x86.Build.0 = Debug|Win32 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Release|x64.ActiveCfg = Release|x64 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Release|x64.Build.0 = Release|x64 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Release|x86.ActiveCfg = Release|Win32 + {992FA038-9497-4951-B1AF-5F0F700741C1}.Release|x86.Build.0 = Release|Win32 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Debug|x64.ActiveCfg = Debug|x64 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Debug|x64.Build.0 = Debug|x64 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Debug|x86.ActiveCfg = Debug|Win32 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Debug|x86.Build.0 = Debug|Win32 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Release|x64.ActiveCfg = Release|x64 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Release|x64.Build.0 = Release|x64 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Release|x86.ActiveCfg = Release|Win32 + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E}.Release|x86.Build.0 = Release|Win32 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Debug|x64.ActiveCfg = Debug|x64 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Debug|x64.Build.0 = Debug|x64 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Debug|x86.ActiveCfg = Debug|Win32 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Debug|x86.Build.0 = Debug|Win32 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Release|x64.ActiveCfg = Release|x64 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Release|x64.Build.0 = Release|x64 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Release|x86.ActiveCfg = Release|Win32 + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7}.Release|x86.Build.0 = Release|Win32 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Debug|x64.ActiveCfg = Debug|x64 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Debug|x64.Build.0 = Debug|x64 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Debug|x86.ActiveCfg = Debug|Win32 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Debug|x86.Build.0 = Debug|Win32 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Release|x64.ActiveCfg = Release|x64 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Release|x64.Build.0 = Release|x64 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Release|x86.ActiveCfg = Release|Win32 + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/5th Study/Example/Gomoku/Gomoku.cpp b/5th Study/Example/Gomoku/Gomoku.cpp new file mode 100644 index 0000000..b85f9e1 --- /dev/null +++ b/5th Study/Example/Gomoku/Gomoku.cpp @@ -0,0 +1,102 @@ + +// Gomoku.cpp : ���� ���α��� ���� Ŭ���� ������ �����մΘ�. +// + +#include "stdafx.h" +#include "Gomoku.h" +#include "GomokuDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CGomokuApp + +BEGIN_MESSAGE_MAP(CGomokuApp, CWinApp) + ON_COMMAND(ID_HELP, &CWinApp::OnHelp) +END_MESSAGE_MAP() + + +// CGomokuApp ���� + +CGomokuApp::CGomokuApp() +{ + // �ٽ� ���� ������ ���� + m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; + + // TODO: ��� ���� �ڵ带 �߰��մΘ�. + // InitInstance�� ���� �߿��� �ɦ�ȭ �۾��� ��ġ�մΘ�. +} + + +// ������ CGomokuApp ��ü�ԴΘ�. + +CGomokuApp theApp; + + +// CGomokuApp �ɦ�ȭ + +BOOL CGomokuApp::InitInstance() +{ + // ���� ���α� �Ŵ��佺Ʈ�� ComCtl32.dll ���� 6 �̻��� �����Ͽ� ���־� ��Ÿ���� + // �����ε��� �����Θ� ����, Windows XP �� �ݵ��� InitCommonControlsEx()�� �ʿ��մΘ�. + // InitCommonControlsEx()�� �������� ������ â�� ���� �� �����Θ�. + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // ���� ���α����� ������ ���� ���� ��Ʈ�� Ŭ������ �����ε��� + // �� ���� �����Ͻʽÿ�. + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + CWinApp::InitInstance(); + + + AfxEnableControlContainer(); + + // ��ȭ ���ڿ� �� Ʈ�� �� �Ǵ� + // �� ���� �� ��Ʈ���� ���ԵǾ� �ִ� ���� �� �����ڸ� �����Θ�. + CShellManager *pShellManager = new CShellManager; + + // MFC ��Ʈ���� ���� �����ρ� ���� "Windows ����" ���־� ������ Ȱ��ȭ + CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); + + // ǥ�� �ɦ�ȭ + // �̵� ������ �������� �h� ���� ���� ������ ũ�⸦ ���̷��� + // �Ʒ����� �ʿ� ���� Ư�� �ɦ�ȭ + // ��ƾ�� �����ؾ� �մΘ�. + // �ش� ������ ������ ������Ʈ�� Ű�� �����Ͻʽÿ�. + // TODO: �� ���ڿ��� ȸ�� �Ǵ� ������ �̸��� ���� + // ������ �������� �����ؾ� �մΘ�. + SetRegistryKey(_T("���� ���� ���α� �����翡�� ������ ���� ���α�")); + + CGomokuDlg dlg; + m_pMainWnd = &dlg; + INT_PTR nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: ��� [Ȯ��]�� Ŭ���Ͽ� ��ȭ ���ڰ� ������ �� ó���� + // �ڵ带 ��ġ�մΘ�. + } + else if (nResponse == IDCANCEL) + { + // TODO: ��� [����]�� Ŭ���Ͽ� ��ȭ ���ڰ� ������ �� ó���� + // �ڵ带 ��ġ�մΘ�. + } + else if (nResponse == -1) + { + TRACE(traceAppMsg, 0, "����: ��ȭ ���ڸ� ������ �������Ƿ� ���� ���α��� ����ġ �h� �����˴Θ�.\n"); + TRACE(traceAppMsg, 0, "����: ��ȭ ���ڿ��� MFC ��Ʈ���� �����Θ� ���� #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS�� ������ �� �����Θ�.\n"); + } + + // ������ ���� �� �����ڸ� �����մΘ�. + if (pShellManager != NULL) + { + delete pShellManager; + } + + // ��ȭ ���ڰ� �������Ƿ� ���� ���α��� ���� ������ �������� �h� ���� ���α��� ���� �� �ֵ��� FALSE�� + // ��ȯ�մΘ�. + return FALSE; +} + diff --git a/5th Study/Example/Gomoku/Gomoku.h b/5th Study/Example/Gomoku/Gomoku.h new file mode 100644 index 0000000..c59810b --- /dev/null +++ b/5th Study/Example/Gomoku/Gomoku.h @@ -0,0 +1,32 @@ + +// Gomoku.h : PROJECT_NAME ���� ���α��� ���� �� ���� �����ԴΘ�. +// + +#pragma once + +#ifndef __AFXWIN_H__ + #error "PCH�� ���� �� ������ �����ρ� ���� 'stdafx.h'�� �����մΘ�." +#endif + +#include "resource.h" // �� ��ȣ�ԴΘ�. + + +// CGomokuApp: +// �� Ŭ������ ������ ���ؼ��� Gomoku.cpp�� �����Ͻʽÿ�. +// + +class CGomokuApp : public CWinApp +{ +public: + CGomokuApp(); + +// �������ԴΘ�. +public: + virtual BOOL InitInstance(); + +// �����ԴΘ�. + + DECLARE_MESSAGE_MAP() +}; + +extern CGomokuApp theApp; \ No newline at end of file diff --git a/5th Study/Example/Gomoku/Gomoku.rc b/5th Study/Example/Gomoku/Gomoku.rc new file mode 100644 index 0000000..4281d0d Binary files /dev/null and b/5th Study/Example/Gomoku/Gomoku.rc differ diff --git a/5th Study/Example/Gomoku/Gomoku.vcxproj b/5th Study/Example/Gomoku/Gomoku.vcxproj new file mode 100644 index 0000000..92d86a5 --- /dev/null +++ b/5th Study/Example/Gomoku/Gomoku.vcxproj @@ -0,0 +1,223 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {A34087C1-6585-44FA-9C79-6C96506560A7} + Gomoku + 8.1 + MFCProj + + + + Application + true + v140 + Unicode + Dynamic + + + Application + false + v140 + true + Unicode + Dynamic + + + Application + true + v140 + Unicode + Dynamic + + + Application + false + v140 + true + Unicode + Dynamic + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0412 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Use + Level3 + Disabled + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + Windows + + + false + true + _DEBUG;%(PreprocessorDefinitions) + + + 0x0412 + _DEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0412 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + Level3 + Use + MaxSpeed + true + true + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + Windows + true + true + + + false + true + NDEBUG;%(PreprocessorDefinitions) + + + 0x0412 + NDEBUG;%(PreprocessorDefinitions) + $(IntDir);%(AdditionalIncludeDirectories) + + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/5th Study/Example/Gomoku/Gomoku.vcxproj.filters b/5th Study/Example/Gomoku/Gomoku.vcxproj.filters new file mode 100644 index 0000000..94d322d --- /dev/null +++ b/5th Study/Example/Gomoku/Gomoku.vcxproj.filters @@ -0,0 +1,69 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + 헤더 파일 + + + + + 소스 파일 + + + 소스 파일 + + + 소스 파일 + + + 소스 파일 + + + + + 리소스 파일 + + + + + 리소스 파일 + + + + + 리소스 파일 + + + \ No newline at end of file diff --git a/5th Study/Example/Gomoku/GomokuBoard.cpp b/5th Study/Example/Gomoku/GomokuBoard.cpp new file mode 100644 index 0000000..15e2d5c --- /dev/null +++ b/5th Study/Example/Gomoku/GomokuBoard.cpp @@ -0,0 +1,12 @@ +#include "stdafx.h" +#include "GomokuBoard.h" + +// +//GomokuBoard::GomokuBoard() +//{ +//} +// +// +//GomokuBoard::~GomokuBoard() +//{ +//} diff --git a/5th Study/Example/Gomoku/GomokuBoard.h b/5th Study/Example/Gomoku/GomokuBoard.h new file mode 100644 index 0000000..10b8370 --- /dev/null +++ b/5th Study/Example/Gomoku/GomokuBoard.h @@ -0,0 +1,199 @@ +#pragma once + +#include +#include +#include +#include +using namespace std; + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + +#define GO_BOARD_SIZE 19 + +class GoMemento +{ + friend class GomokuBoard; +public: + GoMemento() + { + for (int i = 0; i < GO_BOARD_SIZE; i++) + for (int j = 0; j < GO_BOARD_SIZE; j++) + board_[i][j] = 0; + + whiteDeadNum_ = blackDeadNum_ = 0; + paePosX_ = paePosY_ = -1; + } + + GoMemento(const GoMemento& rhs) { CopyBoard(rhs); } + GoMemento& operator=(const GoMemento& rhs) { CopyBoard(rhs); } + + void GetOutDeadStone() + { + // -- Ȯ���� ���� ���� ����. + // -- �̶� whiteDeadNum_ �̳� blackDeadNum_ ���� ������ + } + + bool IsPaePosition(int x, int y) + { + // -- x,y ��ġ�� ���̸� true �ǵ��� + return false; + } + +protected: + void CopyBoard(const GoMemento& src) + { + for (int i = 0; i < GO_BOARD_SIZE; i++) + for (int j = 0; j < GO_BOARD_SIZE; j++) + board_[i][j] = src.board_[i][j]; + + whiteDeadNum_ = src.whiteDeadNum_; + blackDeadNum_ = src.blackDeadNum_; + } +private: + // -- 0 �� ������, ������ ��, ������ ��, ���밪�� ���� + int board_[GO_BOARD_SIZE][GO_BOARD_SIZE]; + + int whiteDeadNum_; // -- ���� ���� �� + int blackDeadNum_; // -- ������ ���� �� + + int paePosX_; + int paePosY_; +}; + + + +class GomokuBoard +{ // -- �اٴ��� +public: + GomokuBoard(int firstTurn = -1) + { + pCurBoard_ = nullptr; + whoseTurn_ = firstTurn; + totalStoneNum_ = 0; + bReact = false; + + Init(); + } + + ~GomokuBoard() + { + for (auto iter = historyList_.begin(); iter != historyList_.end(); iter++) + { + delete *iter; + } + + for (auto iter = AfterList_.begin(); iter != AfterList_.end(); iter++) + { + delete *iter; + } + } + + void Init() + { + pCurBoard_ = new GoMemento(); + historyList_.push_front(pCurBoard_); + } + + int GetStone(int x, int y) + { + return pCurBoard_->board_[x][y]; + } + + + void PutStone(int x, int y) + { + if (pCurBoard_->board_[x][y] != 0 || + (pCurBoard_->paePosX_ == x && pCurBoard_->paePosY_ == y)) + { + //cout << "Can't Be Put Stone There." << endl; + return; + } + + GoMemento *pNewBoard = new GoMemento(*pCurBoard_); + + totalStoneNum_++; + pNewBoard->board_[x][y] = whoseTurn_ * totalStoneNum_; + whoseTurn_ *= -1; + if (pCurBoard_->IsPaePosition(x, y)) + { + pCurBoard_->paePosX_ = x; + pCurBoard_->paePosY_ = y; + } + else + { + pCurBoard_->paePosX_ = -1; + pCurBoard_->paePosY_ = -1; + } + + pNewBoard->GetOutDeadStone(); + + historyList_.push_front(pNewBoard); + pCurBoard_ = pNewBoard; + + if (bReact) + { + for (auto iter = AfterList_.begin(); iter != AfterList_.end(); iter++) + { + delete *iter; + } + AfterList_.clear(); + bReact = false; + } + } + + void RetractStone(int cnt) + { + // ------------------------------------------- + // cnt ����ŭ ���� ������. + // �̶� 1���� ������ ���� pCurBoard_ ���� historyList_�� + // ù ���� ��ġ�Θ� �Ͱ� �����Θ�. + // ------------------------------------------- + if (cnt <= 0) return; + + bReact = true; + totalStoneNum_--; + whoseTurn_ *= -1; + if (historyList_.empty()) + { + delete pCurBoard_; + Init(); + } + else + { + GoMemento *pTmpBoard = historyList_.front(); + AfterList_.push_front(pTmpBoard); + + historyList_.pop_front(); + + if (historyList_.empty()) + { + Init(); + } + else + pCurBoard_ = historyList_.front(); + } + } + + void AfterActStone() + { + totalStoneNum_++; + whoseTurn_ *= -1; + + if (AfterList_.empty()) return; + + pCurBoard_ = AfterList_.front(); + AfterList_.pop_front(); + + historyList_.push_front(pCurBoard_); + } + +private: + list historyList_; + list AfterList_; + GoMemento* pCurBoard_; + int whoseTurn_; // -- ���� �� ����(1 �� ��, -1 �� ��) + int totalStoneNum_; + bool bReact; +}; diff --git a/5th Study/Example/Gomoku/GomokuDlg.cpp b/5th Study/Example/Gomoku/GomokuDlg.cpp new file mode 100644 index 0000000..79fbda4 --- /dev/null +++ b/5th Study/Example/Gomoku/GomokuDlg.cpp @@ -0,0 +1,252 @@ + +// GomokuDlg.cpp : ���� ���� +// + +#include "stdafx.h" +#include "Gomoku.h" +#include "GomokuDlg.h" +#include "afxdialogex.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// ���� ���α� ������ �����Ǵ� CAboutDlg ��ȭ �����ԴΘ�. + +class CAboutDlg : public CDialogEx +{ +public: + CAboutDlg(); + +// ��ȭ ���� �������ԴΘ�. +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_ABOUTBOX }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV �����ԴΘ�. + +// �����ԴΘ�. +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) +END_MESSAGE_MAP() + + +// CGomokuDlg ��ȭ ���� + + + +CGomokuDlg::CGomokuDlg(CWnd* pParent /*=NULL*/) + : CDialogEx(IDD_GOMOKU_DIALOG, pParent) +{ + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void CGomokuDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialogEx::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CGomokuDlg, CDialogEx) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_WM_LBUTTONDOWN() + ON_BN_CLICKED(ID_UNDO, &CGomokuDlg::OnBnClickedUndo) + ON_BN_CLICKED(ID_REDO, &CGomokuDlg::OnBnClickedRedo) +END_MESSAGE_MAP() + + +// CGomokuDlg ���� ó���� + +BOOL CGomokuDlg::OnInitDialog() +{ + CDialogEx::OnInitDialog(); + + // �ý��� ���� "����..." �� ���� �߰��մΘ�. + + // IDM_ABOUTBOX�� �ý��� ���� ������ �־��� �մΘ�. + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != NULL) + { + BOOL bNameValid; + CString strAboutMenu; + bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); + ASSERT(bNameValid); + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // �� ��ȭ ������ �������� �����մΘ�. ���� ���α��� �� â�� ��ȭ ���ڰ� �ƴ� ���쿡�� + // �����ӿ�ũ�� �� �۾��� �ڵ����� �����մΘ�. + SetIcon(m_hIcon, TRUE); // ū �������� �����մΘ�. + SetIcon(m_hIcon, FALSE); // ���� �������� �����մΘ�. + + // TODO: ��� �߰� �ɦ�ȭ �۾��� �߰��մΘ�. + + + return TRUE; // ��L·���� ��Ʈ�ѿ� �������� ������ TRUE�� ��ȯ�մΘ�. +} + +void CGomokuDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialogEx::OnSysCommand(nID, lParam); + } +} + +// ��ȭ ���ڿ� �ּ�ȭ ���߸� �߰��� ���� �������� ������ +// �Ʒ� �ڵ尡 �ʿ��մΘ�. ����/�� ������ �����Θ� MFC ���� ���α��� ���쿡�� +// �����ӿ�ũ���� �� �۾��� �ڵ����� �����մΘ�. + +void CGomokuDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // ���⸦ ���� �����̽� ���ؽ�Ʈ�ԴΘ�. + + SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); + + // Ŭ���̾�Ʈ �簢������ �������� ����� �����Θ�. + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // �������� ���Θ�. + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CWnd* pWnd = NULL; + pWnd = GetDlgItem(IDC_STATIC_BOARD); + CDC *pDC = pWnd->GetDC(); + + //�اٴ��� + int x, y; + for (x = 0;xMoveTo(10, 10 + x * 20); + pDC->LineTo(370, 10 + x * 20); + } + for (x = 0;xMoveTo(10 + x * 20, 10); + pDC->LineTo(10 + x * 20, 370); + } + + //�� �� + for (x = 0;x(m_hIcon); +} + + +// x,y ��ǥ�� ���� ����. +void CGomokuDlg::DrawBoard_(CDC *pDC, int x, int y, int dol) +{ + if (dol> 0) // ������ ���� ������ �귯�� + { + pDC->SelectObject(GetStockObject(BLACK_BRUSH)); + pDC->SetTextColor(RGB(255, 255, 255)); // �ؽ�Ʈ �������� ���� + + } + if (dol < 0) + { + pDC->SelectObject(GetStockObject(WHITE_BRUSH)); + pDC->SetTextColor(RGB(0,0,0)); // �ؽ�Ʈ ���������� ���� + } + + if (dol != 0) //���� ������ ���� �ɹ ́�. + { + pDC->Ellipse(x * 20 + 2, y * 20 + 2, x * 20 + 18, y * 20 + 18); + wstring strDol = std::to_wstring(abs(dol)); + pDC->SetBkMode(TRANSPARENT); + + pDC->TextOut(x * 20 + 4, y * 20 + 1 , strDol.c_str(), strDol.length()); + } +} + + +void CGomokuDlg::OnLButtonDown(UINT nFlags, CPoint point) +{ + // TODO: ��� ���� ó���� �ڵ带 �߰� ��/�Ǵ� �⺻���� ȣ���մΘ�. + int ax, ay; + + ax = point.x / 20; //ȭ�� ��ǥ�� �迭 ��ǥ�� ��ȯ�Ѵ�. + ay = point.y / 20; + + //�اٴ��� ���̾��� �κ� ���� ������ �ɹ� �ڸ����� �Ѵ�. + if ((ax<0) || (ax>= GO_BOARD_SIZE) || (ay<0) || (ay>= GO_BOARD_SIZE)) return; + + m_GoBoard.PutStone(ax, ay); + + Invalidate(FALSE); + + CDialogEx::OnLButtonDown(nFlags, point); +} + + +void CGomokuDlg::OnBnClickedUndo() +{ + // TODO: ��� ��Ʈ�� �˸� ó���� �ڵ带 �߰��մΘ�. + m_GoBoard.RetractStone(3); + + Invalidate(); + UpdateWindow(); + Invalidate(FALSE); +} + + +void CGomokuDlg::OnBnClickedRedo() +{ + // TODO: ��� ��Ʈ�� �˸� ó���� �ڵ带 �߰��մΘ�. + + m_GoBoard.AfterActStone(); + Invalidate(); + UpdateWindow(); + Invalidate(FALSE); +} diff --git a/5th Study/Example/Gomoku/GomokuDlg.h b/5th Study/Example/Gomoku/GomokuDlg.h new file mode 100644 index 0000000..43f08fe --- /dev/null +++ b/5th Study/Example/Gomoku/GomokuDlg.h @@ -0,0 +1,45 @@ + +// GomokuDlg.h : ���� ���� +// + +#pragma once + +#include "GomokuBoard.h" +#include + +// CGomokuDlg ��ȭ ���� +class CGomokuDlg : public CDialogEx +{ +// �����ԴΘ�. +public: + CGomokuDlg(CWnd* pParent = NULL); // ǥ�� �������ԴΘ�. + +// ��ȭ ���� �������ԴΘ�. +#ifdef AFX_DESIGN_TIME + enum { IDD = IDD_GOMOKU_DIALOG }; +#endif + + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV �����ԴΘ�. + + +// �����ԴΘ�. +protected: + HICON m_hIcon; + + // ������ ���� �� �Լ� + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnBnClickedUndo(); + DECLARE_MESSAGE_MAP() + + +public: + GomokuBoard m_GoBoard; + + void DrawBoard_(CDC *pDC, int x, int y, int dol); + afx_msg void OnBnClickedRedo(); +}; diff --git a/5th Study/Example/Gomoku/ReadMe.txt b/5th Study/Example/Gomoku/ReadMe.txt new file mode 100644 index 0000000..ef8dfca --- /dev/null +++ b/5th Study/Example/Gomoku/ReadMe.txt @@ -0,0 +1,71 @@ +================================================================================ + MFC 라이브러리 : Gomoku 프로젝트 개요 +=============================================================================== + +응용 프로그램 마법사에서 이 Gomoku 응용 프로그램을 만들었습니다. 이 응용 프로그램은 MFC의 기본 사용법을 보여 줄 뿐만 아니라 응용 프로그램을 작성하기 위한 기본 구조를 제공합니다. + +Gomoku 응용 프로그램을 구성하는 각 파일에 대한 +요약 설명이 포함되어 있습니다. + +Gomoku.vcxproj + 응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다. 파일을 생성한 Visual C++ 버전에 대한 정보와 응용 프로그램 마법사를 사용하여 선택한 플랫폼, 구성 및 프로젝트 기능에 대한 정보가 포함되어 있습니다. + +Gomoku.vcxproj.filters + 응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 필터 파일입니다. 이 파일에는 프로젝트의 파일과 필터 간의 연결 정보가 들어 있습니다. 이러한 연결은 특정 노드에서 유사한 확장명으로 그룹화된 파일을 표시하기 위해 IDE에서 사용됩니다. 예를 들어 ".cpp" 파일은 "소스 파일" 필터와 연결되어 있습니다. + +Gomoku.h + 해당 응용 프로그램의 기본 헤더 파일입니다. + 여기에는 resource.h를 비롯한 다른 프로젝트별 헤더가 포함되어 있으며 CGomokuApp 응용 프로그램 클래스가 선언되어 있습니다. + +Gomoku.cpp + 이는 응용 프로그램 클래스 CGomokuApp가 포함된 기본 응용 프로그램 소스 파일입니다. + +Gomoku.rc + 프로그램에서 사용하는 모든 Microsoft Windows 리소스의 목록입니다. 여기에는 RES 하위 디렉터리에 저장된 아이콘, 비트맵 및 커서가 포함됩니다. 이 파일은 Microsoft Visual C++에서 직접 편집할 수 있습니다. 프로젝트 리소스는 1042에 있습니다. + +res\Gomoku.ico + 아이콘 파일이며, 응용 프로그램의 아이콘으로 사용됩니다. 이 아이콘은 기본 리소스 파일인 Gomoku.rc에 의해 포함됩니다. + +res\Gomoku.rc2 + 이 파일에는 Microsoft Visual C++ 이외의 다른 도구에서 편집한 리소스가 포함되어 있습니다. 리소스 편집기로 편집할 수 없는 모든 리소스는 이 파일에 넣어야 합니다. + + +///////////////////////////////////////////////////////////////////////////// + +응용 프로그램 마법사에서 대화 상자 클래스 하나를 만듭니다. + +GomokuDlg.h, GomokuDlg.cpp - 대화 상자 + 이 파일에는 CGomokuDlg 클래스가 포함됩니다. 이 클래스는 응용 프로그램의 주 대화 상자에 대한 동작을 정의합니다. 이 대화 상자 템플릿은 Gomoku.rc에 있으며, Microsoft Visual C++에서 직접 편집할 수 있습니다. + +///////////////////////////////////////////////////////////////////////////// + +기타 기능: + +ActiveX 컨트롤 + 응용 프로그램이 Active X 컨트롤을 지원합니다. + +인쇄 및 인쇄 미리 보기 지원 + MFC 라이브러리의 CView 클래스에서 멤버 함수를 호출하여 응용 프로그램 마법사에서 인쇄, 인쇄 설정 및 인쇄 미리 보기 명령 코드를 생성할 수 있습니다. + +///////////////////////////////////////////////////////////////////////////// + +기타 표준 파일: + +StdAfx.h, StdAfx.cpp + 이 파일은 미리 컴파일된 헤더(PCH) 파일 Gomoku.pch와 미리 컴파일된 형식(PCT) 파일 StdAfx.obj를 빌드하는 데 사용됩니다. + +Resource.h + 새 리소스 ID를 정의하는 표준 헤더 파일입니다. Microsoft Visual C++에서 이 파일을 읽고 업데이트합니다. + +Gomoku.manifest + 응용 프로그램 매니페스트 파일은 Windows XP에서 특정 버전의 Side-by-Side 어셈블리에 대한 응용 프로그램 종속성을 설명하는 데 사용됩니다. 로더는 이 정보를 통해 어셈블리 캐시 또는 응용 프로그램의 private에서 적절한 어셈블리를 로드합니다. 응용 프로그램 매니페스트는 응용 프로그램 실행 파일과 같은 폴더에 설치된 외부 .manifest 파일 형태로서 재배포용으로 포함되거나, 리소스 형태로 된 실행 파일에 포함될 수 있습니다. +///////////////////////////////////////////////////////////////////////////// + +기타 참고: + +응용 프로그램 마법사에서 사용하는 "TODO:"는 사용자가 추가하거나 사용자 지정해야 하는 소스 코드 부분을 나타냅니다. + +공유된 DLL에서 MFC를 사용하는 응용 프로그램의 경우 MFC DLL을 재배포할 필요가 없습니다. 응용 프로그램에서 운영 체제의 로캘과 다른 언어를 사용하는 경우 이에 해당하는 지역화된 리소스인 mfc110XXX.DLL도 재배포해야 합니다. +이러한 두 항목에 대한 자세한 내용은 MSDN 설명서에 있는 Visual C++ 응용 프로그램 재배포 섹션을 참조하십시오. + +///////////////////////////////////////////////////////////////////////////// diff --git a/5th Study/Example/Gomoku/res/Gomoku.ico b/5th Study/Example/Gomoku/res/Gomoku.ico new file mode 100644 index 0000000..d56fbcd Binary files /dev/null and b/5th Study/Example/Gomoku/res/Gomoku.ico differ diff --git a/5th Study/Example/Gomoku/res/Gomoku.rc2 b/5th Study/Example/Gomoku/res/Gomoku.rc2 new file mode 100644 index 0000000..bf4be7a Binary files /dev/null and b/5th Study/Example/Gomoku/res/Gomoku.rc2 differ diff --git a/5th Study/Example/Gomoku/resource.h b/5th Study/Example/Gomoku/resource.h new file mode 100644 index 0000000..b278d5d Binary files /dev/null and b/5th Study/Example/Gomoku/resource.h differ diff --git a/5th Study/Example/Gomoku/stdafx.cpp b/5th Study/Example/Gomoku/stdafx.cpp new file mode 100644 index 0000000..84e74ed --- /dev/null +++ b/5th Study/Example/Gomoku/stdafx.cpp @@ -0,0 +1,8 @@ + +// stdafx.cpp : ǥ�� ���� ���ϸ� ���� �ִ� �ҽ� �����ԴΘ�. +// Gomoku.pch�� �̸� �����ε� ������ �˴Θ�. +// stdafx.obj���� �̸� �����ε� ���� ������ ���Ե˴Θ�. + +#include "stdafx.h" + + diff --git a/5th Study/Example/Gomoku/stdafx.h b/5th Study/Example/Gomoku/stdafx.h new file mode 100644 index 0000000..443fe4f --- /dev/null +++ b/5th Study/Example/Gomoku/stdafx.h @@ -0,0 +1,54 @@ + +// stdafx.h : ���� ���������� ���� ���������� �ɹ� +// ǥ�� �ý��� ���� ���� �� ������Ʈ ���� ���� ������ +// ���� �ִ� ���� �����ԴΘ�. + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // ���� �������� �ɹ� ������ Windows ����� �����մΘ�. +#endif + +#include "targetver.h" + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // �Ϻ� CString �����ڴ� ���������� �����˴Θ�. + +// MFC�� ���� �κа� ���� ������ ���� ������ ���� �����⸦ �����մΘ�. +#define _AFX_ALL_WARNINGS + +#include // MFC �ٽ� �� ǥ�� ���� �����ԴΘ�. +#include // MFC Ȯ���ԴΘ�. + + +#include // MFC �ڵ�ȭ Ŭ�����ԴΘ�. + + + +#ifndef _AFX_NO_OLE_SUPPORT +#include // Internet Explorer 4 ���� ��Ʈ�ѿ� ���� MFC �����ԴΘ�. +#endif +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // Windows ���� ��Ʈ�ѿ� ���� MFC �����ԴΘ�. +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include // MFC�� ���� �� ��Ʈ�� ���� ���� + + + + + + + + + +#ifdef _UNICODE +#if defined _M_IX86 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") +#elif defined _M_X64 +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") +#else +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#endif +#endif + + diff --git a/5th Study/Example/Gomoku/targetver.h b/5th Study/Example/Gomoku/targetver.h new file mode 100644 index 0000000..3142091 --- /dev/null +++ b/5th Study/Example/Gomoku/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h�� �����ϸ� �ְ� ������ ���뼺�� ���� Windows �÷����� ���ǵ˴Θ�. + +// ���� Windows �÷����� ���� ���� ���α��� �����Ϸ��� ���쿡�� SDKDDKVer.h�� �����ρ� ���� +// WinSDKVer.h�� �����κ� _WIN32_WINNT ��ũ�θ� �����Ϸ��� �÷������� �����Ͻʽÿ�. + +#include diff --git a/5th Study/Example/Mediator/Mediator.vcxproj b/5th Study/Example/Mediator/Mediator.vcxproj new file mode 100644 index 0000000..9ae1829 --- /dev/null +++ b/5th Study/Example/Mediator/Mediator.vcxproj @@ -0,0 +1,117 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {7E1DF6D9-1837-456D-8C44-9E25DFE77EA7} + Mediator + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + \ No newline at end of file diff --git a/5th Study/Example/Mediator/Mediator.vcxproj.filters b/5th Study/Example/Mediator/Mediator.vcxproj.filters new file mode 100644 index 0000000..6a1782f --- /dev/null +++ b/5th Study/Example/Mediator/Mediator.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file diff --git a/5th Study/Example/Memento/ClassDiagram.cd b/5th Study/Example/Memento/ClassDiagram.cd new file mode 100644 index 0000000..5db0a37 --- /dev/null +++ b/5th Study/Example/Memento/ClassDiagram.cd @@ -0,0 +1,18 @@ + + + + + + AAAAACAAAEAAAAAAAAEAAAAAAAAAAACAJQAgAAAAACA= + Memento.cpp + + + + + + AAAAAEAAAAIBIAAAQAAAAAAgQAAAAAAAAAAAAAAAABA= + Memento.cpp + + + + \ No newline at end of file diff --git a/5th Study/Example/Memento/Memento.cpp b/5th Study/Example/Memento/Memento.cpp new file mode 100644 index 0000000..9b803d7 --- /dev/null +++ b/5th Study/Example/Memento/Memento.cpp @@ -0,0 +1,148 @@ +// State.cpp : �ܼ� ���� ���α��� ���� �������� �����մΘ�. +// + +#include "stdafx.h" +#include +#include +#include +#include +using namespace std; + +#define GO_BOARD_SIZE 19 + +class GoMemento { + friend class GoBoard; //friend�� GoBoard�� ���� +public: + GoMemento() { + for (int i = 0; i < GO_BOARD_SIZE; i++) + for (int j = 0; j < GO_BOARD_SIZE; j++) + board_[i][j] = 0; + + whiteDeadNum_ = blackDeadNum_ = 0; + paePosX_ = paePosY_ = -1; + } + + GoMemento(const GoMemento& rhs) { CopyBoard(rhs); } + GoMemento& operator=(const GoMemento& rhs) { CopyBoard(rhs); } + + void GetOutDeadStone() { + // -- Ȯ���� ���� ���� ����. + // -- �̶� whiteDeadNum_ �̳� blackDeadNum_ ���� ������ + } + + bool IsPaePosition(int x, int y) { + // -- x,y ��ġ�� ���̸� true �ǵ��� + return false; + } + +protected: + void CopyBoard(const GoMemento& src) { + for (int i = 0; i < GO_BOARD_SIZE; i++) + for (int j = 0; j < GO_BOARD_SIZE; j++) + board_[i][j] = src.board_[i][j]; + + whiteDeadNum_ = src.whiteDeadNum_; + blackDeadNum_ = src.blackDeadNum_; + } +private: + // -- 0 �� ������, ������ ��, ������ ��, ���밪�� ���� + int board_[GO_BOARD_SIZE][GO_BOARD_SIZE]; + + int whiteDeadNum_; // -- ���� ���� �� + int blackDeadNum_; // -- ������ ���� �� + + int paePosX_; + int paePosY_; +}; + +class GoBoard { // -- �اٴ��� +public: + GoBoard(int firstTurn = -1) { + pCurBoard_ = new GoMemento(); + whoseTurn_ = firstTurn; + totalStoneNum_ = 0; + } + + void PutStone(int x, int y) { + if (pCurBoard_->board_[x][y] != 0 || + (pCurBoard_->paePosX_ == x && pCurBoard_->paePosY_ == y)) { + cout << "Can't Be Put Stone There." << endl; + return; + } + + GoMemento *pNewBoard = new GoMemento(*pCurBoard_); + totalStoneNum_++; + pNewBoard->board_[x][y] = whoseTurn_ * totalStoneNum_; + whoseTurn_ *= -1; + if (pCurBoard_->IsPaePosition(x, y)) { + pCurBoard_->paePosX_ = x; + pCurBoard_->paePosY_ = y; + } + else { + pCurBoard_->paePosX_ = -1; + pCurBoard_->paePosY_ = -1; + } + + pNewBoard->GetOutDeadStone(); + + historyList_.push_front(pCurBoard_); + pCurBoard_ = pNewBoard; + } + + void RetractStone(int cnt) { + // ------------------------------------------- + // cnt ����ŭ ���� ������. + // �̶� 1���� ������ ���� pCurBoard_ ���� historyList_�� + // ù ���� ��ġ�Θ� �Ͱ� �����Θ�. + // ------------------------------------------- + if (cnt <= 0) return; + + for (auto i = 0; i < cnt - 1; i++) { + GoMemento *pTmpBoard = historyList_.front(); //ù��° ������ȯ + delete pTmpBoard; + historyList_.pop_front(); //������ ���� + totalStoneNum_--; + } + + delete pCurBoard_; + totalStoneNum_--; + if (historyList_.empty()) + pCurBoard_ = new GoMemento(); + else + pCurBoard_ = historyList_.front(); + } + + void PrintBoard() { + for (auto i = 0; i < GO_BOARD_SIZE; i++) { + for (auto j = 0; j < GO_BOARD_SIZE; j++) + cout << pCurBoard_->board_[i][j] << " "; + cout << endl; + } + cout << "--- total stone --- " << totalStoneNum_ << endl; + } +private: + list historyList_; + GoMemento* pCurBoard_; + int whoseTurn_; // -- ���� �� ����(1 �� ��, -1 �� ��) + int totalStoneNum_; +}; + +int main() +{ + GoBoard board; + + board.PutStone(3, 3); //�� + board.PutStone(16, 16); + board.PutStone(16, 3); + board.PutStone(3, 16); + board.PrintBoard(); + + system("pause"); + + board.RetractStone(2); //������ + board.PrintBoard(); + + system("pause"); + + return 0; +} diff --git a/5th Study/Example/Memento/Memento.vcxproj b/5th Study/Example/Memento/Memento.vcxproj new file mode 100644 index 0000000..d2f2f4a --- /dev/null +++ b/5th Study/Example/Memento/Memento.vcxproj @@ -0,0 +1,166 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {FFCFF21C-0705-46C9-BAAD-30A579F5F60F} + Win32Proj + Memento + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Use + Level3 + Disabled + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + Use + MaxSpeed + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/5th Study/Example/Memento/Memento.vcxproj.filters b/5th Study/Example/Memento/Memento.vcxproj.filters new file mode 100644 index 0000000..087d273 --- /dev/null +++ b/5th Study/Example/Memento/Memento.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + + + 헤더 파일 + + + 헤더 파일 + + + + + 소스 파일 + + + 소스 파일 + + + + + + \ No newline at end of file diff --git a/5th Study/Example/Memento/ReadMe.txt b/5th Study/Example/Memento/ReadMe.txt new file mode 100644 index 0000000..81c73b8 --- /dev/null +++ b/5th Study/Example/Memento/ReadMe.txt @@ -0,0 +1,31 @@ +======================================================================== + 콘솔 응용 프로그램 : Memento 프로젝트 개요 +======================================================================== + +응용 프로그램 마법사에서 이 Memento 응용 프로그램을 만들었습니다. + +Memento 응용 프로그램을 구성하는 각 파일에 대한 +요약 설명이 포함되어 있습니다. + + +Memento.vcxproj + 응용 프로그램 마법사를 사용하여 생성한 VC++ 프로젝트의 기본 프로젝트 파일입니다. 파일을 생성한 Visual C++ 버전에 대한 정보와 응용 프로그램 마법사를 사용하여 선택한 플랫폼, 구성 및 프로젝트 기능에 대한 정보가 포함되어 있습니다. + +Memento.vcxproj.filters + 응용 프로그램 마법사를 사용하여 생성된 VC++ 프로젝트의 필터 파일입니다. 이 파일에는 프로젝트의 파일과 필터 간의 연결 정보가 들어 있습니다. 이러한 연결은 특정 노드에서 유사한 확장명으로 그룹화된 파일을 표시하기 위해 IDE에서 사용됩니다. 예를 들어 ".cpp" 파일은 "소스 파일" 필터와 연결되어 있습니다. + +Memento.cpp + 기본 응용 프로그램 소스 파일입니다. + +///////////////////////////////////////////////////////////////////////////// +기타 표준 파일: + +StdAfx.h, StdAfx.cpp + 이 파일은 미리 컴파일된 헤더(PCH) 파일 Memento.pch와 미리 컴파일된 형식(PCT) 파일 StdAfx.obj를 빌드하는 데 사용됩니다. + +///////////////////////////////////////////////////////////////////////////// +기타 참고: + +응용 프로그램 마법사에서 사용하는 "TODO:" 주석은 사용자가 추가하거나 사용자 지정해야 하는 소스 코드 부분을 나타냅니다. + +///////////////////////////////////////////////////////////////////////////// diff --git a/5th Study/Example/Memento/stdafx.cpp b/5th Study/Example/Memento/stdafx.cpp new file mode 100644 index 0000000..30f8b48 --- /dev/null +++ b/5th Study/Example/Memento/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : ǥ�� ���� ���ϸ� ���� �ִ� �ҽ� �����ԴΘ�. +// Memento.pch�� �̸� �����ε� ������ �˴Θ�. +// stdafx.obj���� �̸� �����ε� ���� ������ ���Ե˴Θ�. + +#include "stdafx.h" + +// TODO: �ʿ��� �߰� ������ +// �� ������ �ƴ� STDAFX.H���� �����մΘ�. diff --git a/5th Study/Example/Memento/stdafx.h b/5th Study/Example/Memento/stdafx.h new file mode 100644 index 0000000..b9d7e4d --- /dev/null +++ b/5th Study/Example/Memento/stdafx.h @@ -0,0 +1,15 @@ +// stdafx.h : ���� ���������� ���� ���������� �ɹ� +// ǥ�� �ý��� ���� ���� �Ǵ� ������Ʈ ���� ���� ������ +// ���� �ִ� ���� �����ԴΘ�. +// + +#pragma once + +#include "targetver.h" + +#include +#include + + + +// TODO: ���α��� �ʿ��� �߰� ������ ����� �����մΘ�. diff --git a/5th Study/Example/Memento/targetver.h b/5th Study/Example/Memento/targetver.h new file mode 100644 index 0000000..3142091 --- /dev/null +++ b/5th Study/Example/Memento/targetver.h @@ -0,0 +1,8 @@ +#pragma once + +// SDKDDKVer.h�� �����ϸ� �ְ� ������ ���뼺�� ���� Windows �÷����� ���ǵ˴Θ�. + +// ���� Windows �÷����� ���� ���� ���α��� �����Ϸ��� ���쿡�� SDKDDKVer.h�� �����ρ� ���� +// WinSDKVer.h�� �����κ� _WIN32_WINNT ��ũ�θ� �����Ϸ��� �÷������� �����Ͻʽÿ�. + +#include diff --git a/5th Study/Example/Observer/Observer.vcxproj b/5th Study/Example/Observer/Observer.vcxproj new file mode 100644 index 0000000..6b288b9 --- /dev/null +++ b/5th Study/Example/Observer/Observer.vcxproj @@ -0,0 +1,117 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {992FA038-9497-4951-B1AF-5F0F700741C1} + Observer + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + \ No newline at end of file diff --git a/5th Study/Example/Observer/Observer.vcxproj.filters b/5th Study/Example/Observer/Observer.vcxproj.filters new file mode 100644 index 0000000..6a1782f --- /dev/null +++ b/5th Study/Example/Observer/Observer.vcxproj.filters @@ -0,0 +1,17 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + \ No newline at end of file diff --git a/5th Study/Example/README.md b/5th Study/Example/README.md new file mode 100644 index 0000000..4e36601 --- /dev/null +++ b/5th Study/Example/README.md @@ -0,0 +1,39 @@ +# 5주차 스터디 예제 코드 + +> ### 작성자 +> 박 동하 ( luncliff@gmail.com ) +> ### 갱신일 +> 16/09/30 ~ 16/10/01 + +## 0. 요약 +5주차 디자인 패턴 스터디에서 사용하는 패턴들이 반영된 예제 코드입니다. + +### - Mediator 패턴 +GUI 프로그래밍에서 다수의 Page들간의 관계, 화면전환 코드를 관리하는 것은 꽤나 번거로운 일이 될 수 있습니다. +프로그래머의 두뇌를 괴롭히는 이 문제를 `Mediator`로 접근해봅니다. + +### - Observer 패턴 +옵저버 패턴으로 간단한 Data-Binding을 구현합니다. +옵저버 패턴은 간단하면서도 효율적인 패턴 중 하나인데요, 멀티스레드에서는 어떨까요? + +### - State 패턴 +2주차 스터디에서 사용했던 JSON 타입들을 기반으로 +FSM(Finite State Machine)을 활용한 JSON parser를 구현합니다. + + +## 1. 외부 라이브러리 + +### - Qt 5.7 +C++ 생태계에서 Qt는 대표적인 Cross Platform 프레임워크로서 자리하고 있습니다. + +예제 코드에서는 GUI를 위해서 사용했지만, +Database나 System, Web 프로그래밍에도 유용하게 사용될 수 있는 라이브러리로 가득합니다. + +오픈 소스 개발에는 무료로 사용할 수 있지만 그 외에는 라이센스 비용을 지불해야 합니다. + +### - Catch +Macro 기반 C++ Testing 라이브러리입니다. 예제코드들의 Unit Test를 위해 사용하였습니다. + + + + diff --git a/5th Study/Example/State/State.vcxproj b/5th Study/Example/State/State.vcxproj new file mode 100644 index 0000000..d149ea7 --- /dev/null +++ b/5th Study/Example/State/State.vcxproj @@ -0,0 +1,117 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {02ED96A0-3ACD-4887-8E62-90E0C027DE4E} + State + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + \ No newline at end of file diff --git a/5th Study/Example/State/State.vcxproj.filters b/5th Study/Example/State/State.vcxproj.filters new file mode 100644 index 0000000..ce6ab79 --- /dev/null +++ b/5th Study/Example/State/State.vcxproj.filters @@ -0,0 +1,11 @@ + + + + + {c1a7ec11-6e13-4ccd-b882-a1410e79ae26} + + + {54170264-a8ce-42dc-99f6-a3e10b949925} + + + \ No newline at end of file diff --git a/2nd Study/Example/Json/json.hpp b/5th Study/Example/State/json.hpp similarity index 100% rename from 2nd Study/Example/Json/json.hpp rename to 5th Study/Example/State/json.hpp diff --git a/2nd Study/Example/Json/json/parser.h b/5th Study/Example/State/json/parser.h similarity index 100% rename from 2nd Study/Example/Json/json/parser.h rename to 5th Study/Example/State/json/parser.h diff --git a/2nd Study/Example/Json/json/parser/array_parser.cpp b/5th Study/Example/State/json/parser/array_parser.cpp similarity index 100% rename from 2nd Study/Example/Json/json/parser/array_parser.cpp rename to 5th Study/Example/State/json/parser/array_parser.cpp diff --git a/2nd Study/Example/Json/json/parser/array_parser.h b/5th Study/Example/State/json/parser/array_parser.h similarity index 100% rename from 2nd Study/Example/Json/json/parser/array_parser.h rename to 5th Study/Example/State/json/parser/array_parser.h diff --git a/2nd Study/Example/Json/json/parser/json_builder.cpp b/5th Study/Example/State/json/parser/json_builder.cpp similarity index 100% rename from 2nd Study/Example/Json/json/parser/json_builder.cpp rename to 5th Study/Example/State/json/parser/json_builder.cpp diff --git a/2nd Study/Example/Json/json/parser/json_builder.h b/5th Study/Example/State/json/parser/json_builder.h similarity index 100% rename from 2nd Study/Example/Json/json/parser/json_builder.h rename to 5th Study/Example/State/json/parser/json_builder.h diff --git a/2nd Study/Example/Json/json/parser/object_parser.cpp b/5th Study/Example/State/json/parser/object_parser.cpp similarity index 100% rename from 2nd Study/Example/Json/json/parser/object_parser.cpp rename to 5th Study/Example/State/json/parser/object_parser.cpp diff --git a/2nd Study/Example/Json/json/parser/object_parser.h b/5th Study/Example/State/json/parser/object_parser.h similarity index 100% rename from 2nd Study/Example/Json/json/parser/object_parser.h rename to 5th Study/Example/State/json/parser/object_parser.h diff --git a/2nd Study/Example/Json/json/parser/stream_parser.cpp b/5th Study/Example/State/json/parser/stream_parser.cpp similarity index 100% rename from 2nd Study/Example/Json/json/parser/stream_parser.cpp rename to 5th Study/Example/State/json/parser/stream_parser.cpp diff --git a/2nd Study/Example/Json/json/parser/stream_parser.hpp b/5th Study/Example/State/json/parser/stream_parser.hpp similarity index 100% rename from 2nd Study/Example/Json/json/parser/stream_parser.hpp rename to 5th Study/Example/State/json/parser/stream_parser.hpp diff --git a/2nd Study/Example/Json/json/types.h b/5th Study/Example/State/json/types.h similarity index 100% rename from 2nd Study/Example/Json/json/types.h rename to 5th Study/Example/State/json/types.h diff --git a/2nd Study/Example/Json/json/types/json_array.cpp b/5th Study/Example/State/json/types/json_array.cpp similarity index 100% rename from 2nd Study/Example/Json/json/types/json_array.cpp rename to 5th Study/Example/State/json/types/json_array.cpp diff --git a/2nd Study/Example/Json/json/types/json_array.hpp b/5th Study/Example/State/json/types/json_array.hpp similarity index 100% rename from 2nd Study/Example/Json/json/types/json_array.hpp rename to 5th Study/Example/State/json/types/json_array.hpp diff --git a/2nd Study/Example/Json/json/types/json_base.cpp b/5th Study/Example/State/json/types/json_base.cpp similarity index 100% rename from 2nd Study/Example/Json/json/types/json_base.cpp rename to 5th Study/Example/State/json/types/json_base.cpp diff --git a/2nd Study/Example/Json/json/types/json_base.hpp b/5th Study/Example/State/json/types/json_base.hpp similarity index 100% rename from 2nd Study/Example/Json/json/types/json_base.hpp rename to 5th Study/Example/State/json/types/json_base.hpp diff --git a/2nd Study/Example/Json/json/types/json_object.cpp b/5th Study/Example/State/json/types/json_object.cpp similarity index 100% rename from 2nd Study/Example/Json/json/types/json_object.cpp rename to 5th Study/Example/State/json/types/json_object.cpp diff --git a/2nd Study/Example/Json/json/types/json_object.hpp b/5th Study/Example/State/json/types/json_object.hpp similarity index 100% rename from 2nd Study/Example/Json/json/types/json_object.hpp rename to 5th Study/Example/State/json/types/json_object.hpp diff --git a/2nd Study/Example/Json/test/test.json_parser.cpp b/5th Study/Example/State/test/test.json_parser.cpp similarity index 100% rename from 2nd Study/Example/Json/test/test.json_parser.cpp rename to 5th Study/Example/State/test/test.json_parser.cpp diff --git a/2nd Study/Example/Json/test/test.json_types.cpp b/5th Study/Example/State/test/test.json_types.cpp similarity index 100% rename from 2nd Study/Example/Json/test/test.json_types.cpp rename to 5th Study/Example/State/test/test.json_types.cpp diff --git a/2nd Study/Example/Json/test/test.main.cpp b/5th Study/Example/State/test/test.main.cpp similarity index 100% rename from 2nd Study/Example/Json/test/test.main.cpp rename to 5th Study/Example/State/test/test.main.cpp diff --git a/5th Study/Example/lib/Catch b/5th Study/Example/lib/Catch new file mode 160000 index 0000000..35f5105 --- /dev/null +++ b/5th Study/Example/lib/Catch @@ -0,0 +1 @@ +Subproject commit 35f510545d55a831372d3113747bf1314ff4f2ef diff --git a/5th Study/Memento.pptx b/5th Study/Memento.pptx new file mode 100644 index 0000000..5fe8c30 Binary files /dev/null and b/5th Study/Memento.pptx differ diff --git a/5th Study/Week5.pptx b/5th Study/Week5.pptx new file mode 100644 index 0000000..f65afdc Binary files /dev/null and b/5th Study/Week5.pptx differ diff --git a/6th Study/Example/.gitignore b/6th Study/Example/.gitignore new file mode 100644 index 0000000..6c5009c --- /dev/null +++ b/6th Study/Example/.gitignore @@ -0,0 +1,301 @@ + +# Created by https://www.gitignore.io/api/visualstudio,visualstudiocode,c++ + +### Project Library ### +lib/bin/ + + +### VisualStudioCode ### +.vscode + + + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml diff --git a/6th Study/Example/DoubleBuffer/DoubleBuffer.vcxproj b/6th Study/Example/DoubleBuffer/DoubleBuffer.vcxproj new file mode 100644 index 0000000..97cb112 --- /dev/null +++ b/6th Study/Example/DoubleBuffer/DoubleBuffer.vcxproj @@ -0,0 +1,124 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21} + DoubleBuffer + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/6th Study/Example/DoubleBuffer/DoubleBuffer.vcxproj.filters b/6th Study/Example/DoubleBuffer/DoubleBuffer.vcxproj.filters new file mode 100644 index 0000000..8141234 --- /dev/null +++ b/6th Study/Example/DoubleBuffer/DoubleBuffer.vcxproj.filters @@ -0,0 +1,34 @@ + + + + + {ed6c0be5-9438-4ae2-af7a-60d781397f2d} + + + {101eedb4-51eb-4932-acf8-735f90c4dfae} + + + + + src + + + src\games + + + src\games + + + src\games + + + src\games + + + src\games + + + src\games + + + \ No newline at end of file diff --git a/6th Study/Example/DoubleBuffer/games.h b/6th Study/Example/DoubleBuffer/games.h new file mode 100644 index 0000000..7087220 --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games.h @@ -0,0 +1,4 @@ +#pragma once +#include "./games/FrameBuffer.h" +#include "./games/game.h" +#include "./games/screen.h" diff --git a/6th Study/Example/DoubleBuffer/games/FrameBuffer.h b/6th Study/Example/DoubleBuffer/games/FrameBuffer.h new file mode 100644 index 0000000..ec32b61 --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games/FrameBuffer.h @@ -0,0 +1,79 @@ +#pragma once +#include "./buffer.h" + +namespace Pattern +{ + using u8 = std::uint8_t; + + struct Pos2D + { + i32 x = 0, y = 0; + public: + Pos2D(i32 _x, i32 _y) : + x{ _x }, y{ _y } + {} + }; + + // - Note + // CSS-like 4 byte color type with RGB-A notation + // In this type, Alpha's value domain is 0 ~ 255. + // + // a == 255 : CSS alpha 1.0 (default) + // a == 0 : CSS alpha 0.0 + // + struct PixelColor final + { + union { + struct { + u8 red; + u8 green; + u8 blue; + u8 alpha; + }; + u32 rgba; + }; + + PixelColor(const u32 _rgba = 0xff) : + rgba{ _rgba } + {} + + PixelColor( const u8 _red, + const u8 _green, + const u8 _blue, + const u8 _alpha = 0xff ) : + red{ _red }, green{_green}, blue{_blue}, alpha{_alpha} + {} + + operator u32() const noexcept + { + return this->rgba; + } + }; + + + // - Dependency + // `PixelColor` + template + class FrameBuffer : + public StaticBuffer + { + using base_type = StaticBuffer; + public: + using value_type = PixelColor; + + public: + value_type& operator[](const Pos2D _pos) noexcept(false) + { + return base_type::operator[](_pos.x + _pos.y * Width); + } + + const value_type& operator[](const Pos2D _pos) const noexcept(false) + { + return base_type::operator[](_pos.x + _pos.y * Width); + } + + + }; + + +} \ No newline at end of file diff --git a/6th Study/Example/DoubleBuffer/games/buffer.h b/6th Study/Example/DoubleBuffer/games/buffer.h new file mode 100644 index 0000000..cea910c --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games/buffer.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include + +namespace Pattern +{ + using i32 = std::int32_t; + using u32 = std::uint32_t; + + template + struct basic_buffer + { + protected: + basic_buffer() = default; + ~basic_buffer() = default; + public: + virtual T& operator [](const i32 _idx) noexcept(false) = 0; + virtual const T& operator [](const i32 _idx) const noexcept(false) = 0; + virtual void clear() = 0; + }; + + + template + class StaticBuffer : + public basic_buffer + { + static_assert(std::is_default_constructible::value, + "The buffer's element type must be [default constructible]"); + static_assert(std::is_copy_assignable::value, + "The buffer's element type must be [copy assignable]"); + + T blocks[Size]; + + public: + StaticBuffer() = default; + + void clear() noexcept + override + { + for (auto i = 0; i < Size; ++i) { + // Assign default value + blocks[i] = T{}; + } + } + + T& operator [](const i32 _idx) noexcept(false) + override + { + return blocks[_idx]; + } + + const T& operator [](const i32 _idx) const noexcept(false) + override + { + return blocks[_idx]; + } + + }; + + +}// namespace Pattern + diff --git a/6th Study/Example/DoubleBuffer/games/game.h b/6th Study/Example/DoubleBuffer/games/game.h new file mode 100644 index 0000000..0ccc06d --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games/game.h @@ -0,0 +1,100 @@ +#pragma once +#include "./FrameBuffer.h" +#include "./IOSystem.h" +#include "./timer.hpp" + +namespace Pattern +{ + using namespace std::chrono_literals; + + // - Note + // Double buffer provider module + // - Pattern + // Double Buffer + template + class BufferModule + { + private: + BufferType buffers[2]; + BufferType* pcurr = buffers + 0; + BufferType* pnext = buffers + 1; + + public: + BufferModule() = default; + + const BufferType& current() const noexcept + { + return *pcurr; + } + + const BufferType& next() const noexcept + { + return *pnext; + } + + BufferType& next() noexcept + { + return *pnext; + } + + void change() noexcept + { + std::swap(pcurr, pnext); + } + + }; + + + + template + class RateCalc + { + public: + using unit_type = UnitType; + + // Exponential Weight Moving Average + unit_type ewma{}; + public: + unit_type calc(const unit_type _elapsed) + { + const auto weighted = (ewma.count() * 5 + _elapsed.count() * 5) / 10; + ewma = unit_type{ weighted }; + return ewma; + } + }; + + + template + class InGameSystem: + BufferModule + { + int counter{ 1 }; + public: + InGameSystem() + { + this->next()[{1, 0}] = 0xAA; + this->change(); + this->next()[{1, 0}] = 0xBB; + this->change(); + } + + void update(std::chrono::milliseconds _ms) + { + std::cout << "update time "<< _ms.count() << " ms... "<< std::endl; + + // Do stuff... + auto& buffer = this->next(); + buffer[{0, 0}] = counter++; + + // Swap the buffer + this->change(); + } + + decltype(auto) buffer() const noexcept + { + return this->current(); + } + }; + +}// namespace Pattern + diff --git a/6th Study/Example/DoubleBuffer/games/memory.hpp b/6th Study/Example/DoubleBuffer/games/memory.hpp new file mode 100644 index 0000000..13144d5 --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games/memory.hpp @@ -0,0 +1,66 @@ +#pragma once +#include +#include + +namespace Pattern +{ + // - Note + // Minimal allocator interface, use `std::allocator` if possible. + template + struct allocator + { + protected: + allocator() = default; + ~allocator() = default; + + public: + virtual T* allocate() noexcept = 0; + virtual T* allocate(const std::size_t n) noexcept = 0; + virtual void deallocate(T* _addr, + const std::size_t _n) noexcept = 0; + }; + + // - Note + // Simple heap(dynamic memory) allocator + // - Dependency + // `std::calloc` + // `std::free` + template + class HeapAllocator : + public allocator + { + public: + T* allocate() noexcept + override + { + void* res = std::calloc(1, sizeof(T)); + return reinterpret_cast(res); + } + + T* allocate(std::size_t _n) noexcept + override + { + void* res = std::calloc(_n, sizeof(T)); + return reinterpret_cast(res); + } + + + void deallocate(T* _addr, + const std::size_t _n) noexcept + override + { + // Ignore nullptr + if (_addr == nullptr) { return; } + + // Invoke destructors + for (int i = 0; i < _n; ++i) { + _addr[i].~T(); + } + // Resource release + std::free(_addr); + } + + }; + + +}// namespace Pattern diff --git a/6th Study/Example/DoubleBuffer/games/screen.h b/6th Study/Example/DoubleBuffer/games/screen.h new file mode 100644 index 0000000..e5ef43b --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games/screen.h @@ -0,0 +1,60 @@ +#pragma once +#include +#include + +#include "./FrameBuffer.h" + +namespace Pattern +{ + + class ConsoleScreen + { + public: + + void clear() + { + // Windows CMD + //std::system("cls"); + } + + template + void render(const FrameBuffer& _buffer) + { + using namespace std; + this->clear(); + + cout << "Rendering... " << Width << ", " << Height << endl; + + cout << hex << uppercase ; + // Row-based access + for (auto y = 0; y < Height; ++y) { + for (auto x = 0; x < Width; ++x) { + cout << _buffer[{x, y}] << ' '; + } + cout << '\n'; + } + /* + // Column-based access + for (auto x = 0; x < Width; ++x) { + for (auto y = 0; y < Height; ++y) { + cout << _buffer[{x, y}] << ' '; + } + cout << '\n'; + } + */ + cout << dec << endl; + } + + }; + + + template + ConsoleScreen& operator << (ConsoleScreen& _out, + const FrameBuffer& _buffer) + { + _out.render(_buffer); + return _out; + } + +}// namespace Pattern + diff --git a/6th Study/Example/DoubleBuffer/games/timer.hpp b/6th Study/Example/DoubleBuffer/games/timer.hpp new file mode 100644 index 0000000..f1b5b17 --- /dev/null +++ b/6th Study/Example/DoubleBuffer/games/timer.hpp @@ -0,0 +1,69 @@ +// ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== +// +// File : timer.hpp +// Author : Park Dong Ha ( luncliff@gmail.com ) +// Updated : 16/09/05 +// +// Note +// Simple stop watch class +// +// Task +// More types for time utility +// +// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- +#ifndef _MAGIC_TIMER_HPP_ +#define _MAGIC_TIMER_HPP_ + +//#include +#include + +namespace magic +{ + // - Note + // Stop watch class. + // Support `pick()` and `reset()` functionality + template + class stop_watch + { + public: + using clock_type = Clock; + using time_point = typename clock_type::time_point; + using duration = typename clock_type::duration; + + private: + //std::atomic start = clock_type::now(); + time_point start = clock_type::now(); + + public: + template + decltype(auto) pick() const noexcept + { + using namespace std::chrono; + time_point curr = clock_type::now(); + + //return duration_cast(current - start.load()); + return duration_cast(curr - start); + }; + + template + decltype(auto) reset() noexcept + { + using namespace std::chrono; + + // end - start + auto span = this->pick(); + + // reset start time point + //start.store(clock_type::now()); + start = clock_type::now(); + + return span; + } + + }; + + + +}// namespace magic + +#endif diff --git a/6th Study/Example/Example.sln b/6th Study/Example/Example.sln new file mode 100644 index 0000000..dd2273c --- /dev/null +++ b/6th Study/Example/Example.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DoubleBuffer", "DoubleBuffer\DoubleBuffer.vcxproj", "{B0822618-4DDD-46C9-8D55-DF58D0B9CA21}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Debug|x64.ActiveCfg = Debug|x64 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Debug|x64.Build.0 = Debug|x64 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Debug|x86.ActiveCfg = Debug|Win32 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Debug|x86.Build.0 = Debug|Win32 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Release|x64.ActiveCfg = Release|x64 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Release|x64.Build.0 = Release|x64 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Release|x86.ActiveCfg = Release|Win32 + {B0822618-4DDD-46C9-8D55-DF58D0B9CA21}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/7th Study/Example/Example.sln b/7th Study/Example/Example.sln new file mode 100644 index 0000000..9aa1977 --- /dev/null +++ b/7th Study/Example/Example.sln @@ -0,0 +1,48 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Subclass", "Subclass\Subclass.vcxproj", "{0B2A543C-5EF9-4419-9B00-0695EE49EFD6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLoop", "GameLoop\GameLoop.vcxproj", "{15C9E4CD-56AE-47A5-A517-F8399A223045}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UpdateMethod", "UpdateMethod\UpdateMethod.vcxproj", "{C52B0AD3-2180-4B60-8A87-788E93AD7E6A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Debug|x64.ActiveCfg = Debug|x64 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Debug|x64.Build.0 = Debug|x64 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Debug|x86.ActiveCfg = Debug|Win32 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Debug|x86.Build.0 = Debug|Win32 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Release|x64.ActiveCfg = Release|x64 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Release|x64.Build.0 = Release|x64 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Release|x86.ActiveCfg = Release|Win32 + {0B2A543C-5EF9-4419-9B00-0695EE49EFD6}.Release|x86.Build.0 = Release|Win32 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Debug|x64.ActiveCfg = Debug|x64 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Debug|x64.Build.0 = Debug|x64 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Debug|x86.ActiveCfg = Debug|Win32 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Debug|x86.Build.0 = Debug|Win32 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Release|x64.ActiveCfg = Release|x64 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Release|x64.Build.0 = Release|x64 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Release|x86.ActiveCfg = Release|Win32 + {15C9E4CD-56AE-47A5-A517-F8399A223045}.Release|x86.Build.0 = Release|Win32 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Debug|x64.ActiveCfg = Debug|x64 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Debug|x64.Build.0 = Debug|x64 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Debug|x86.ActiveCfg = Debug|Win32 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Debug|x86.Build.0 = Debug|Win32 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Release|x64.ActiveCfg = Release|x64 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Release|x64.Build.0 = Release|x64 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Release|x86.ActiveCfg = Release|Win32 + {C52B0AD3-2180-4B60-8A87-788E93AD7E6A}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/7th Study/Example/GameLoop/GameLoop.vcxproj b/7th Study/Example/GameLoop/GameLoop.vcxproj new file mode 100644 index 0000000..9f13d2b --- /dev/null +++ b/7th Study/Example/GameLoop/GameLoop.vcxproj @@ -0,0 +1,130 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {15C9E4CD-56AE-47A5-A517-F8399A223045} + GameLoop + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + + + Level3 + Disabled + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/7th Study/Example/GameLoop/GameLoop.vcxproj.filters b/7th Study/Example/GameLoop/GameLoop.vcxproj.filters new file mode 100644 index 0000000..26b71f7 --- /dev/null +++ b/7th Study/Example/GameLoop/GameLoop.vcxproj.filters @@ -0,0 +1,46 @@ + + + + + {5150b6cc-89e1-472c-9d4b-cf93e4b3aa1b} + + + {0ff17c51-7972-469e-a9e7-ebc87cc09e0f} + + + + + src + + + src\games + + + src\games + + + src\games + + + src\games + + + src\games + + + src\games + + + + + src\games + + + + src\games + + + src\games + + + \ No newline at end of file diff --git a/7th Study/Example/GameLoop/games.h b/7th Study/Example/GameLoop/games.h new file mode 100644 index 0000000..5700723 --- /dev/null +++ b/7th Study/Example/GameLoop/games.h @@ -0,0 +1,2 @@ +#pragma once +#include "./games/game.h" diff --git a/7th Study/Example/GameLoop/games/avatar.cpp b/7th Study/Example/GameLoop/games/avatar.cpp new file mode 100644 index 0000000..778beea --- /dev/null +++ b/7th Study/Example/GameLoop/games/avatar.cpp @@ -0,0 +1,17 @@ +#include "./avatar.h" +#include "./skills.h" +namespace Pattern +{ + Avatar::Avatar() + { + this->setSkill(new Fly{ *this }); + } + + void Avatar::update(std::chrono::milliseconds _time) + { + if (skill) { + skill->update(_time); + } + } + +}// namespace Pattern diff --git a/7th Study/Example/GameLoop/games/avatar.h b/7th Study/Example/GameLoop/games/avatar.h new file mode 100644 index 0000000..e9f8311 --- /dev/null +++ b/7th Study/Example/GameLoop/games/avatar.h @@ -0,0 +1,40 @@ +#pragma once + +#include "./base.h" +#include "./skills.h" + +namespace Pattern +{ + + class Avatar : + public updatable + { + Skill* skill = nullptr; + + public: + i32 hp{ 100 }, mp{ 20 }; + Pos2D pos; + public: + Avatar(); + + void update(std::chrono::milliseconds _time) override; + + void setSkill(Skill* _skill) + { + if (_skill != nullptr) { + skill = _skill; + } + } + + bool useSkill() + { + if (skill && skill->isReady()) { + skill->activate(); + return true; + } + return false; + } + + }; + +}// namespace Pattern diff --git a/7th Study/Example/GameLoop/games/base.h b/7th Study/Example/GameLoop/games/base.h new file mode 100644 index 0000000..c2dd806 --- /dev/null +++ b/7th Study/Example/GameLoop/games/base.h @@ -0,0 +1,30 @@ +#pragma once + +#include "./timer.hpp" +#include + +namespace Pattern +{ + using u8 = std::uint8_t; + using i32 = std::int32_t; + + struct Pos2D + { + i32 x{ 0 }, y{ 0 }; + public: + Pos2D() {}; + Pos2D(i32 _x, i32 _y) : + x{ _x }, y{ _y } + {} + }; + + + template + struct Updatable + { + virtual void update(UnitType _time) = 0; + }; + + using updatable = Updatable; + +}// namespace Pattern diff --git a/7th Study/Example/GameLoop/games/game.cpp b/7th Study/Example/GameLoop/games/game.cpp new file mode 100644 index 0000000..2636e48 --- /dev/null +++ b/7th Study/Example/GameLoop/games/game.cpp @@ -0,0 +1,54 @@ +#pragma once + +#include "./game.h" +#include +#include +using namespace std; +using namespace std::chrono_literals; + +namespace Pattern +{ + InGameSystem::InGameSystem() + { + auto* a = new Avatar{}; + this->ups.push_back(a); + } + + + void InGameSystem::processInput() noexcept + { + std::this_thread::sleep_for(1ms); + } + + void InGameSystem::update(std::chrono::milliseconds _ms) + { + for (auto elem : this->ups) { + elem->update(_ms); + } + } + + void InGameSystem::render() noexcept + { + std::this_thread::sleep_for(14ms); + } + + void InGameSystem::resume() + { + fstop = false; + } + + void InGameSystem::stop() { + fstop = true; + } + + bool InGameSystem::is_stopped() const noexcept + { + return fstop == true; + } + + InGameSystem::operator bool() const noexcept + { + return this->is_stopped() == false; + } + +}// namespace Pattern diff --git a/7th Study/Example/GameLoop/games/game.h b/7th Study/Example/GameLoop/games/game.h new file mode 100644 index 0000000..a8262b2 --- /dev/null +++ b/7th Study/Example/GameLoop/games/game.h @@ -0,0 +1,60 @@ +#pragma once + +#include +#include +#include "./base.h" +#include "./avatar.h" +#include + +namespace Pattern +{ + using namespace std::chrono_literals; + + + class InGameSystem : + public updatable + { + std::atomic fstop{ false }; + std::vector ups{}; + + public: + InGameSystem(); + + void processInput() noexcept; + void update(std::chrono::milliseconds _ms) override; + void render() noexcept; + + + void resume(); + void stop(); + bool is_stopped() const noexcept; + + operator bool() const noexcept; + }; + +}// namespace Pattern + +namespace Pattern +{ + + template + class RateCalc + { + public: + using unit_type = UnitType; + + // Exponential Weight Moving Average + unit_type ewma{}; + public: + unit_type calc(const unit_type _elapsed) + { + const auto weighted = (ewma.count() * 5 + _elapsed.count() * 5) / 10; + ewma = unit_type{ weighted }; + return ewma; + } + }; + + +}// namespace Pattern + + diff --git a/7th Study/Example/GameLoop/games/main.cpp b/7th Study/Example/GameLoop/games/main.cpp new file mode 100644 index 0000000..e2de8be --- /dev/null +++ b/7th Study/Example/GameLoop/games/main.cpp @@ -0,0 +1,27 @@ +#include "./game.h" + +using namespace std; +using namespace magic; +using namespace chrono; +using namespace Pattern; + +int main() +{ + InGameSystem game{}; + + stop_watch sw{}; + + game.resume(); + // Game Loop + while (game) + { + auto elapsed = sw.pick(); + + game.processInput(); + game.update(elapsed); + game.render(); + } + + + return std::system("pause"); +} diff --git a/7th Study/Example/GameLoop/games/memory.hpp b/7th Study/Example/GameLoop/games/memory.hpp new file mode 100644 index 0000000..13144d5 --- /dev/null +++ b/7th Study/Example/GameLoop/games/memory.hpp @@ -0,0 +1,66 @@ +#pragma once +#include +#include + +namespace Pattern +{ + // - Note + // Minimal allocator interface, use `std::allocator` if possible. + template + struct allocator + { + protected: + allocator() = default; + ~allocator() = default; + + public: + virtual T* allocate() noexcept = 0; + virtual T* allocate(const std::size_t n) noexcept = 0; + virtual void deallocate(T* _addr, + const std::size_t _n) noexcept = 0; + }; + + // - Note + // Simple heap(dynamic memory) allocator + // - Dependency + // `std::calloc` + // `std::free` + template + class HeapAllocator : + public allocator + { + public: + T* allocate() noexcept + override + { + void* res = std::calloc(1, sizeof(T)); + return reinterpret_cast(res); + } + + T* allocate(std::size_t _n) noexcept + override + { + void* res = std::calloc(_n, sizeof(T)); + return reinterpret_cast(res); + } + + + void deallocate(T* _addr, + const std::size_t _n) noexcept + override + { + // Ignore nullptr + if (_addr == nullptr) { return; } + + // Invoke destructors + for (int i = 0; i < _n; ++i) { + _addr[i].~T(); + } + // Resource release + std::free(_addr); + } + + }; + + +}// namespace Pattern diff --git a/7th Study/Example/GameLoop/games/skills.cpp b/7th Study/Example/GameLoop/games/skills.cpp new file mode 100644 index 0000000..2c78c4e --- /dev/null +++ b/7th Study/Example/GameLoop/games/skills.cpp @@ -0,0 +1,30 @@ +#include "./skills.h" +#include "./avatar.h" + +namespace Pattern +{ + void Fly::update(std::chrono::milliseconds _time) + { + this->cool -= _time; + } + + bool Fly::isReady() + { + const auto HP = avatar.hp; + const auto Height = avatar.pos.y; + + if (HP != 0 && Height <= 0) { + return true; + } + return false; + } + + bool Fly::activate() + { + this->cool = std::chrono::milliseconds{ 1000 }; + + avatar.pos.y = 200; + return true; + } + +} diff --git a/7th Study/Example/GameLoop/games/skills.h b/7th Study/Example/GameLoop/games/skills.h new file mode 100644 index 0000000..06f7d61 --- /dev/null +++ b/7th Study/Example/GameLoop/games/skills.h @@ -0,0 +1,44 @@ +#pragma once + +#include "./base.h" +namespace Pattern +{ + using namespace std::chrono_literals; + class Avatar; + + class Skill : + public updatable + { + protected: + Avatar& avatar; + public: + explicit Skill(Avatar& _avatar) : + avatar{ _avatar } + {} + + //void update(std::chrono::milliseconds _time); + virtual bool isReady() = 0; + virtual bool activate() = 0; + + }; + + + class Fly : + public Skill + { + std::chrono::milliseconds cool = 1000ms; + public: + explicit Fly(Avatar& _avatar) : + Skill{_avatar} + {} + + void update(std::chrono::milliseconds _time) override; + virtual bool isReady() override; + virtual bool activate() override; + }; + + + + +} + diff --git a/7th Study/Example/GameLoop/games/timer.hpp b/7th Study/Example/GameLoop/games/timer.hpp new file mode 100644 index 0000000..f1b5b17 --- /dev/null +++ b/7th Study/Example/GameLoop/games/timer.hpp @@ -0,0 +1,69 @@ +// ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== +// +// File : timer.hpp +// Author : Park Dong Ha ( luncliff@gmail.com ) +// Updated : 16/09/05 +// +// Note +// Simple stop watch class +// +// Task +// More types for time utility +// +// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- +#ifndef _MAGIC_TIMER_HPP_ +#define _MAGIC_TIMER_HPP_ + +//#include +#include + +namespace magic +{ + // - Note + // Stop watch class. + // Support `pick()` and `reset()` functionality + template + class stop_watch + { + public: + using clock_type = Clock; + using time_point = typename clock_type::time_point; + using duration = typename clock_type::duration; + + private: + //std::atomic start = clock_type::now(); + time_point start = clock_type::now(); + + public: + template + decltype(auto) pick() const noexcept + { + using namespace std::chrono; + time_point curr = clock_type::now(); + + //return duration_cast(current - start.load()); + return duration_cast(curr - start); + }; + + template + decltype(auto) reset() noexcept + { + using namespace std::chrono; + + // end - start + auto span = this->pick(); + + // reset start time point + //start.store(clock_type::now()); + start = clock_type::now(); + + return span; + } + + }; + + + +}// namespace magic + +#endif diff --git "a/8th Study/Component-based Entity System and Data-oriented Design_2016_11_12_354円235円264円354円204円235円354円232円260円.pptx" "b/8th Study/Component-based Entity System and Data-oriented Design_2016_11_12_354円235円264円354円204円235円354円232円260円.pptx" new file mode 100644 index 0000000..a4ab631 Binary files /dev/null and "b/8th Study/Component-based Entity System and Data-oriented Design_2016_11_12_354円235円264円354円204円235円354円232円260円.pptx" differ diff --git a/8th Study/GameDoD.cpp b/8th Study/GameDoD.cpp new file mode 100644 index 0000000..a56da4d --- /dev/null +++ b/8th Study/GameDoD.cpp @@ -0,0 +1,190 @@ +#include + +enum ComponentType +{ + AI, + PHYSICS, + RENDERING +}; + +class Component +{ +public: + virtual ~Component() {} + virtual void Update() = 0; + +private: + int cId; +}; + +class UnitAI :public Component +{ +public: + virtual ~UnitAI() {} + virtual void Update(); +}; + +class UnitPhysics :public Component +{ +public: + virtual ~UnitPhysics() {} + virtual void Update(); +}; + +class UnitRendering :public Component +{ +public: + virtual ~UnitRendering() {} + virtual void Update(); + void Render(); + bool IsAcitve(); +}; + +class Entity +{ +public: + Component *GetComponent(int id); + void AddComponent(Component *comp); + void RemoveComponent(int id); + bool HasComponent(int id); + + std::vector GetComponents() + { + return mComponents; + } + +private: + std::vector mComponents; + int eId; +}; + +class AISystem +{ +public: + UnitAI GetAIComponent(int id); + void AddAIComponent(UnitAI ai); + void RemoveAIComponent(int id); + bool HasAIComponent(int id); + void Update() + { + for (auto i = 0; i < AIComponents.size(); ++i) + { + AIComponents[i].Update(); + } + } +private: + std::vector AIComponents; +}; + +class PhysicsSystem +{ +public: + UnitPhysics GetPhysicsComponent(int id); + void AddPhysicsComponent(UnitPhysics phy); + void RemovePhysicsComponent(int id); + bool HasPhysicsComponent(int id); + void Update() + { + for (auto i = 0; i < PhysicsComponents.size(); ++i) + { + PhysicsComponents[i].Update(); + } + } + +private: + std::vector PhysicsComponents; +}; + +class RenderingSystem +{ +public: + UnitRendering GetRenderingComponent(int id); + void AddRenderingComponent(UnitRendering phy); + void RemoveRenderingComponent(int id); + bool HasRenderingComponent(int id); + void Update() + { + for (auto i = 0; i < RenderingComponents.size(); ++i) + { + RenderingComponents[i].Update(); + } + } + void Render() + { + for (auto i = 0; i < RenderingComponents.size(); ++i) + { + if(isAcitive()) + RenderingComponents[i].Render(); + } + } + +private: + std::vector RenderingComponents; + std::vector showCom; + std::vector offCom; +}; + +class Engine +{ +public: + void Init(); + + void Update(float dt) + { + AIComponents.Update(); + PhysicsComponents.Update(); + RenderComponents.Update(); + } + + void Render() + { + RenderComponents.Render(); + } + + void MainLoop() + { + Update(timer.GetDeltaTime()); + Render(); + } + + +private: + AISystem AIComponents; + PhysicsSystem PhysicsComponents; + RenderingSystem RenderComponents; + + Timer timer; +}; + +class Timer +{ +public: + float GetDeltaTime(); +}; + +class Animation{}; +class Vector{}; +class LootType {}; + +class AIComponent +{ +public: + void Update(); + +private: + Animation* animation; + double evergy_; + Vector goalPos; + LootDrop* Loot; +}; + + + +class LootDrop +{ + friend class AIComponent; + LootType drop; + int minDrops; + int maxDrops; + double changeOfDrop; +}; \ No newline at end of file diff --git a/8th Study/GameOOP.cpp b/8th Study/GameOOP.cpp new file mode 100644 index 0000000..43372cd --- /dev/null +++ b/8th Study/GameOOP.cpp @@ -0,0 +1,127 @@ + +#include + +enum ComponentType +{ + AI, + PHYSICS, + RENDERING +}; + +class Component +{ +public: + virtual ~Component() {} + virtual void Update() = 0; + +private: + int cId; +}; + +class UnitAI :public Component +{ +public: + virtual ~UnitAI() {} + virtual void Update(); +}; + +class UnitPhysics :public Component +{ +public: + virtual ~UnitPhysics() {} + virtual void Update(); +}; + +class UnitRendering :public Component +{ +public: + virtual ~UnitRendering() {} + virtual void Update(); + void Render(); + bool IsAcitve(); +}; + +class Entity +{ +public: + Component *GetComponent(int id); + void AddComponent(Component *comp); + void RemoveComponent(int id); + bool HasComponent(int id); + + std::vector GetComponents() + { + return mComponents; + } + +private: + std::vector mComponents; + int eId; +}; + +class EntityManager +{ +public: + Entity *GetEntity(int id); + void AddEntity(Entity * ent); + void RemoveEntity(int id); + bool HasEntity(int id); + + std::vector GetEntities() + { + return mEntities; + } + +private: + std::vector mEntities; +}; + +class Engine +{ +public: + void Init(); + + void Update(float dt) + { + for (auto EMit = mEntityManagers.begin(); EMit != mEntityManagers.end(); ++EMit) + { + for (auto Eit = (*EMit)->GetEntities().begin(); Eit != (*EMit)->GetEntities().end(); ++Eit) + { + for (auto Cit = (*Eit)->GetComponents().begin(); Cit != (*Eit)->GetComponents().end(); ++Cit) + { + (*Cit)->Update(); + } + } + } + } + + void Render() + { + for (auto EMit = mEntityManagers.begin(); EMit != mEntityManagers.end(); ++EMit) + { + for (auto Eit = (*EMit)->GetEntities().begin(); Eit != (*EMit)->GetEntities().end(); ++Eit) + { + UnitRendering* renderCom = static_cast((*Eit)->GetComponent(RENDERING)); + renderCom->Render(); + } + } + } + + void MainLoop() + { + Update(timer.GetDeltaTime()); + Render(); + } + + void Add(EntityManager &EM); + +private: + std::vector mEntityManagers; + Timer timer; +}; + +class Timer +{ +public: + float GetDeltaTime(); +}; diff --git a/README.md b/README.md index cfcb2ef..1970270 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,10 @@ - 8월 20일 : 스터디 2회차 (Prototype, Adapter, Bridge, Composite) - 9월 3일 : 스터디 3회차 (Decorator, Façade, Flyweight, Proxy) - 9월 10일 : 스터디 4회차 (Chain of Responsibility, Command, Interpreter, Iterator) -- 9월 24일 : 스터디 5회차 (Mediator, Memento, Observer, State) -- 10월 8일 : 스터디 6회차 (Strategy, Template Method, Visitor, Double buffer) -- 10월 22일 : 스터디 7회차 (Game Loop, Update Method, Bytecode, Subclass Sandbox) -- 10월 29일 : 스터디 8회차 (Type Object, Component, Event Queue, Service Locator) +- 10월 1일 : 스터디 5회차 (Mediator, Memento, Observer, State) +- 10월 15일 : 스터디 6회차 (Strategy, Template Method, Visitor, Double buffer) +- 10월 29일 : 스터디 7회차 (Game Loop, Update Method, Bytecode, Subclass Sandbox) +- 11월 12일 : 스터디 8회차 (Type Object, Component, Event Queue, Service Locator) ## 비용 diff --git a/SOLID/Dependency/.gitignore b/SOLID/Dependency/.gitignore new file mode 100644 index 0000000..4f67c21 --- /dev/null +++ b/SOLID/Dependency/.gitignore @@ -0,0 +1,300 @@ + +# Created by https://www.gitignore.io/api/visualstudio,visualstudiocode,c++ + +### Project Library ### +Library/irrKlang_1_5 + +### VisualStudioCode ### +.vscode + + + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + + +### VisualStudio ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml diff --git a/2nd Study/Example/Json/Json.vcxproj b/SOLID/Dependency/AudioPlayer/AudioPlayer.vcxproj similarity index 76% rename from 2nd Study/Example/Json/Json.vcxproj rename to SOLID/Dependency/AudioPlayer/AudioPlayer.vcxproj index 767e20d..5a88a55 100644 --- a/2nd Study/Example/Json/Json.vcxproj +++ b/SOLID/Dependency/AudioPlayer/AudioPlayer.vcxproj @@ -19,9 +19,9 @@ - {2DE18D84-2873-4FFD-BB96-BF9D7592B52B} - Json - 10.0.10586.0 + {8126967A-3CC5-4975-B680-66AF7FD55AAC} + AudioPlayer + 10.0.10240.0 @@ -69,10 +69,8 @@ - ..\..\Example\lib\Catch\include;$(IncludePath) - - - ..\..\Example\lib\Catch\include;$(IncludePath) + ..\Library\yse-soundengine\include;..\Library\irrKlang_1_5\include;$(IncludePath) + ..\Build @@ -86,9 +84,6 @@ Level3 Disabled true - MultiThreadedDebug - true - true @@ -118,31 +113,30 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - + + - - + + diff --git a/SOLID/Dependency/AudioPlayer/AudioPlayer.vcxproj.filters b/SOLID/Dependency/AudioPlayer/AudioPlayer.vcxproj.filters new file mode 100644 index 0000000..d6e0525 --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/AudioPlayer.vcxproj.filters @@ -0,0 +1,81 @@ + + + + + {9ae3fda5-8b9d-47ee-8608-3feabbb7ec77} + + + {fdfade26-7252-490c-96e3-b21c99915cfa} + + + {c5f82917-d0df-4f4c-ad05-10a75320e092} + + + {8d31fa91-133c-481c-bf9b-32cc1a8465d2} + + + {002a368c-1a26-4a89-82fc-f98bbb42f2af} + + + {49285b48-f424-4284-94d5-d0540f092018} + + + + + src + + + src\Engine + + + + + src + + + src + + + src\Engine + + + + + lib\yse + + + lib\yse + + + lib\irrKlang + + + lib\irrKlang + + + lib\irrKlang + + + lib\irrKlang + + + res + + + + + lib\yse + + + lib\irrKlang + + + + + res + + + res + + + \ No newline at end of file diff --git a/SOLID/Dependency/AudioPlayer/Engine/EngineYSE.cpp b/SOLID/Dependency/AudioPlayer/Engine/EngineYSE.cpp new file mode 100644 index 0000000..36fd933 --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/Engine/EngineYSE.cpp @@ -0,0 +1,215 @@ +#include "./EngineYSE.h" +#include "EngineirrKlang.h" + +namespace Pattern +{ + // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + + EngineYSE::Sound EngineYSE::Load(std::string && _fpath) + { + return EngineYSE::Sound{ _fpath.c_str() }; + } + + EngineYSE::EngineYSE() + { + YSE::System().init(); + } + + EngineYSE::~EngineYSE() + { + try { + YSE::System().close(); + } + catch (...) {} + } + + + + void EngineYSE::play(EngineYSE::Sound & _sound) + { + // Alias + Mapping + + // Argument check + if (_sound.is_valid() == false && _sound.is_playing()) { + return; + } + _sound.play_impl(); + + // Insert into list for pause/resume support + auto iter = std::find(sounds.begin(), sounds.end(), _sound); + + // Not found + if (iter == sounds.end()) { + sounds.emplace_back(_sound); + } + + } + + void EngineYSE::play() + { + for (auto& snd : sounds) { + snd.play_impl(); + } + } + + void EngineYSE::remove(EngineYSE::Sound & _sound) + { + auto iter = std::find(sounds.begin(), sounds.end(), _sound); + // Found + if (iter != sounds.end()) { + sounds.erase(iter); + } + } + + void EngineYSE::stop() + { + for (auto& snd : sounds) { + snd.stop_impl(); + } + } + + void EngineYSE::pause() + { + for (auto& snd : sounds) { + snd.pause_impl(); + } + } + + void EngineYSE::resume() + { + for (auto& snd : sounds) + { + snd.resume_impl(); + } + } + + void EngineYSE::update() + { + YSE::System().update(); + } + + void EngineYSE::sleep(int ms) + { + if (ms> 0) { + YSE::System().sleep(ms); + } + } + + + // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + + void EngineYSE::Sound::play_impl() + { + if (is_valid() == true) { + impl->play(); + } + } + + void EngineYSE::Sound::pause_impl() + { + if (is_valid() == true) { + impl->pause(); + } + } + + void EngineYSE::Sound::resume_impl() + { + if (is_valid() && impl->isPaused() ) { + impl->toggle(); + } + } + + void EngineYSE::Sound::stop_impl() + { + if (is_valid() == true) { + impl->stop(); + } + } + + + EngineYSE::Sound::Sound(const char * _fname) + { + ref = new uint32_t{1}; + impl = new YSE::sound{}; + impl->create(_fname, nullptr, true); + } + + EngineYSE::Sound::~Sound() + { + if (*ref> 1) { + *ref -= 1; + } + else { + delete ref; + delete impl; + } + } + + + + EngineYSE::Sound::Sound(Sound & _rhs): + ref{_rhs.ref}, + impl{_rhs.impl} + { + *ref += 1; + } + + + EngineYSE::Sound & EngineYSE::Sound::operator=(Sound & _rhs) + { + ref = _rhs.ref; + impl = _rhs.impl; + *ref += 1; + + return *this; + } + + + bool EngineYSE::Sound::operator==(const Sound & _rhs) noexcept + { + return _rhs.impl == this->impl; + } + + + bool EngineYSE::Sound::is_valid() noexcept + { + return (impl != nullptr) && (impl->isValid()); + } + + bool EngineYSE::Sound::is_playing() noexcept + { + return impl->isPlaying() ; + } + + bool EngineYSE::Sound::is_paused() noexcept + { + return impl->isPaused(); + } + + + +namespace Option +{ + + void Volume::set(EngineYSE & _engine) + { + for (auto& snd : _engine.sounds) + { + const auto vol = snd.impl->getVolume() + increment; + snd.impl->setVolume(vol); + } + } + + float Volume::get(EngineYSE & _engine) + { + float res{}; + auto& list = _engine.sounds; + for (auto& snd : list) { + res += snd.impl->getVolume(); + } + + return res / list.size(); + } + +}// namespace Option +}// namespace Pattern diff --git a/SOLID/Dependency/AudioPlayer/Engine/EngineYSE.h b/SOLID/Dependency/AudioPlayer/Engine/EngineYSE.h new file mode 100644 index 0000000..3c3a27a --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/Engine/EngineYSE.h @@ -0,0 +1,97 @@ +#ifndef _ENGINE_YSE_H_ +#define _ENGINE_YSE_H_ + +#include +#include +#include "yse.hpp" + +namespace Pattern +{ + + namespace Option + { + class Volume; + } + + + class EngineYSE + { + friend class Option::Volume; + + public: // ---- ---- ---- ---- ---- + class Sound; + + + public: // ---- ---- ---- ---- ---- + static Sound Load(std::string&& _fpath); + + public: + + EngineYSE(); + ~EngineYSE(); + + void play(EngineYSE::Sound& _sound); + void play(); + void remove(EngineYSE::Sound& _sound); + + void stop(); + void pause(); + void resume(); + void update(); + + void sleep(int ms); + + private: + std::vector sounds; + + }; + + class EngineYSE::Sound + { + friend class EngineYSE; + friend class Option::Volume; + + private: + uint32_t* ref = nullptr; + YSE::sound* impl = nullptr; + + private: + void play_impl(); + void pause_impl(); + void resume_impl(); + void stop_impl(); + + public: + explicit Sound(const char* _fname); + ~Sound(); + + Sound(Sound&); + + Sound& operator=(Sound&); + + bool operator==(const Sound&) noexcept; + + bool is_valid() noexcept; + bool is_playing() noexcept; + bool is_paused() noexcept; + + }; + + + namespace Option + { + class Volume + { + float increment; + public: + explicit Volume(float _inc) :increment{ _inc } {} + + void set(EngineYSE& _engine); + float get(EngineYSE& _engine); + }; + + }// namespace Option + +}// namespace Pattern + +#endif diff --git a/SOLID/Dependency/AudioPlayer/Engine/EngineirrKlang.cpp b/SOLID/Dependency/AudioPlayer/Engine/EngineirrKlang.cpp new file mode 100644 index 0000000..7f4437f --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/Engine/EngineirrKlang.cpp @@ -0,0 +1,159 @@ +#include "./EngineirrKlang.h" + +using namespace irrklang; + +namespace Pattern +{ + // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + + std::uint32_t & EngineirrKlang::RefCount() + { + static uint32_t count{ 0 }; + return count; + } + + irrklang::ISoundEngine & EngineirrKlang::getDevice() + { + static irrklang::ISoundEngine* engine = createIrrKlangDevice(); + return *engine; + } + + + EngineirrKlang::Sound EngineirrKlang::Load(std::string && _fpath) + { + auto& device = EngineirrKlang::getDevice(); + ISound* snd = device.play2D(_fpath.c_str(), false, true, true); + return EngineirrKlang::Sound{ snd }; + } + + + // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + + + EngineirrKlang::EngineirrKlang() + { + RefCount() += 1; + } + + EngineirrKlang::~EngineirrKlang() + { + RefCount() -= 1; + if (RefCount() == 0) { + getDevice().drop(); + } + } + + void EngineirrKlang::play(EngineirrKlang::Sound & _sound) + { + _sound.play_impl(); + } + + void EngineirrKlang::play() + { + getDevice().setAllSoundsPaused(false); + } + + void EngineirrKlang::remove(EngineirrKlang::Sound & _sound) + { + getDevice().removeSoundSource(_sound.impl->getSoundSource()); + } + + void EngineirrKlang::stop() + { + getDevice().stopAllSounds(); + } + + void EngineirrKlang::pause() + { + getDevice().setAllSoundsPaused(true); + } + + void EngineirrKlang::resume() + { + getDevice().setAllSoundsPaused(false); + } + + void EngineirrKlang::update() + { + getDevice().update(); + } + + void EngineirrKlang::sleep(int ms) + { + return; + } + + + + + + + + // ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + + EngineirrKlang::Sound::Sound(irrklang::ISound * _pimpl): + impl{_pimpl} + { + } + + + void EngineirrKlang::Sound::play_impl() + { + impl->setIsPaused(false); + } + void EngineirrKlang::Sound::pause_impl() + { + impl->setIsPaused(); + } + void EngineirrKlang::Sound::resume_impl() + { + impl->setIsPaused(false); + } + void EngineirrKlang::Sound::stop_impl() + { + impl->stop(); + } + + bool EngineirrKlang::Sound::is_valid() noexcept + { + return impl != nullptr; + } + + bool EngineirrKlang::Sound::is_playing() noexcept + { + return impl->isFinished() == false; + } + + bool EngineirrKlang::Sound::is_paused() noexcept + { + return impl->getIsPaused(); + } + + +namespace Option +{ + + void Volume::set(EngineirrKlang & _engine) + { + auto& device = EngineirrKlang::getDevice(); + const auto vol = device.getSoundVolume() + increment; + if (vol> 1.0) { + device.setSoundVolume(1.0); + } + else { + device.setSoundVolume(vol); + } + + } + + float Volume::get(EngineirrKlang & _engine) + { + auto& device = EngineirrKlang::getDevice(); + + return device.getSoundVolume(); + } + +}// namespace Option +}// namespace Pattern + + diff --git a/SOLID/Dependency/AudioPlayer/Engine/EngineirrKlang.h b/SOLID/Dependency/AudioPlayer/Engine/EngineirrKlang.h new file mode 100644 index 0000000..5bc83f7 --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/Engine/EngineirrKlang.h @@ -0,0 +1,94 @@ +#ifndef _ENGINE_IRRKLANG_H_ +#define _ENGINE_IRRKLANG_H_ + + +#include +#include "irrKlang.h" + +#pragma comment(lib, "irrKlang.lib") // link with irrKlang.dll + +namespace Pattern +{ + + namespace Option + { + class Volume; + } + + + class EngineirrKlang + { + friend class Option::Volume; + + static std::uint32_t& RefCount(); + static irrklang::ISoundEngine& getDevice(); + + + public: // ---- ---- ---- ---- ---- + class Sound; + + + public: // ---- ---- ---- ---- ---- + static Sound Load(std::string&& _fpath); + + public: + EngineirrKlang(); + ~EngineirrKlang(); + + void play(EngineirrKlang::Sound& _sound); + void play(); + void remove(EngineirrKlang::Sound& _sound); + + void stop(); + void pause(); + void resume(); + void update(); + + void sleep(int ms); + + + }; + + class EngineirrKlang::Sound + { + friend class EngineirrKlang; + + irrklang::ISound* impl = nullptr; + private: + void play_impl(); + void pause_impl(); + void resume_impl(); + void stop_impl(); + + explicit Sound(irrklang::ISound*); + public: + ~Sound() = default; + + Sound(Sound&) = default; + Sound& operator=(Sound&) = default; + + bool is_valid() noexcept; + bool is_playing() noexcept; + bool is_paused() noexcept; + }; + + + /* + namespace Option + { + class Volume + { + float increment; + public: + explicit Volume(float _inc) :increment{ _inc } {} + + void set(EngineirrKlang& _engine); + float get(EngineirrKlang& _engine); + + }; + + }// namespace Option + */ +}// namespace Pattern + +#endif diff --git a/SOLID/Dependency/AudioPlayer/Options.h b/SOLID/Dependency/AudioPlayer/Options.h new file mode 100644 index 0000000..09cc98f --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/Options.h @@ -0,0 +1,10 @@ +#pragma once +#include "./Player.h" + +namespace Pattern +{ + + // Set options + Get options + + +}// namespace Pattern diff --git a/SOLID/Dependency/AudioPlayer/Player.h b/SOLID/Dependency/AudioPlayer/Player.h new file mode 100644 index 0000000..bae3900 --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/Player.h @@ -0,0 +1,74 @@ +#ifndef _PLAYER_H_ +#define _PLAYER_H_ + +namespace Pattern +{ + template + class Player + { + using sound_type = typename Engine::Sound; + + Engine eng; + public: + + void play(sound_type& _sound); + void play(); + + void remove(sound_type& _sound); + + void pause(); + void resume(); + void stop(); + + void update(); + void sleep(int ms); + + template + decltype(auto) set(SetOption&& option) + { + return option.set(eng); + } + + template + decltype(auto) get(GetOption&& option) + { + return option.get(eng); + } + + }; + + + template + void Player::update() { eng.update(); } + + template + void Player::sleep(int ms) + { + if (ms < 0) { return; } + eng.sleep(ms); + } + + template + void Player::pause() { eng.pause(); } + + template + void Player::resume() { eng.resume(); } + + template + void Player::stop() { eng.stop(); } + + template + void Player::play(sound_type& _sound) { eng.play(_sound); } + + template + void Player::play() { eng.play(); } + + template + void Player::remove(sound_type & _sound) + { + eng.remove(_sound); + } + +}// namespace Pattern + +#endif diff --git a/SOLID/Dependency/AudioPlayer/main.cpp b/SOLID/Dependency/AudioPlayer/main.cpp new file mode 100644 index 0000000..41931a2 --- /dev/null +++ b/SOLID/Dependency/AudioPlayer/main.cpp @@ -0,0 +1,54 @@ + +#include +#include +#include + +#include "./Player.h" +#include "./Engine/EngineYSE.h" +//#include "./Engine/EngineirrKlang.h" +using namespace std; +using namespace Pattern; + + +int main(void) { + using Engine = EngineYSE; + + { + Player player{}; + + Engine::Sound music = Engine::Load("../Resource/IWBTB_Boss5_Sonic.ogg"); + + if (music.is_valid() == false) { + std::cerr << "Loading failed" << std::endl; + return std::system("pause"); + } + + player.play(music); + + while (true) + { + if (_kbhit()) { + char ch = _getch(); + switch (ch) + { + case 'y': player.play(); break; + case 'p': player.pause(); break; + case 's': player.stop(); break; + case 'r': player.resume(); break; + case 'u': player.set(Option::Volume{ 0.5 }); break; + case 'd': player.set(Option::Volume{ -0.5 }); break; + case 'q': + player.stop(); + goto Exit; + } + } + + player.sleep(300); + + player.update(); + + } + } +Exit: + return std::system("pause"); +} diff --git a/SOLID/Dependency/Dependency.sln b/SOLID/Dependency/Dependency.sln new file mode 100644 index 0000000..1bc32c6 --- /dev/null +++ b/SOLID/Dependency/Dependency.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AudioPlayer", "AudioPlayer\AudioPlayer.vcxproj", "{8126967A-3CC5-4975-B680-66AF7FD55AAC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Debug|x64.ActiveCfg = Debug|x64 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Debug|x64.Build.0 = Debug|x64 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Debug|x86.ActiveCfg = Debug|Win32 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Debug|x86.Build.0 = Debug|Win32 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Release|x64.ActiveCfg = Release|x64 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Release|x64.Build.0 = Release|x64 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Release|x86.ActiveCfg = Release|Win32 + {8126967A-3CC5-4975-B680-66AF7FD55AAC}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SOLID/Dependency/Library/irrKlang_1_5/readme.txt b/SOLID/Dependency/Library/irrKlang_1_5/readme.txt new file mode 100644 index 0000000..7c48645 --- /dev/null +++ b/SOLID/Dependency/Library/irrKlang_1_5/readme.txt @@ -0,0 +1,196 @@ +========================================================================== +The irrKlang SDK version 1.5 +========================================================================== + + Welcome the irrKlang SDK. + + Content of this file: + + 1. Directory structure overview + 2. How to start + 3. Release Notes + 4. .NET version dependencies + 5. License + 6. Contact + + + +========================================================================== +1. Directory structure overview +========================================================================== + + You will find some directories after decompressing the archive in which + came the SDK. These are: + + \bin The compiled library irrKlang.DLL and some compiled demo + and example applications, just start them to see the + Irrlicht Engine in action. + \doc Documentation of the Irrlicht Engine. + \examples Examples and tutorials showing how to use the native engine + engine using C++. + \example.net Examples written for the .NET version of irrKlang, in C# and + VisualBasic.NET + \include Header files to include when using the engine. + \lib Lib to link with your programs when using the engine. + \media Sound data for the demo applications and + examples. + \plugins Source and documentation of the irrKlang plugins. + + +========================================================================== +2. How to start +========================================================================== + + To see the engine in action in Windows, just go to the \bin\Win32 + directories, and start some applications. + + To start developing own applications and games with the engine take + a look at the 01.HelloWorld example in the \examples directory. + + Windows Users: + There are Visual Studio as well as CodeBlocks projects for the examples. + + Linux users: + Just go into the /examples directory and run 'make' for every + example you want to try out. You can run the examples directly from the + directory they are created in. Some examples may print some special + hints after a successful make and might help you starting them up + by typing in 'make run'. + + Mac users: + There is a XCode project for each example available in + the corresponding example directory. To run the precompiled example + applications from bin\macos-gcc, doubleclick the run_0x_xxxxx.command + files from the finder (this will change the working directory to + bin\macos-gcc) or start them directly from a terminal. + +========================================================================== +3. Release Notes +========================================================================== + + Informations about changes in this new version of the engine can be + found in changes.txt. + + Please note that the included sound files are copyright + by their authors and not included in the irrKlang engine license. + + +========================================================================== +4. .NET version dependencies +========================================================================== + +There are four versions of irrKlang.NET available. They have the same +functionality and can be used from the same .NET projects. +The difference are only their dependencies and target platforms: + +irrKlang.NET in bin\dotnet-1.1: + Compiled for .NET common language runtime version 1.1, depends on + the modudle MSVCR71.DLL + Works with all .NET versions (32 bit). + +irrKlang.NET2.0 in bin\dotnet-2.0: + Compiled for .NET common language runtime version 2.0, depends on + the modudles MSVCR80.DLL and MSVCM80.DLL. (32 bit) + One method to redistribute these is using the visual studio 2005 + redistributeable (vcredist_x86) + +irrKlang.NET4 in bin\dotnet-4: + Compiled for .NET common language runtime version 4, depends on + MSVCR100.DLL. (32 bit) + One method to redistribute this is using the visual studio 2010 + redistributeable (vcredist_x86) + +irrKlang.NET4 in bin\dotnet-4-64: (only in the 64 bit irrKlang SDK) + 64 bit version, Compiled for .NET common language runtime version 4.5, + depends on MSVCR120.DLL. (64 bit) + One method to redistribute this is using the visual studio 2013 + redistributeable (vcredist 64 bit) + +========================================================================== +5. License +========================================================================== + +irrKlang's source codes, documentation and binaries contained within the +distributed archive are copyright � Nikolaus Gebhardt / Ambiera 2001-2014. + +The contents of the irrKlang distribution archive may not be redistributed, +reproduced, modified, transmitted, broadcast, published or adapted in any +way, shape or form, without the prior written consent of the owner, +Nikolaus Gebhardt. + +The irrKlang.dll, irrKlang.so and libirrklang.dylib files may be +redistributed without the authors prior permission in non-commercial +products, and must remain unmodified except for compressing the file. + +For the included plugins which can be found in the \plugins +directory, different licenses may be applied, as specified in the +actual plugin directory. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------------------- +irrKlang may include Xiph.org Foundation code (Ogg Vorbis and FLAC). +It's license is the following: + +Copyright (c) 2002, Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------------------- +irrKlang may include code from the + Dynamic Universal Music Bibliotheque, Version 0.9.3 + +Copyright (C) 2001-2005 Ben Davis, Robert J Ohannessian and Julien Cugniere + +========================================================================== +6. Contact +========================================================================== + + If you have problems, questions or suggestions, please visit the + official homepage of the irrKlang Engine: + + http://www.ambiera.com/irrklang + + You will find forums, bugtrackers, patches, tutorials, and other stuff + which will help you out. + + If want to contact the author of the engine, please send an email to + Nikolaus Gebhardt: + + office@ambiera.com diff --git a/SOLID/Dependency/Library/yse-soundengine b/SOLID/Dependency/Library/yse-soundengine new file mode 160000 index 0000000..65544bb --- /dev/null +++ b/SOLID/Dependency/Library/yse-soundengine @@ -0,0 +1 @@ +Subproject commit 65544bb4def18d1fc0c19a8a4329ad89b53fc5ad diff --git a/SOLID/Dependency/Resource/IWBTB_Boss5_Sonic.ogg b/SOLID/Dependency/Resource/IWBTB_Boss5_Sonic.ogg new file mode 100644 index 0000000..d89c81e Binary files /dev/null and b/SOLID/Dependency/Resource/IWBTB_Boss5_Sonic.ogg differ diff --git a/SOLID/Dependency/Resource/Piano.mp3 b/SOLID/Dependency/Resource/Piano.mp3 new file mode 100644 index 0000000..a256531 Binary files /dev/null and b/SOLID/Dependency/Resource/Piano.mp3 differ diff --git a/SOLID/Dependency/Resource/chord.wav b/SOLID/Dependency/Resource/chord.wav new file mode 100644 index 0000000..f981525 Binary files /dev/null and b/SOLID/Dependency/Resource/chord.wav differ diff --git a/SOLID/DependencyInversion.md b/SOLID/DependencyInversion.md new file mode 100644 index 0000000..c12ceee --- /dev/null +++ b/SOLID/DependencyInversion.md @@ -0,0 +1,9 @@ +# 의존성 역전 + +> #### 작성자 +> - 박 동하 ( luncliff@gmail.com ) +> #### 참고 +> + +예제 코드를 위해 irrKlang 1.5.0, yse-soundengine 두 라이브러리를 사용하였습니다. `audio` 디렉토리를 참고해주세요. + diff --git a/SOLID/InterfaceSegregation.md b/SOLID/InterfaceSegregation.md new file mode 100644 index 0000000..e37083d --- /dev/null +++ b/SOLID/InterfaceSegregation.md @@ -0,0 +1,9 @@ +# 인터페이스 분리 + +> #### 작성자 +> - 박 동하 ( luncliff@gmail.com ) +> #### 참고 +> + +Interface Segregation + diff --git a/SOLID/LiskovPrinciple.md b/SOLID/LiskovPrinciple.md new file mode 100644 index 0000000..3f39350 --- /dev/null +++ b/SOLID/LiskovPrinciple.md @@ -0,0 +1,9 @@ +# 리스코프 치환 원칙 + +> #### 작성자 +> - 박 동하 ( luncliff@gmail.com ) +> #### 참고 +> + +Liskov Substitution Principle + diff --git a/SOLID/README.md b/SOLID/README.md new file mode 100644 index 0000000..a2f9acf --- /dev/null +++ b/SOLID/README.md @@ -0,0 +1,22 @@ +# SOLID with C++ + +SOLID는 다음의 5가지를 말하는데요. + + - S : 단일 책임(Single Responsibility) + - O : 개방/폐쇄(Open/Closed) + - L : 리스코프 치환 원칙(Liskov Substitution) + - I : 인터페이스 분리(Interface Segregation) + - D : 의존성 역전(Dependency Inversion) + +이 디렉토리에서는 L, I, D에 대해서 다룹니다. 자세한 내용은 각각의 Markdown 문서를 참고해주세요. + +**문서에 기여해주시는 것도 언제나 환영합니다! :D** + + +### 목록 + + - [리스코프 치환 원칙]() + - [인터페이스 분리]() + - [의존성 역전]() + + diff --git a/SOLID/Week3_LSP.pptx b/SOLID/Week3_LSP.pptx index bd10e7c..caf818d 100644 Binary files a/SOLID/Week3_LSP.pptx and b/SOLID/Week3_LSP.pptx differ diff --git a/SOLID/Week4_IS.pptx b/SOLID/Week4_IS.pptx index 6dbd309..9778bdc 100644 Binary files a/SOLID/Week4_IS.pptx and b/SOLID/Week4_IS.pptx differ diff --git a/SOLID/Week8_DI.pptx b/SOLID/Week8_DI.pptx new file mode 100644 index 0000000..cb5cd34 Binary files /dev/null and b/SOLID/Week8_DI.pptx differ AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル