DummyResource.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. /// @addtogroup resource_private
  9. /// @{
  10. /// A dummy resource for the unit tests of the ResourceManager
  11. class DummyResource : public ResourceObject
  12. {
  13. public:
  14. DummyResource(ResourceManager* manager)
  15. : ResourceObject(manager)
  16. {
  17. }
  18. ~DummyResource()
  19. {
  20. if(m_memory)
  21. {
  22. getAllocator().deallocate(m_memory, 128);
  23. }
  24. }
  25. ANKI_USE_RESULT Error load(const ResourceFilename& filename, Bool async)
  26. {
  27. Error err = Error::NONE;
  28. if(filename.find("error") == ResourceFilename::NPOS)
  29. {
  30. m_memory = getAllocator().allocate(128);
  31. void* tempMem = getTempAllocator().allocate(128);
  32. (void)tempMem;
  33. getTempAllocator().deallocate(tempMem, 128);
  34. }
  35. else
  36. {
  37. ANKI_RESOURCE_LOGE("Dummy error");
  38. err = Error::USER_DATA;
  39. }
  40. return err;
  41. }
  42. private:
  43. void* m_memory = nullptr;
  44. };
  45. /// @}
  46. } // end namespace anki