.vs
Assets
Library
APIUpdater
Artifacts
Bee
BuildPlayerData
PackageCache
com.unity.collab-proxy@2.5.2
com.unity.editorcoroutines@1.0.0
com.unity.ext.nunit@1.0.6
com.unity.feature.development@1.0.1
com.unity.ide.rider@3.0.31
com.unity.ide.visualstudio@2.0.22
Documentation~
Editor
AppleEventIntegration~
COMIntegration
COMIntegration~
BStrHolder.h
CMakeLists.txt
COMIntegration.cpp
ComPtr.h
dte80a.tlh
howtobuild.txt
Release
Release.meta
Messaging
Plugins
ProjectGeneration
Testing
VSWhere
AssemblyInfo.cs
AssemblyInfo.cs.meta
AsyncOperation.cs
AsyncOperation.cs.meta
COMIntegration.meta
Cli.cs
Cli.cs.meta
Discovery.cs
Discovery.cs.meta
FileUtility.cs
FileUtility.cs.meta
Image.cs
Image.cs.meta
KnownAssemblies.cs
KnownAssemblies.cs.meta
Messaging.meta
Plugins.meta
ProcessRunner.cs
ProcessRunner.cs.meta
ProjectGeneration.meta
SimpleJSON.cs
SimpleJSON.cs.meta
Solution.cs
Solution.cs.meta
SolutionParser.cs
SolutionParser.cs.meta
SolutionProjectEntry.cs
SolutionProjectEntry.cs.meta
SolutionProperties.cs
SolutionProperties.cs.meta
Symbols.cs
Symbols.cs.meta
Testing.meta
UnityInstallation.cs
UnityInstallation.cs.meta
UsageUtility.cs
UsageUtility.cs.meta
VSWhere.meta
VersionPair.cs
VersionPair.cs.meta
VisualStudioCodeInstallation.cs
VisualStudioCodeInstallation.cs.meta
VisualStudioEditor.cs
VisualStudioEditor.cs.meta
VisualStudioForMacInstallation.cs
VisualStudioForMacInstallation.cs.meta
VisualStudioForWindowsInstallation.cs
VisualStudioForWindowsInstallation.cs.meta
VisualStudioInstallation.cs
VisualStudioInstallation.cs.meta
VisualStudioIntegration.cs
VisualStudioIntegration.cs.meta
com.unity.ide.visualstudio.asmdef
com.unity.ide.visualstudio.asmdef.meta
.signature
CHANGELOG.md
CHANGELOG.md.meta
CONTRIBUTING.md
CONTRIBUTING.md.meta
Editor.meta
LICENSE.md
LICENSE.md.meta
ThirdPartyNotices.md
ThirdPartyNotices.md.meta
ValidationConfig.json
ValidationConfig.json.meta
ValidationExceptions.json
ValidationExceptions.json.meta
package.json
package.json.meta
com.unity.ide.vscode@1.2.5
com.unity.modules.ai@1.0.0
com.unity.modules.androidjni@1.0.0
com.unity.modules.animation@1.0.0
com.unity.modules.assetbundle@1.0.0
com.unity.modules.audio@1.0.0
com.unity.modules.cloth@1.0.0
com.unity.modules.director@1.0.0
com.unity.modules.imageconversion@1.0.0
com.unity.modules.imgui@1.0.0
com.unity.modules.jsonserialize@1.0.0
com.unity.modules.particlesystem@1.0.0
com.unity.modules.physics2d@1.0.0
com.unity.modules.physics@1.0.0
com.unity.modules.screencapture@1.0.0
com.unity.modules.subsystems@1.0.0
com.unity.modules.terrain@1.0.0
com.unity.modules.terrainphysics@1.0.0
com.unity.modules.tilemap@1.0.0
com.unity.modules.ui@1.0.0
com.unity.modules.uielements@1.0.0
com.unity.modules.umbra@1.0.0
com.unity.modules.unityanalytics@1.0.0
com.unity.modules.unitywebrequest@1.0.0
com.unity.modules.unitywebrequestassetbundle@1.0.0
com.unity.modules.unitywebrequestaudio@1.0.0
com.unity.modules.unitywebrequesttexture@1.0.0
com.unity.modules.unitywebrequestwww@1.0.0
com.unity.modules.vehicles@1.0.0
com.unity.modules.video@1.0.0
com.unity.modules.vr@1.0.0
com.unity.modules.wind@1.0.0
com.unity.modules.xr@1.0.0
com.unity.performance.profile-analyzer@1.2.2
com.unity.settings-manager@2.0.1
com.unity.test-framework@1.1.33
com.unity.testtools.codecoverage@1.2.6
com.unity.textmeshpro@3.0.6
com.unity.timeline@1.7.6
com.unity.ugui@1.0.0
com.unity.visualscripting@1.9.4
PackageManager
PlayModeViewStates
PlayerDataCache
ScriptAssemblies
Search
ShaderCache
SplashScreenCache
StateCache
UIElements
AnnotationManager
ArtifactDB
ArtifactDB-lock
BuildPlayer.prefs
BuildSettings.asset
EditorOnlyScriptingSettings.json
EditorOnlyVirtualTextureState.json
EditorSnapSettings.asset
EditorUserBuildSettings.asset
InspectorExpandedItems.asset
LastBuild.buildreport
LastSceneManagerSetup.txt
LibraryFormatVersion.txt
MonoManager.asset
SceneVisibilityState.asset
ScriptMapper
ShaderCache.db
SourceAssetDB
SourceAssetDB-lock
SpriteAtlasDatabase.asset
Style.catalog
expandedItems
ilpp.pid
Logs
Packages
ProjectSettings
UserSettings
obj
.vsconfig
Assembly-CSharp.Player.csproj
Assembly-CSharp.csproj
TM1.sln
Unity.CollabProxy.Editor.csproj
Unity.EditorCoroutines.Editor.csproj
Unity.Performance.Profile-Analyzer.Editor.csproj
Unity.PlasticSCM.Editor.csproj
Unity.Rider.Editor.csproj
Unity.Settings.Editor.csproj
Unity.TestTools.CodeCoverage.Editor.OpenCover.Model.csproj
Unity.TestTools.CodeCoverage.Editor.OpenCover.Mono.Reflection.csproj
Unity.TestTools.CodeCoverage.Editor.csproj
Unity.TextMeshPro.Editor.csproj
Unity.TextMeshPro.Player.csproj
Unity.TextMeshPro.csproj
Unity.Timeline.Editor.csproj
Unity.Timeline.Player.csproj
Unity.Timeline.csproj
Unity.VSCode.Editor.csproj
Unity.VisualScripting.Core.Editor.csproj
Unity.VisualScripting.Core.Player.csproj
Unity.VisualScripting.Core.csproj
Unity.VisualScripting.Flow.Editor.csproj
Unity.VisualScripting.Flow.Player.csproj
Unity.VisualScripting.Flow.csproj
Unity.VisualScripting.SettingsProvider.Editor.csproj
Unity.VisualScripting.Shared.Editor.csproj
Unity.VisualScripting.State.Editor.csproj
Unity.VisualScripting.State.Player.csproj
Unity.VisualScripting.State.csproj
Unity.VisualStudio.Editor.csproj
UnityEditor.TestRunner.csproj
UnityEditor.UI.csproj
UnityEngine.TestRunner.Player.csproj
UnityEngine.TestRunner.csproj
UnityEngine.UI.Player.csproj
UnityEngine.UI.csproj
187 lines
2.9 KiB
C++
187 lines
2.9 KiB
C++
#pragma once
|
|
|
|
namespace win
|
|
{
|
|
template<typename T>
|
|
class ComPtr;
|
|
|
|
template<typename T>
|
|
class ComPtrRef
|
|
{
|
|
private:
|
|
ComPtr<T>& m_ComPtr;
|
|
|
|
ComPtrRef(ComPtr<T>& comPtr) :
|
|
m_ComPtr(comPtr)
|
|
{
|
|
}
|
|
|
|
friend class ComPtr<T>;
|
|
|
|
public:
|
|
inline operator T**()
|
|
{
|
|
return m_ComPtr.ReleaseAndGetAddressOf();
|
|
}
|
|
|
|
inline operator void**()
|
|
{
|
|
return reinterpret_cast<void**>(m_ComPtr.ReleaseAndGetAddressOf());
|
|
}
|
|
|
|
inline T* operator*() throw ()
|
|
{
|
|
return m_ComPtr;
|
|
}
|
|
|
|
};
|
|
|
|
template<typename T>
|
|
class ComPtr
|
|
{
|
|
private:
|
|
T *ptr;
|
|
|
|
public:
|
|
inline ComPtr(void) : ptr(NULL) {}
|
|
inline ~ComPtr(void) { this->Free(); }
|
|
|
|
ComPtr(T *ptr)
|
|
{
|
|
if (NULL != (this->ptr = ptr))
|
|
{
|
|
this->ptr->AddRef();
|
|
}
|
|
}
|
|
|
|
ComPtr(const ComPtr &ptr)
|
|
{
|
|
if (NULL != (this->ptr = ptr.ptr))
|
|
{
|
|
this->ptr->AddRef();
|
|
}
|
|
}
|
|
|
|
inline bool operator!() const
|
|
{
|
|
return (NULL == this->ptr);
|
|
}
|
|
|
|
inline operator T*() const { return this->ptr; }
|
|
|
|
inline T *operator->() const
|
|
{
|
|
//_assert(NULL != this->ptr);
|
|
return this->ptr;
|
|
}
|
|
|
|
inline T &operator*()
|
|
{
|
|
//_assert(NULL != this->ptr);
|
|
return *this->ptr;
|
|
}
|
|
|
|
inline ComPtrRef<T> operator&()
|
|
{
|
|
return ComPtrRef<T>(*this);
|
|
}
|
|
|
|
const ComPtr &operator=(T *ptr)
|
|
{
|
|
if (this->ptr != ptr)
|
|
{
|
|
this->Free();
|
|
|
|
if (NULL != (this->ptr = ptr))
|
|
{
|
|
this->ptr->AddRef();
|
|
}
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
const ComPtr &operator=(const ComPtr &ptr)
|
|
{
|
|
if (this->ptr != ptr.ptr)
|
|
{
|
|
this->Free();
|
|
|
|
if (NULL != (this->ptr = ptr.ptr))
|
|
{
|
|
this->ptr->AddRef();
|
|
}
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
void Free(void)
|
|
{
|
|
if (NULL != this->ptr)
|
|
{
|
|
this->ptr->Release();
|
|
this->ptr = NULL;
|
|
}
|
|
}
|
|
|
|
inline T** ReleaseAndGetAddressOf()
|
|
{
|
|
Free();
|
|
return &ptr;
|
|
}
|
|
|
|
template<typename U>
|
|
inline HRESULT As(ComPtrRef<U> p) const throw ()
|
|
{
|
|
return ptr->QueryInterface(__uuidof(U), p);
|
|
}
|
|
|
|
inline bool operator==(std::nullptr_t) const
|
|
{
|
|
return this->ptr == nullptr;
|
|
}
|
|
|
|
template<typename U>
|
|
inline bool operator==(U* other)
|
|
{
|
|
if (ptr == nullptr || other == nullptr)
|
|
return ptr == other;
|
|
|
|
ComPtr<IUnknown> meUnknown;
|
|
ComPtr<IUnknown> otherUnknown;
|
|
|
|
if (FAILED(this->ptr->QueryInterface(__uuidof(IUnknown), &meUnknown)))
|
|
return false;
|
|
|
|
if (FAILED(other->QueryInterface(__uuidof(IUnknown), &otherUnknown)))
|
|
return false;
|
|
|
|
return static_cast<IUnknown*>(meUnknown) == static_cast<IUnknown*>(otherUnknown);
|
|
}
|
|
|
|
template<typename U>
|
|
inline bool operator==(ComPtr<U>& other)
|
|
{
|
|
return *this == static_cast<U*>(other);
|
|
}
|
|
|
|
inline bool operator!=(std::nullptr_t) const
|
|
{
|
|
return this->ptr != nullptr;
|
|
}
|
|
|
|
template<typename U>
|
|
inline bool operator!=(U* other)
|
|
{
|
|
return !(*this == other);
|
|
}
|
|
|
|
template<typename U>
|
|
inline bool operator!=(ComPtr<U>& other)
|
|
{
|
|
return *this != static_cast<U*>(other);
|
|
}
|
|
};
|
|
}
|