QGearsHRCFileManager.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <OgreResourceManager.h>
  17. #include "QGearsPrerequisites.h"
  18. #include "common/TypeDefine.h"
  19. #include "QGearsHRCFile.h"
  20. namespace QGears{
  21. /**
  22. * A manager for HRC files.
  23. */
  24. class _QGearsExport HRCFileManager :
  25. public Ogre::ResourceManager, public Ogre::Singleton<HRCFileManager>
  26. {
  27. public:
  28. /**
  29. * Constructor.
  30. */
  31. HRCFileManager();
  32. /**
  33. * Destructor.
  34. */
  35. virtual ~HRCFileManager();
  36. /**
  37. * Parses a HRC script and creates a skeleton.
  38. *
  39. * @param stream[in] Script content.
  40. * @param group_name[in] GRoup to add the skeleton to.
  41. */
  42. virtual void ParseScript(
  43. Ogre::DataStreamPtr &stream, const String &group_name
  44. );
  45. /**
  46. * Retrieves a singleton to the manager.
  47. */
  48. static HRCFileManager& GetSingleton();
  49. /**
  50. * Retrieves a pointer to the manager singleton.
  51. */
  52. static HRCFileManager* GetSingletonPtr();
  53. protected:
  54. /**
  55. * Loads the manager.
  56. *
  57. * @param name[in] The unique name of the manager.
  58. * @param handle[in] @todo Understand and document.
  59. * @param group[in] The name of the resource group to which this
  60. * resource belong.
  61. * @param is_manual[in] True if the resource is manually loaded,
  62. * false otherwise.
  63. * @param loader[in] Pointer to a ManualResourceLoader
  64. * implementation which will be called when the Resource wishes to
  65. * load (should be supplied if is_manual is set to true). It can be
  66. * null, but the Resource will never be able to reload if anything
  67. * ever causes it to unload. Therefore provision of a proper
  68. * ManualResourceLoader instance is strongly recommended.
  69. * @param create_params[in] Unused.
  70. */
  71. virtual Ogre::Resource *createImpl(
  72. const Ogre::String &name, Ogre::ResourceHandle handle,
  73. const Ogre::String &group, bool is_manual,
  74. Ogre::ManualResourceLoader *loader,
  75. const Ogre::NameValuePairList *create_params
  76. ) override final;
  77. };
  78. }