DummyResource.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/Resource/ResourceObject.h>
  7. namespace anki
  8. {
  9. /// @addtogroup resource_private
  10. /// @{
  11. /// A dummy resource for the unit tests of the ResourceManager
  12. class DummyResource : public ResourceObject
  13. {
  14. public:
  15. DummyResource(ResourceManager* manager)
  16. : ResourceObject(manager)
  17. {
  18. }
  19. ~DummyResource()
  20. {
  21. if(m_memory)
  22. {
  23. getAllocator().deallocate(m_memory, 128);
  24. }
  25. }
  26. ANKI_USE_RESULT Error load(const ResourceFilename& filename, Bool async)
  27. {
  28. Error err = Error::NONE;
  29. if(filename.find("error") == ResourceFilename::NPOS)
  30. {
  31. m_memory = getAllocator().allocate(128);
  32. void* tempMem = getTempAllocator().allocate(128);
  33. (void)tempMem;
  34. getTempAllocator().deallocate(tempMem, 128);
  35. }
  36. else
  37. {
  38. ANKI_RESOURCE_LOGE("Dummy error");
  39. err = Error::USER_DATA;
  40. }
  41. return err;
  42. }
  43. private:
  44. void* m_memory = nullptr;
  45. };
  46. /// @}
  47. } // end namespace anki