• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // com_utils.h: Utility functions for working with COM objects
8 
9 #ifndef UTIL_COM_UTILS_H
10 #define UTIL_COM_UTILS_H
11 
12 template <typename outType>
DynamicCastComObject(IUnknown * object)13 inline outType *DynamicCastComObject(IUnknown *object)
14 {
15     outType *outObject = nullptr;
16     HRESULT result =
17         object->QueryInterface(__uuidof(outType), reinterpret_cast<void **>(&outObject));
18     if (SUCCEEDED(result))
19     {
20         return outObject;
21     }
22     else
23     {
24         SafeRelease(outObject);
25         return nullptr;
26     }
27 }
28 
29 #endif  // UTIL_COM_UTILS_H
30