VGearsResource.h 2.3 KB

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