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.

131 lines
3.4 KiB

  1. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1995 - 1999.
  4. File: Attributes.h
  5. Content: Declaration of CAttributes.
  6. History: 11-15-99 dsie created
  7. ------------------------------------------------------------------------------*/
  8. #ifndef __ATTRIBUTES_H_
  9. #define __ATTRIBUTES_H_
  10. #include "Resource.h"
  11. #include "Lock.h"
  12. #include "Debug.h"
  13. #include "CopyItem.h"
  14. #include "Attribute.h"
  15. //
  16. // typdefs to make life easier.
  17. //
  18. typedef std::map<CComBSTR, CComPtr<IAttribute> > AttributeMap;
  19. typedef CComEnumOnSTL<IEnumVARIANT, &IID_IEnumVARIANT, VARIANT, _CopyMapItem<IAttribute>, AttributeMap> AttributeEnum;
  20. typedef ICollectionOnSTLImpl<IAttributes, AttributeMap, VARIANT, _CopyMapItem<IAttribute>, AttributeEnum> IAttributesCollection;
  21. ////////////////////////////////////////////////////////////////////////////////
  22. //
  23. // Exported functions.
  24. //
  25. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26. Function : CreateAttributesObject
  27. Synopsis : Create and initialize an IAttributes collection object.
  28. Parameter: CRYPT_ATTRIBUTES * pAttrbibutes - Pointer to attributes to be
  29. added to the collection object.
  30. IAttributes ** ppIAttributes - Pointer to pointer to IAttributes
  31. to receive the interface pointer.
  32. Remark :
  33. ------------------------------------------------------------------------------*/
  34. HRESULT CreateAttributesObject (CRYPT_ATTRIBUTES * pAttributes,
  35. IAttributes ** ppIAttributes);
  36. ////////////////////////////////////////////////////////////////////////////////
  37. //
  38. // CAttributes
  39. //
  40. class ATL_NO_VTABLE CAttributes :
  41. public CComObjectRootEx<CComMultiThreadModel>,
  42. public CComCoClass<CAttributes, &CLSID_Attributes>,
  43. public ICAPICOMError<CAttributes, &IID_IAttributes>,
  44. public IDispatchImpl<IAttributesCollection, &IID_IAttributes, &LIBID_CAPICOM,
  45. CAPICOM_MAJOR_VERSION, CAPICOM_MINOR_VERSION>
  46. {
  47. public:
  48. CAttributes()
  49. {
  50. }
  51. DECLARE_NO_REGISTRY()
  52. DECLARE_GET_CONTROLLING_UNKNOWN()
  53. DECLARE_PROTECT_FINAL_CONSTRUCT()
  54. BEGIN_COM_MAP(CAttributes)
  55. COM_INTERFACE_ENTRY(IAttributes)
  56. COM_INTERFACE_ENTRY(IDispatch)
  57. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  58. END_COM_MAP()
  59. BEGIN_CATEGORY_MAP(CAttributes)
  60. END_CATEGORY_MAP()
  61. HRESULT FinalConstruct()
  62. {
  63. HRESULT hr;
  64. if (FAILED(hr = m_Lock.Initialized()))
  65. {
  66. DebugTrace("Error [%#x]: Critical section could not be created for Attributes object.\n", hr);
  67. return hr;
  68. }
  69. m_dwNextIndex = 0;
  70. return S_OK;
  71. }
  72. //
  73. // IAttributes
  74. //
  75. public:
  76. //
  77. // These are the only ones that we need to implemented, others will be
  78. // handled by ATL ICollectionOnSTLImpl.
  79. //
  80. STDMETHOD(Clear)
  81. (void);
  82. STDMETHOD(Remove)
  83. (/*[in]*/ long Index);
  84. STDMETHOD(Add)
  85. (/*[in]*/ IAttribute * pVal);
  86. //
  87. // None COM functions.
  88. //
  89. STDMETHOD(Init)
  90. (CRYPT_ATTRIBUTES * pAttributes);
  91. private:
  92. CLock m_Lock;
  93. DWORD m_dwNextIndex;
  94. };
  95. #endif //__ATTRIBUTES_H_