Common.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef ANKI_SCENE_COMMON_H
  2. #define ANKI_SCENE_COMMON_H
  3. #include "anki/util/Allocator.h"
  4. #include "anki/util/Vector.h"
  5. #include "anki/util/StdTypes.h"
  6. #include "anki/util/Dictionary.h"
  7. #include "anki/util/Object.h"
  8. #include <memory>
  9. namespace anki {
  10. // Forward
  11. class SceneNode;
  12. /// @addtogroup Scene
  13. /// @{
  14. /// The type of the scene's allocator
  15. template<typename T>
  16. using SceneAllocator = StackAllocator<T, false>;
  17. /// The type of the scene's frame allocator
  18. template<typename T>
  19. using SceneFrameAllocator = StackAllocator<T, false>;
  20. /// Scene string
  21. typedef std::basic_string<char, std::char_traits<char>,
  22. SceneAllocator<char>> SceneString;
  23. /// Scene vector
  24. template<typename T>
  25. using SceneVector = Vector<T, SceneAllocator<T>>;
  26. /// The same as SceneVector. Different name to show the difference
  27. template<typename T>
  28. using SceneFrameVector = Vector<T, SceneFrameAllocator<T>>;
  29. /// Scene dictionary
  30. template<typename T>
  31. using SceneDictionary =
  32. Dictionary<T, SceneAllocator<std::pair<const char*, T>>>;
  33. /// Deleter for shared pointers
  34. template<typename T>
  35. struct SceneSharedPtrDeleter
  36. {
  37. void operator()(T* x)
  38. {
  39. ANKI_ASSERT(x);
  40. SceneAllocator<U8> alloc = x->getSceneAllocator();
  41. deleteObject(alloc, x);
  42. }
  43. };
  44. /// Shared pointer in scene
  45. template<typename T>
  46. using SceneSharedPointer = std::shared_ptr<T>;
  47. /// Scene object
  48. template<typename T>
  49. using SceneHierarchicalObject = Object<T, SceneAllocator<T>>;
  50. /// @}
  51. } // end namespace anki
  52. #endif