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.

68 lines
1.2 KiB

  1. #ifndef _STACK_H
  2. #define _STACK_H
  3. #include "PssException.h"
  4. #include "Allocator.h"
  5. #define STACK_ELEMENT_DIR_BIT_SIZE ElementSize
  6. #define STACK_ELEMENT_DIR_SIZE 1 << STACK_ELEMENT_DIR_BIT_SIZE
  7. #define STACK_ELEMENT_DIR_MASK 0xFFFFFFFF >> ( 32 - STACK_ELEMENT_DIR_BIT_SIZE )
  8. template <class WmiElement, ULONG ElementSize >
  9. class WmiStack
  10. {
  11. private:
  12. class WmiElementDir
  13. {
  14. public:
  15. WmiElementDir *m_Previous ;
  16. WmiElement m_Block [ STACK_ELEMENT_DIR_SIZE ] ;
  17. WmiElementDir () { m_Previous = NULL ; } ;
  18. ~WmiElementDir () { ; } ;
  19. } ;
  20. WmiElementDir *m_Top ;
  21. ULONG m_Size ;
  22. ULONG m_AllocatedSize ;
  23. WmiAllocator &m_Allocator ;
  24. WmiStatusCode UnInitialize_ElementDir ( ULONG a_Size ) ;
  25. WmiStatusCode Grow_ElementDir () ;
  26. WmiStatusCode Shrink_ElementDir () ;
  27. public:
  28. WmiStack (
  29. WmiAllocator &a_Allocator
  30. ) ;
  31. ~WmiStack () ;
  32. WmiStatusCode Initialize () ;
  33. WmiStatusCode UnInitialize () ;
  34. WmiStatusCode Push (
  35. const WmiElement &a_Element
  36. ) ;
  37. WmiStatusCode Top (
  38. WmiElement &a_Element
  39. ) ;
  40. WmiStatusCode Pop () ;
  41. ULONG Size () { return m_Size + 1 ; } ;
  42. } ;
  43. #include "..\Stack.cpp"
  44. #endif _STACK_H