Counter Strike : Global Offensive Source Code
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.

76 lines
2.2 KiB

  1. //====== Copyright � 1996-2004, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef DMXSERIALIZATIONDICTIONARY_H
  7. #define DMXSERIALIZATIONDICTIONARY_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier1/utlrbtree.h"
  12. //-----------------------------------------------------------------------------
  13. // Forward declarations
  14. //-----------------------------------------------------------------------------
  15. class CDmxElement;
  16. //-----------------------------------------------------------------------------
  17. // Element dictionary used in unserialization
  18. //-----------------------------------------------------------------------------
  19. typedef int DmxSerializationHandle_t;
  20. enum
  21. {
  22. DMX_SERIALIZATION_HANDLE_INVALID = (DmxSerializationHandle_t)~0
  23. };
  24. //-----------------------------------------------------------------------------
  25. // Element dictionary used in serialization
  26. //-----------------------------------------------------------------------------
  27. class CDmxSerializationDictionary
  28. {
  29. public:
  30. CDmxSerializationDictionary( int nElementsHint = 0 );
  31. // Creates the list of all things to serialize
  32. void BuildElementList( CDmxElement *pRoot, bool bFlatMode );
  33. // Should I inline the serialization of this element?
  34. bool ShouldInlineElement( CDmxElement *pElement );
  35. // Clears the dictionary
  36. void Clear();
  37. // Iterates over all root elements to serialize
  38. DmxSerializationHandle_t FirstRootElement() const;
  39. DmxSerializationHandle_t NextRootElement( DmxSerializationHandle_t h ) const;
  40. CDmxElement* GetRootElement( DmxSerializationHandle_t h );
  41. // Finds the handle of the element
  42. DmxSerializationHandle_t Find( CDmxElement *pElement );
  43. // How many root elements do we have?
  44. int RootElementCount() const;
  45. private:
  46. struct DmxElementInfo_t
  47. {
  48. CDmxElement* m_pElement;
  49. bool m_bRoot;
  50. };
  51. // Creates the list of all things to serialize
  52. void BuildElementList_R( CDmxElement *pRoot, bool bFlatMode, bool bIsRoot );
  53. static bool LessFunc( const DmxElementInfo_t &lhs, const DmxElementInfo_t &rhs );
  54. CUtlRBTree< DmxElementInfo_t, DmxSerializationHandle_t > m_Dict;
  55. };
  56. #endif // DMXSERIALIZATIONDICTIONARY_H