GrObject.cpp 720 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2009-present, 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. GrObject::GrObject(GrObjectType type, CString name)
  9. : m_uuid(GrManager::getSingleton().getNewUuid())
  10. , m_refcount(0)
  11. , m_type(type)
  12. {
  13. if(name.getLength() == 0)
  14. {
  15. name = "N/A";
  16. }
  17. m_name = static_cast<Char*>(GrMemoryPool::getSingleton().allocate(name.getLength() + 1, alignof(Char)));
  18. memcpy(m_name, &name[0], name.getLength() + 1);
  19. }
  20. GrObject::~GrObject()
  21. {
  22. if(m_name)
  23. {
  24. GrMemoryPool::getSingleton().free(m_name);
  25. }
  26. }
  27. } // end namespace anki