From 33a7d7ef17a3db7497ddc28ab79531b3752d8b55 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 10 Jan 2021 15:47:41 -0800 Subject: IBufferSuballocation: added SetUserData()/GetUserData() methods --- Graphics/GraphicsTools/interface/BufferSuballocator.h | 15 +++++++++++++++ Graphics/GraphicsTools/src/BufferSuballocator.cpp | 12 ++++++++++++ 2 files changed, 27 insertions(+) (limited to 'Graphics/GraphicsTools') diff --git a/Graphics/GraphicsTools/interface/BufferSuballocator.h b/Graphics/GraphicsTools/interface/BufferSuballocator.h index 93c99db1..23fbdbbf 100644 --- a/Graphics/GraphicsTools/interface/BufferSuballocator.h +++ b/Graphics/GraphicsTools/interface/BufferSuballocator.h @@ -60,6 +60,21 @@ struct IBufferSuballocation : public IObject /// Returns the pointer to the parent allocator. virtual IBufferSuballocator* GetAllocator() = 0; + + /// Stores a pointer to the user-provided data object, which + /// may later be retreived through GetUserData(). + /// + /// \param [in] pUserData - Pointer to the user data object to store. + /// + /// \note The method is not thread-safe and an application + /// must externally synchronize the access. + virtual void SetUserData(IObject* pUserData) = 0; + + /// Returns the pointer to the user data object previously + /// set with SetUserData() method. + /// + /// \return Pointer to the user data object + virtual IObject* GetUserData() const = 0; }; diff --git a/Graphics/GraphicsTools/src/BufferSuballocator.cpp b/Graphics/GraphicsTools/src/BufferSuballocator.cpp index 8dcb2879..2c5d60cd 100644 --- a/Graphics/GraphicsTools/src/BufferSuballocator.cpp +++ b/Graphics/GraphicsTools/src/BufferSuballocator.cpp @@ -92,6 +92,16 @@ public: virtual IBufferSuballocator* GetAllocator() override final; + virtual void SetUserData(IObject* pUserData) override final + { + m_pUserData = pUserData; + } + + virtual IObject* GetUserData() const override final + { + return m_pUserData.RawPtr(); + } + private: RefCntAutoPtr m_pParentAllocator; @@ -99,6 +109,8 @@ private: const Uint32 m_Offset; const Uint32 m_Size; + + RefCntAutoPtr m_pUserData; }; class BufferSuballocatorImpl final : public ObjectBase -- cgit v1.2.3