QGearsApplication.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. -----------------------------------------------------------------------------
  3. Copyright (c) 19.10.2013 Tobias Peters <tobias.peters@kreativeffekt.at>
  4. This file is part of Q-Gears
  5. Q-Gears is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 2.0 (GPLv2) of the License.
  8. Q-Gears is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. -----------------------------------------------------------------------------
  13. */
  14. #ifndef __QGearsApplication_H__
  15. #define __QGearsApplication_H__
  16. #include <OgreRoot.h>
  17. #include <OgreOverlaySystem.h>
  18. #include <memory>
  19. #include "TypeDefine.h"
  20. namespace QGears
  21. {
  22. class Application : public Ogre::Singleton<Application>
  23. {
  24. public:
  25. Application(Ogre::String pluginsFileName, Ogre::String resourcesFile, Ogre::String logFileName)
  26. : m_plugins_filename(pluginsFileName), m_resources_filename(resourcesFile), m_log_filename(logFileName)
  27. {
  28. }
  29. Application( int argc, char *argv[] );
  30. virtual ~Application();
  31. bool initOgre( bool hideWindow = false );
  32. Ogre::Root* getRoot( void );
  33. Ogre::RenderWindow* getRenderWindow( void );
  34. const String& getResourcesFilename( void );
  35. protected:
  36. String getWindowTitle( void ) const;
  37. bool processCommandLine( int argc, char *argv[] );
  38. void registerArchiveFactories( void );
  39. void loadResourcesConfig( void );
  40. void initComponents( void );
  41. void destroyComponents( void );
  42. void createResourceManagers( void );
  43. void destroyResourceManagers( void );
  44. private:
  45. typedef std::vector<std::shared_ptr<Ogre::ResourceManager>> ResourceManagerVector;
  46. static const char* CLI_SECTION_GENERIC;
  47. static const char* CLI_HELP;
  48. static const char* CLI_HELP_DESCRIPTION;
  49. static const char* CLI_CONFIG_FILE;
  50. static const char* CLI_CONFIG_FILE_DESCRIPTION;
  51. static const char* CLI_LOG_FILE;
  52. static const char* CLI_LOG_FILE_DESCRIPTION;
  53. static const char* CLI_PLUGINS_FILE;
  54. static const char* CLI_PLUGINS_FILE_DESCRIPTION;
  55. static const char* CLI_RESOURCES_FILE;
  56. static const char* CLI_RESOURCES_FILE_DESCRIPTION;
  57. int m_argc = 0;
  58. char **m_argv = nullptr;
  59. String m_config_filename;
  60. String m_log_filename;
  61. String m_plugins_filename;
  62. String m_resources_filename;
  63. bool m_initialized = false;
  64. std::unique_ptr<Ogre::Root> m_root;
  65. std::unique_ptr<Ogre::OverlaySystem> m_overlay_system;
  66. Ogre::RenderWindow* m_render_window = nullptr; // Not owned
  67. ResourceManagerVector m_resource_managers;
  68. };
  69. }
  70. #endif // __QGearsApplication_H__