Source code of Windows XP (NT5)
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.

95 lines
1.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: guidtbl.hxx
  7. //
  8. // Contents:
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History:
  15. //
  16. //----------------------------------------------------------------------------
  17. class CGuidTable;
  18. class CGuidTableEntry;
  19. class CGuidTable : public CList
  20. {
  21. public:
  22. CGuidTable( LONG& Status );
  23. CGuidTableEntry * Lookup( GUID * pGuid );
  24. CGuidTableEntry * Add( CGuidTableEntry * pEntry );
  25. private:
  26. };
  27. class CGuidTableEntry : public CListElement, public CReferencedObject, public CScmAlloc
  28. {
  29. friend class CGuidTable;
  30. public:
  31. CGuidTableEntry( GUID * pGuid );
  32. inline GUID
  33. Guid()
  34. {
  35. return _Guid;
  36. }
  37. private:
  38. GUID _Guid;
  39. };
  40. inline
  41. CGuidTable::CGuidTable( LONG& Status )
  42. {
  43. Status = ERROR_SUCCESS;
  44. }
  45. inline
  46. CGuidTableEntry *
  47. CGuidTable::Lookup( GUID * pGuid )
  48. {
  49. CGuidTableEntry * pEntry;
  50. for ( pEntry = (CGuidTableEntry *) First(); pEntry; pEntry = (CGuidTableEntry *) pEntry->Next() )
  51. if ( 0 == memcmp( &pEntry->_Guid, pGuid, sizeof(GUID) ) )
  52. {
  53. pEntry->Reference();
  54. break;
  55. }
  56. return pEntry;
  57. }
  58. inline
  59. CGuidTableEntry *
  60. CGuidTable::Add( CGuidTableEntry * pEntry )
  61. {
  62. CGuidTableEntry * pExistingEntry;
  63. pExistingEntry = Lookup( &pEntry->_Guid );
  64. if ( pExistingEntry )
  65. {
  66. delete pEntry;
  67. return pExistingEntry;
  68. }
  69. Insert( (CListElement *) pEntry );
  70. return pEntry;
  71. }
  72. inline
  73. CGuidTableEntry::CGuidTableEntry( GUID * pGuid )
  74. {
  75. memcpy( &_Guid, pGuid, sizeof(GUID) );
  76. }