/DiamondCore Engine/Interfaces/MainCore.h

https://bitbucket.org/diamondcore/diamondcore-engine · C Header · 131 lines · 68 code · 36 blank · 27 comment · 0 complexity · 505bdb3d4fbb9d0f988dfee502c1030a MD5 · raw file

  1. #pragma once
  2. #include <Windows.h>
  3. #include "../DataTypes.h"
  4. #include "../Messaging System\MessageDispatcher.h"
  5. #include "../Interfaces.h"
  6. //*******************************************
  7. /*
  8. This is the Main Core. It coordinates all communication between
  9. engine core DLL's, housing the shared memory manager and
  10. messaging system.
  11. */
  12. class MainCore
  13. {
  14. public:
  15. MainCore(HINSTANCE inst);
  16. ~MainCore(void);
  17. //Accessors for core handles
  18. int LoadCoreDLL(char *cFilePath, CoreType eType);
  19. int ReleaseCoreDLL(CoreType eType);
  20. // core specific accessors
  21. IAICore* GetAICore();
  22. IGraphicsCore* GetGraphicsCore();
  23. IInputCore* GetInputCore();
  24. ISoundCore* GetSoundCore();
  25. ////////////////////
  26. // SCRATCH PAD VARS
  27. ////////////////////
  28. HRESULT hr;
  29. // Temporarily public while engine is restructured
  30. Module* m_mMainMemory;
  31. // message dispatcher
  32. MessageDispatcher* m_pMessageDisp;
  33. inline MemoryManager* GetMemoryManager() { return m_pMemManager; }
  34. void Update(float dt);
  35. inline float GetElapsedTime() { return m_fTimeElapsed; };
  36. void Shutdown();
  37. vector<BaseCore*> m_vActiveCores;
  38. struct EngineUpdateInfo
  39. {
  40. public:
  41. EngineUpdateInfo(MainCore* mainCore, BaseCore* coreToUpdate) :
  42. m_MainCore(mainCore), m_bCoreToUpdate(coreToUpdate) {}
  43. MainCore* m_MainCore;
  44. BaseCore* m_bCoreToUpdate;
  45. };
  46. private:
  47. // Core Handles
  48. HMODULE m_hGraphicsDLL;
  49. HMODULE m_hAIDLL;
  50. HMODULE m_hInputDLL;
  51. HMODULE m_hSoundDLL;
  52. HMODULE m_hScriptingDLL;
  53. HINSTANCE hInst;
  54. // Core Interface Pointers
  55. IGraphicsCore *m_pIGraphics;
  56. IAICore *m_pIAI;
  57. IInputCore *m_pIInput;
  58. ISoundCore *m_pISound;
  59. // memory manager
  60. MemoryManager* m_pMemManager;
  61. // setting Core Variables
  62. void SetCoreVars(CoreType eType, BaseCore* pointerToCore);
  63. //TODO: This WILL run out of precision eventually.
  64. // consider making a XNA/.NET style GameTime/DateTime object
  65. // for larger precision
  66. float m_fTimeElapsed;
  67. void BeginUpdateLoop();
  68. };
  69. // externing (in C-style) all the creation and release of the COM objects
  70. extern "C"
  71. {
  72. // create and release of graphics
  73. HRESULT CreateGraphicsObject(HINSTANCE hDLL, IGraphicsCore **pInterface);
  74. HRESULT ReleaseGraphicsObject(IGraphicsCore **pInterface);
  75. // create and release of AI
  76. HRESULT CreateAIObject(HINSTANCE hDLL, IAICore **pInterface);
  77. HRESULT ReleaseAIObject(IAICore **pInterface);
  78. // create and release of Input
  79. HRESULT CreateInputObject(HINSTANCE hDLL, IInputCore **pInterface);
  80. HRESULT ReleaseInputObject(IInputCore **pInterface);
  81. // create and release of Sound
  82. HRESULT CreateSoundObject(HINSTANCE hDLL, ISoundCore **pInterface);
  83. HRESULT ReleaseSoundObject(ISoundCore **pInterface);
  84. }
  85. // function pointers to allow for address of creation and release functions
  86. // to be acquired
  87. typedef HRESULT (*CREATEAIOBJECT)(HINSTANCE hDLL, IAICore **pInterface);
  88. typedef HRESULT(*RELEASEAIOBJECT)(IAICore **pInterface);
  89. typedef HRESULT (*CREATEINPUTOBJECT)(HINSTANCE hDLL, IInputCore **pInterface);
  90. typedef HRESULT(*RELEASEINPUTOBJECT)(IInputCore **pInterface);
  91. typedef HRESULT (*CREATEGRAPHICSOBJECT)(HINSTANCE hDLL, IGraphicsCore **pInterface);
  92. typedef HRESULT(*RELEASEGRAPHICSOBJECT)(IGraphicsCore **pInterface);
  93. typedef HRESULT (*CREATESOUNDOBJECT)(HINSTANCE hDLL, ISoundCore **pInterface);
  94. typedef HRESULT(*RELEASESOUNDOBJECT)(ISoundCore **pInterface);
  95. DWORD WINAPI UpdateCore(void* data);