IDataModelManager::GetModelForType 方法 (dbgmodel.h)

GetModelForType 方法返回数据模型,该模型是给定类型实例的规范可视化工具。 实际上,此方法查找与之前对 RegisterModelForTypeSignature 方法的调用注册的最佳匹配类型签名,并返回关联的数据模型。

语法

HRESULT GetModelForType(
  IDebugHostType             *type,
  IModelObject               **dataModel,
  IDebugHostTypeSignature    **typeSignature,
  IDebugHostSymbolEnumerator **wildcardMatches
);

参数

type

通过先前调用 RegisterModelForTypeSignature 方法来查找注册的最佳匹配规范可视化工具的具体类型实例。

dataModel

此处将返回由之前通过 RegisterModelForTypeSignature 注册的最佳匹配类型签名确定的给定类型实例的规范可视化工具的数据模型。 此数据模型将自动附加到使用类型参数指定的类型创建的任何本机/语言对象。

typeSignature

类型签名,它与 类型的匹配导致我们返回使用返回的类型签名从先前调用 RegisterModelForTypeSignature 注册的数据模型。

wildcardMatches

如果 typeSignature 参数中返回的签名中存在通配符,则会在此处返回通配符与类型参数中给出的具体类型实例之间所有匹配项的枚举器。

返回值

此方法返回指示成功或失败的 HRESULT。

注解

示例代码

ComPtr<IDataModelManager> spManager; /* get the data model manager */
ComPtr<IDebugHostModule> spModule;   /* get a module */

// Find the type of "MyType<int>" within the module
ComPtr<IDebugHostType> spType;
if (SUCCEEDED(spModule->FindTypeByName(L"MyType<int>", &spType)))
{
    // Find the canonical visualizer which would be applied to MyType<int>
    ComPtr<IModelObject> spDataModel;
    ComPtr<IDebugHostTypeSignature> spSignature;
    ComPtr<IDebugHostSymbolEnumerator> spWildcardMatches;

    if (SUCCEEDED(spManager->GetModelForType(spType.Get(), 
                                             &spDataModel, 
                                             &spSignature, 
                                             &spWildcardMatches)))
    {
        // There is a visualizer which matched.
        // spDataModel is the data model object which was registered as 
        //     the canonical visualizer (RegisterModelForTypeSignature)
        // spSignature is the signature which that data model was registered 
        //     against (e.g.: created for MyType<*> via
        //     CreateTypeSignature/RegisterModelForTypeSignature)
        // spWildcardMatches is an enumerator of the wildcard matches between 
        //     the specific type spType and the signature spSignature (here 
        //     int matched *, so there will be one item -- the type 'int' in
        //     the enumerator)
    }

要求

要求
Header dbgmodel.h

另请参阅

IDataModelManager 接口