GrObject.cpp 855 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #include <AnKi/Gr/GrObject.h>
  6. #include <AnKi/Gr/GrManager.h>
  7. namespace anki
  8. {
  9. GrObject::GrObject(GrManager* manager, GrObjectType type, CString name)
  10. : m_manager(manager)
  11. , m_uuid(m_manager->getNewUuid())
  12. , m_refcount(0)
  13. , m_type(type)
  14. {
  15. if(name.getLength() == 0)
  16. {
  17. name = "N/A";
  18. }
  19. m_name = static_cast<Char*>(manager->getAllocator().getMemoryPool().allocate(name.getLength() + 1, alignof(Char)));
  20. memcpy(m_name, &name[0], name.getLength() + 1);
  21. }
  22. GrObject::~GrObject()
  23. {
  24. if(m_name)
  25. {
  26. m_manager->getAllocator().getMemoryPool().free(m_name);
  27. }
  28. }
  29. GrAllocator<U8> GrObject::getAllocator() const
  30. {
  31. return m_manager->getAllocator();
  32. }
  33. } // end namespace anki