diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-01-25 22:33:42 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-01-25 22:33:42 +0000 |
| commit | 75d892e4358f877a5db23b20930b680aee6415d9 (patch) | |
| tree | a01881662936340d1e2bb4fa0a970e10a26c8140 /Primitives/interface | |
| parent | Fixed issue with SHADER_SOURCE_LANGUAGE SourceLanguage member (diff) | |
| download | DiligentCore-75d892e4358f877a5db23b20930b680aee6415d9.tar.gz DiligentCore-75d892e4358f877a5db23b20930b680aee6415d9.zip | |
c inteface: implemented core object VTBLs
Diffstat (limited to 'Primitives/interface')
| -rw-r--r-- | Primitives/interface/Object.h | 26 | ||||
| -rw-r--r-- | Primitives/interface/ReferenceCounters.h | 16 |
2 files changed, 30 insertions, 12 deletions
diff --git a/Primitives/interface/Object.h b/Primitives/interface/Object.h index 6dc8333f..1b3dbaf9 100644 --- a/Primitives/interface/Object.h +++ b/Primitives/interface/Object.h @@ -41,8 +41,6 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) class IObject { public: - using CounterValueType = IReferenceCounters::CounterValueType; - /// Queries the specific interface. /// \param [in] IID - Unique identifier of the requested interface. @@ -60,7 +58,7 @@ public: /// \return The number of strong references after incrementing the counter. /// \note In a multithreaded environment, the returned number may not be reliable /// as other threads may simultaneously change the actual value of the counter. - virtual CounterValueType AddRef() = 0; + virtual ReferenceCounterValueType AddRef() = 0; /// Decrements the number of strong references by 1 and destroys the object when the @@ -73,7 +71,7 @@ public: /// as other threads may simultaneously change the actual value of the counter. /// The only reliable value is 0 as the object is destroyed when the last /// strong reference is released. - virtual CounterValueType Release() = 0; + virtual ReferenceCounterValueType Release() = 0; /// Returns the pointer to IReferenceCounters interface of the associated @@ -84,6 +82,26 @@ public: #else +struct IObject; + +struct IObjectVtbl +{ + void (*QueryInterface)(const struct INTERFACE_ID* IID, struct IObject** ppInterface); + ReferenceCounterValueType (*AddRef)(); + ReferenceCounterValueType (*Release)(); + class IReferenceCounters* (*GetReferenceCounters)(); +}; + +struct IObject +{ + struct IObjectVtbl* pObjectVtbl; + struct IObjectVtbl* pDeviceObjectVtbl; +}; + +# define IObject_QueryInterface(This, ...) (This)->pDeviceObjectVtbl->QueryInterface(This, __VA_ARGS__) +# define IObject_AddRef(This, ...) (This)->pDeviceObjectVtbl->AddRef(This, __VA_ARGS__) +# define IObject_Release(This) (This)->pDeviceObjectVtbl->Release() + #endif DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Primitives/interface/ReferenceCounters.h b/Primitives/interface/ReferenceCounters.h index 297d71b8..793761a7 100644 --- a/Primitives/interface/ReferenceCounters.h +++ b/Primitives/interface/ReferenceCounters.h @@ -34,6 +34,8 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) +typedef long ReferenceCounterValueType; + #if DILIGENT_CPP_INTERFACE /// Base interface for a reference counter object that stores the number of strong and @@ -42,15 +44,13 @@ DILIGENT_BEGIN_NAMESPACE(Diligent) class IReferenceCounters { public: - using CounterValueType = long; - /// Increments the number of strong references by 1. /// \return The number of strong references after incrementing the counter. /// \remark The method is thread-safe and does not require explicit synchronization. /// \note In a multithreaded environment, the returned number may not be reliable /// as other threads may simultaneously change the actual value of the counter. - virtual CounterValueType AddStrongRef() = 0; + virtual ReferenceCounterValueType AddStrongRef() = 0; /// Decrements the number of strong references by 1 and destroys the referenced object @@ -66,7 +66,7 @@ public: /// as other threads may simultaneously change the actual value of the counter. /// The only reliable value is 0 as the object is destroyed when the last /// strong reference is released. - virtual CounterValueType ReleaseStrongRef() = 0; + virtual ReferenceCounterValueType ReleaseStrongRef() = 0; /// Increments the number of weak references by 1. @@ -75,7 +75,7 @@ public: /// \remark The method is thread-safe and does not require explicit synchronization. /// \note In a multithreaded environment, the returned number may not be reliable /// as other threads may simultaneously change the actual value of the counter. - virtual CounterValueType AddWeakRef() = 0; + virtual ReferenceCounterValueType AddWeakRef() = 0; /// Decrements the number of weak references by 1. If there are no more strong and weak @@ -85,7 +85,7 @@ public: /// \remark The method is thread-safe and does not require explicit synchronization. /// \note In a multithreaded environment, the returned number may not be reliable /// as other threads may simultaneously change the actual value of the counter. - virtual CounterValueType ReleaseWeakRef() = 0; + virtual ReferenceCounterValueType ReleaseWeakRef() = 0; /// Gets the pointer to the IUnknown interface of the referenced object. @@ -107,7 +107,7 @@ public: /// as other threads may simultaneously change the actual value of the counter. /// The only reliable value is 0 as the object is destroyed when the last /// strong reference is released. - virtual CounterValueType GetNumStrongRefs() const = 0; + virtual ReferenceCounterValueType GetNumStrongRefs() const = 0; /// Returns the number of outstanding weak references. @@ -115,7 +115,7 @@ public: /// \return The number of weak references. /// \note In a multithreaded environment, the returned number may not be reliable /// as other threads may simultaneously change the actual value of the counter. - virtual CounterValueType GetNumWeakRefs() const = 0; + virtual ReferenceCounterValueType GetNumWeakRefs() const = 0; }; #else |
