1 /* 2 ************************************************************************************************************************ 3 * 4 * Copyright (C) 2007-2022 Advanced Micro Devices, Inc. All rights reserved. 5 * SPDX-License-Identifier: MIT 6 * 7 ***********************************************************************************************************************/ 8 9 10 /** 11 **************************************************************************************************** 12 * @file addrobject.h 13 * @brief Contains the Object base class definition. 14 **************************************************************************************************** 15 */ 16 17 #ifndef __ADDR_OBJECT_H__ 18 #define __ADDR_OBJECT_H__ 19 20 #include "addrtypes.h" 21 #include "addrcommon.h" 22 23 namespace Addr 24 { 25 26 /** 27 **************************************************************************************************** 28 * @brief This structure contains client specific data 29 **************************************************************************************************** 30 */ 31 struct Client 32 { 33 ADDR_CLIENT_HANDLE handle; 34 ADDR_CALLBACKS callbacks; 35 }; 36 /** 37 **************************************************************************************************** 38 * @brief This class is the base class for all ADDR class objects. 39 **************************************************************************************************** 40 */ 41 class Object 42 { 43 public: 44 Object(); 45 Object(const Client* pClient); 46 virtual ~Object(); 47 48 VOID* operator new(size_t size, VOID* pMem) noexcept; 49 VOID operator delete(VOID* pObj); 50 /// Microsoft compiler requires a matching delete implementation, which seems to be called when 51 /// bad_alloc is thrown. But currently C++ exception isn't allowed so a dummy implementation is 52 /// added to eliminate the warning. delete(VOID * pObj,VOID * pMem)53 VOID operator delete(VOID* pObj, VOID* pMem) { ADDR_ASSERT_ALWAYS(); } 54 55 VOID* Alloc(size_t size) const; 56 VOID Free(VOID* pObj) const; 57 58 VOID DebugPrint(const CHAR* pDebugString, ...) const; 59 GetClient()60 const Client* GetClient() const {return &m_client;} 61 62 protected: 63 Client m_client; 64 65 static VOID* ClientAlloc(size_t size, const Client* pClient); 66 static VOID ClientFree(VOID* pObj, const Client* pClient); 67 68 private: 69 // disallow the copy constructor 70 Object(const Object& a); 71 72 // disallow the assignment operator 73 Object& operator=(const Object& a); 74 }; 75 76 } // Addr 77 #endif 78