/** * @file XTPTypeId.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(_XTPTYPEID_H_) # define _XTPTYPEID_H_ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTypeId { public: explicit CXTPTypeId(DWORD_PTR id); CXTPTypeId(const CXTPTypeId& rhs); BOOL operator==(const CXTPTypeId& rhs) const; BOOL operator!=(const CXTPTypeId& rhs) const; private: DWORD_PTR m_id; }; AFX_INLINE CXTPTypeId::CXTPTypeId(DWORD_PTR id) : m_id(id) { } AFX_INLINE CXTPTypeId::CXTPTypeId(const CXTPTypeId& rhs) : m_id(rhs.m_id) { } AFX_INLINE BOOL CXTPTypeId::operator==(const CXTPTypeId& rhs) const { return m_id == rhs.m_id; } AFX_INLINE BOOL CXTPTypeId::operator!=(const CXTPTypeId& rhs) const { return m_id != rhs.m_id; } template class CXTPTypeIdProvider; class _XTP_EXT_CLASS CXTPTypeIdProviderBase { # if _MSC_VER > 1200 protected: template friend class CXTPTypeIdProvider; # else public: # endif struct DerivedList { DerivedList(CXTPTypeId derivedTypeId, CXTPTypeIdProviderBase* pTypeProvider, void* pInstance, DerivedList* pFLink); CXTPTypeId derivedTypeId; CXTPTypeIdProviderBase* pTypeProvider; void* pInstance; DerivedList* pFLink; }; explicit CXTPTypeIdProviderBase(CXTPTypeId typeId); virtual ~CXTPTypeIdProviderBase(); virtual CXTPTypeId GetTypeId() const; void AddDerived(CXTPTypeId typeId, CXTPTypeIdProviderBase* pTypeProvider, void* pInstance); template AFX_INLINE T* TryCast() const; void* TryCastTo(CXTPTypeId typeId) const; const CXTPTypeId m_typeId; DerivedList* m_pDerivedList; }; template class CXTPTypeIdProvider : # if _MSC_VER > 1200 private CXTPTypeIdProviderBase { template friend class CXTPTypeIdProvider; protected: # else public CXTPTypeIdProviderBase { public: # endif typedef CXTPTypeIdProvider XTPTypeIdProvider; CXTPTypeIdProvider(); public: using CXTPTypeIdProviderBase::GetTypeId; using CXTPTypeIdProviderBase::TryCastTo; }; template class CXTPTypeIdOf { public: static CXTPTypeId AFX_CDECL Id(); }; template AFX_INLINE T* CXTPTypeIdProviderBase::TryCast() const { return reinterpret_cast(TryCastTo(CXTPTypeIdOf::Id())); } template AFX_INLINE CXTPTypeIdProvider::CXTPTypeIdProvider() : CXTPTypeIdProviderBase(CXTPTypeIdOf::Id()) { typename Parent::XTPTypeIdProvider* pParent = static_cast( static_cast(this)); pParent->AddDerived(GetTypeId(), this, static_cast(this)); } template AFX_INLINE CXTPTypeId AFX_CDECL CXTPTypeIdOf::Id() { static const CXTPTypeId id(reinterpret_cast(&CXTPTypeIdOf::Id)); return id; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(_XTPTYPEID_H_) /** @endcond */