QGearsResource.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <OgreDataStream.h>
  17. #include <OgreResource.h>
  18. #include <OgreResourceGroupManager.h>
  19. #include "common/TypeDefine.h"
  20. #include "QGearsPrerequisites.h"
  21. namespace QGears{
  22. /**
  23. * A resource.
  24. */
  25. class _QGearsExport Resource : public Ogre::Resource{
  26. public:
  27. /**
  28. * Constructor.
  29. *
  30. * Initializes a resource.
  31. *
  32. * @param creator[in] The resource manager that handles the
  33. * resource creation.
  34. * @param name[in] A name for the resource.
  35. * @param handle[in] Ogre object that will handle the resource.
  36. * @param group[in] Name of the group to include the resource in.
  37. * @pram manual[in] Indicates if the resource is a {@see
  38. * QGearsManualObject}.
  39. * @param loader[in] Ogre resource loader for the resource.
  40. */
  41. Resource(
  42. Ogre::ResourceManager *creator, const String &name,
  43. Ogre::ResourceHandle handle, const String &group,
  44. bool manual, Ogre::ManualResourceLoader *loader
  45. ): Ogre::Resource(creator, name, handle, group, manual, loader)
  46. {}
  47. /**
  48. * Destructor.
  49. */
  50. virtual ~Resource() = default;
  51. protected:
  52. /**
  53. * Opens the resource.
  54. *
  55. * @return A pointer to the resource.
  56. */
  57. virtual Ogre::DataStreamPtr openResource(){
  58. // Last parameter to true to throw an exception.
  59. // Change when ready.
  60. return Ogre::ResourceGroupManager::getSingleton().openResource(
  61. mName, mGroup, this, false
  62. );
  63. }
  64. private:
  65. };
  66. }