Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.4 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbtico.h
  5. Abstract:
  6. Definition of the TIME_COLLECTION class
  7. Author:
  8. */
  9. #if !defined(AFX_BLBTICO_H__2E4F4A20_0ABD_11D1_976D_00C04FD91AC0__INCLUDED_)
  10. #define AFX_BLBTICO_H__2E4F4A20_0ABD_11D1_976D_00C04FD91AC0__INCLUDED_
  11. #if _MSC_VER >= 1000
  12. #pragma once
  13. #endif // _MSC_VER >= 1000
  14. #include "resource.h" // main symbols
  15. #include "blbsdp.h"
  16. #include "blbcoen.h"
  17. #include "blbtime.h"
  18. /////////////////////////////////////////////////////////////////////////////
  19. // TIME_COLLECTION
  20. class MY_TIME_COLL_IMPL : public MY_COLL_IMPL<TIME>
  21. {
  22. public:
  23. STDMETHOD(Create)(/*[in]*/ ULONG Index, /*[out, retval]*/ ELEM_IF **Interface);
  24. STDMETHOD(Delete)(/*[in]*/ ULONG Index);
  25. HRESULT Create(
  26. IN ULONG Index,
  27. IN DWORD StartTime,
  28. IN DWORD StopTime
  29. );
  30. };
  31. typedef IDispatchImpl<MY_TIME_COLL_IMPL, &IID_ITTimeCollection, &LIBID_SDPBLBLib> MY_TIME_COLL_DISPATCH_IMPL;
  32. class ATL_NO_VTABLE TIME_COLLECTION :
  33. public MY_TIME_COLL_DISPATCH_IMPL,
  34. public CComObjectRootEx<CComObjectThreadModel>,
  35. public CObjectSafeImpl
  36. {
  37. public:
  38. BEGIN_COM_MAP(TIME_COLLECTION)
  39. COM_INTERFACE_ENTRY2(IDispatch, ITTimeCollection)
  40. COM_INTERFACE_ENTRY(ITTimeCollection)
  41. COM_INTERFACE_ENTRY(IObjectSafety)
  42. COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pFTM)
  43. END_COM_MAP()
  44. DECLARE_NOT_AGGREGATABLE(TIME_COLLECTION)
  45. DECLARE_GET_CONTROLLING_UNKNOWN()
  46. STDMETHODIMP get_EnumerationIf(
  47. /*[out, retval]*/ ENUM_IF **pVal
  48. )
  49. {
  50. CLock Lock(g_DllLock);
  51. ASSERT(NULL != m_IfArray);
  52. BAIL_IF_NULL(m_IfArray, E_FAIL);
  53. BAIL_IF_NULL(pVal, E_INVALIDARG);
  54. CComObject<CSafeComEnum<ENUM_IF, &IID_IEnumTime , ELEM_IF *, COPY_ELEM_IF> > * EnumComObject;
  55. HRESULT HResult = CComObject<CSafeComEnum<ENUM_IF, &IID_IEnumTime , ELEM_IF *, COPY_ELEM_IF> >::
  56. CreateInstance(&EnumComObject);
  57. BAIL_ON_FAILURE(HResult);
  58. HResult = EnumComObject->Init(
  59. m_IfArray->GetElemIfArrayData(),
  60. m_IfArray->GetElemIfArrayData() + m_IfArray->GetSize(),
  61. NULL, // no owner pUnk
  62. AtlFlagCopy // copy the array data
  63. );
  64. if ( FAILED(HResult) )
  65. {
  66. delete EnumComObject;
  67. return HResult;
  68. }
  69. // query for the ENUM_IF interface and return it
  70. HResult = EnumComObject->_InternalQueryInterface(IID_IEnumTime, (void**)pVal);
  71. if ( FAILED(HResult) )
  72. {
  73. delete EnumComObject;
  74. return HResult;
  75. }
  76. return S_OK;
  77. }
  78. TIME_COLLECTION() : m_pFTM(NULL) { }
  79. ~TIME_COLLECTION() { if ( m_pFTM ) m_pFTM->Release(); }
  80. inline HRESULT FinalConstruct(void);
  81. protected:
  82. IUnknown * m_pFTM; // pointer to the free threaded marshaler
  83. };
  84. inline
  85. HRESULT TIME_COLLECTION::FinalConstruct(void)
  86. {
  87. HRESULT HResult = CoCreateFreeThreadedMarshaler( GetControllingUnknown(),
  88. & m_pFTM );
  89. if ( FAILED(HResult) )
  90. {
  91. return HResult;
  92. }
  93. return S_OK;
  94. }
  95. #endif // !defined(AFX_BLBTICO_H__2E4F4A20_0ABD_11D1_976D_00C04FD91AC0__INCLUDED_)