QGearsApplication.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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( int argc, char *argv[] );
  26. virtual ~Application();
  27. bool initOgre( void );
  28. Ogre::Root* getRoot( void );
  29. Ogre::RenderWindow* getRenderWindow( void );
  30. const String& getResourcesFilename( void );
  31. protected:
  32. String getWindowTitle( void ) const;
  33. bool processCommandLine( int argc, char *argv[] );
  34. void registerArchiveFactories( void );
  35. void loadResourcesConfig( void );
  36. void initComponents( void );
  37. void destroyComponents( void );
  38. void createResourceManagers( void );
  39. void destroyResourceManagers( void );
  40. private:
  41. typedef std::vector<std::shared_ptr<Ogre::ResourceManager>> ResourceManagerVector;
  42. Application();
  43. static const char* CLI_SECTION_GENERIC;
  44. static const char* CLI_HELP;
  45. static const char* CLI_HELP_DESCRIPTION;
  46. static const char* CLI_CONFIG_FILE;
  47. static const char* CLI_CONFIG_FILE_DESCRIPTION;
  48. static const char* CLI_LOG_FILE;
  49. static const char* CLI_LOG_FILE_DESCRIPTION;
  50. static const char* CLI_PLUGINS_FILE;
  51. static const char* CLI_PLUGINS_FILE_DESCRIPTION;
  52. static const char* CLI_RESOURCES_FILE;
  53. static const char* CLI_RESOURCES_FILE_DESCRIPTION;
  54. int m_argc = 0;
  55. char **m_argv = nullptr;
  56. String m_config_filename;
  57. String m_log_filename;
  58. String m_plugins_filename;
  59. String m_resources_filename;
  60. bool m_initialized = false;
  61. std::unique_ptr<Ogre::Root> m_root;
  62. std::unique_ptr<Ogre::OverlaySystem> m_overlay_system;
  63. Ogre::RenderWindow* m_render_window = nullptr; // Not owned
  64. ResourceManagerVector m_resource_managers;
  65. };
  66. }
  67. #endif // __QGearsApplication_H__