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 #if DEBUG 59 // This function should be called on every addrlib entrypoint (usually implicit by GetLib()) SetDebugPrinters()60 VOID SetDebugPrinters() const { ApplyDebugPrinters(m_client.callbacks.debugPrint, m_client.handle); } 61 #endif 62 GetClient()63 const Client* GetClient() const {return &m_client;} 64 65 protected: 66 Client m_client; 67 68 static VOID* ClientAlloc(size_t size, const Client* pClient); 69 static VOID ClientFree(VOID* pObj, const Client* pClient); 70 71 private: 72 // disallow the copy constructor 73 Object(const Object& a); 74 75 // disallow the assignment operator 76 Object& operator=(const Object& a); 77 }; 78 79 } // Addr 80 #endif 81