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.

93 lines
2.2 KiB

  1. //#---------------------------------------------------------------
  2. // File: CObjID.cpp
  3. //
  4. // Synopsis: This file implements the CObjectID class
  5. //
  6. // Copyright (C) 1995 Microsoft Corporation
  7. // All rights reserved.
  8. //
  9. // Authors: HowardCu
  10. //----------------------------------------------------------------
  11. #ifdef THIS_FILE
  12. #undef THIS_FILE
  13. #endif
  14. static char __szTraceSourceFile[] = __FILE__;
  15. #define THIS_FILE __szTraceSourceFile
  16. #include <windows.h>
  17. #include "cobjid.h"
  18. #include "dbgtrace.h"
  19. //+---------------------------------------------------------------
  20. //
  21. // Function: CObjectID
  22. //
  23. // Synopsis: constructor
  24. //
  25. // Arguments: void
  26. //
  27. // Returns: void
  28. //
  29. // History: HowardCu Created 8 May 1995
  30. //
  31. //----------------------------------------------------------------
  32. CObjectID::CObjectID( void )
  33. {
  34. TraceFunctEnter( "CObjectID::CObjectID" );
  35. m_dwObjectID = INITIALOBJECTID;
  36. InitializeCriticalSection( &m_ObjIDCritSect );
  37. TraceFunctLeave();
  38. }
  39. //+---------------------------------------------------------------
  40. //
  41. // Function: ~CObjectID
  42. //
  43. // Synopsis: destructor
  44. //
  45. // Arguments: void
  46. //
  47. // Returns: void
  48. //
  49. // History: HowardCu Created 8 May 1995
  50. //
  51. //----------------------------------------------------------------
  52. CObjectID::~CObjectID( void )
  53. {
  54. TraceFunctEnter( "CObjectID::~CObjectID" );
  55. DeleteCriticalSection( &m_ObjIDCritSect );
  56. TraceFunctLeave();
  57. }
  58. //+---------------------------------------------------------------
  59. //
  60. // Function: GetUniqueID
  61. //
  62. // Synopsis: generate the next object ID
  63. //
  64. // Arguments: void
  65. //
  66. // Returns: next object ID
  67. //
  68. // History: HowardCu Created 8 May 1995
  69. //
  70. //----------------------------------------------------------------
  71. DWORD
  72. CObjectID::GetUniqueID(
  73. void
  74. )
  75. {
  76. DWORD dwReturnValue;
  77. TraceFunctEnter( "CObjectID::GetUniqueID" );
  78. EnterCriticalSection( &m_ObjIDCritSect );
  79. m_dwObjectID += OBJECTIDINCREMENT;
  80. if( m_dwObjectID == 0 )
  81. {
  82. m_dwObjectID = INITIALOBJECTID;
  83. }
  84. dwReturnValue = m_dwObjectID;
  85. LeaveCriticalSection( &m_ObjIDCritSect );
  86. DebugTrace( m_dwObjectID, "New object ID assigned 0x%08lx.", m_dwObjectID );
  87. TraceFunctLeave();
  88. return dwReturnValue;
  89. }