VGearsPFileManager.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #include "data/VGearsPFileManager.h"
  16. /**
  17. * '.P' file manager singleton.
  18. */
  19. template<> VGears::PFileManager
  20. *Ogre::Singleton<VGears::PFileManager>::msSingleton = nullptr;
  21. namespace VGears {
  22. PFileManager *PFileManager::GetSingletonPtr(){return msSingleton;}
  23. PFileManager &PFileManager::GetSingleton(){
  24. assert( msSingleton );
  25. return(*msSingleton );
  26. }
  27. PFileManager::PFileManager(){
  28. mResourceType = PFile::RESOURCE_TYPE;
  29. // Low, because it will likely reference other resources.
  30. mLoadOrder = 30.0f;
  31. // This is how the ResourceManager registers with OGRE.
  32. Ogre::ResourceGroupManager::getSingleton()._registerResourceManager(
  33. mResourceType, this
  34. );
  35. }
  36. PFileManager::~PFileManager(){
  37. Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(
  38. mResourceType
  39. );
  40. }
  41. Ogre::Resource *PFileManager::createImpl(
  42. const Ogre::String &name, Ogre::ResourceHandle handle,
  43. const Ogre::String &group, bool is_manual,
  44. Ogre::ManualResourceLoader *loader,
  45. const Ogre::NameValuePairList *create_params
  46. ){
  47. return new PFile(this, name, handle, group, is_manual, loader);
  48. }
  49. }