DS_HuffmanEncodingTreeFactory.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. /// \file DS_HuffmanEncodingTreeFactory.h
  11. /// \internal
  12. /// \brief Creates instances of the class HuffmanEncodingTree
  13. ///
  14. #ifndef __HUFFMAN_ENCODING_TREE_FACTORY
  15. #define __HUFFMAN_ENCODING_TREE_FACTORY
  16. #include "RakMemoryOverride.h"
  17. namespace RakNet {
  18. /// Forward declarations
  19. class HuffmanEncodingTree;
  20. /// \brief Creates instances of the class HuffmanEncodingTree
  21. /// \details This class takes a frequency table and given that frequence table, will generate an instance of HuffmanEncodingTree
  22. class HuffmanEncodingTreeFactory
  23. {
  24. public:
  25. /// Default constructor
  26. HuffmanEncodingTreeFactory();
  27. /// \brief Reset the frequency table.
  28. /// \details You don't need to call this unless you want to reuse the class for a new tree
  29. void Reset( void );
  30. /// \brief Pass an array of bytes to this to add those elements to the frequency table.
  31. /// \param[in] array the data to insert into the frequency table
  32. /// \param[in] size the size of the data to insert
  33. void AddToFrequencyTable( unsigned char *array, int size );
  34. /// \brief Copies the frequency table to the array passed. Retrieve the frequency table.
  35. /// \param[in] _frequency The frequency table used currently
  36. void GetFrequencyTable( unsigned int _frequency[ 256 ] );
  37. /// \brief Returns the frequency table as a pointer.
  38. /// \return the address of the frenquency table
  39. unsigned int * GetFrequencyTable( void );
  40. /// \brief Generate a HuffmanEncodingTree.
  41. /// \details You can also use GetFrequencyTable and GenerateFromFrequencyTable in the tree itself
  42. /// \return The generated instance of HuffmanEncodingTree
  43. HuffmanEncodingTree * GenerateTree( void );
  44. private:
  45. /// Frequency table
  46. unsigned int frequency[ 256 ];
  47. };
  48. } // namespace RakNet
  49. #endif
粤ICP备19079148号