ReferenceTable.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef REFTABLE_H_
  2. #define REFTABLE_H_
  3. #include "FileIO.h"
  4. #include "Reference.h"
  5. #include "Object.h"
  6. namespace gameplay
  7. {
  8. /**
  9. * Collection of unique Reference objects stored in a hashtable.
  10. */
  11. class ReferenceTable
  12. {
  13. public:
  14. /**
  15. * Constructor.
  16. */
  17. ReferenceTable(void);
  18. /**
  19. * Destructor.
  20. */
  21. virtual ~ReferenceTable(void);
  22. /**
  23. * Adds an object to the reference table.
  24. *
  25. * @param xref The xref for the object.
  26. * @param obj The object to be added.
  27. */
  28. void add(std::string xref, Object* obj);
  29. Object* get(const std::string& xref);
  30. void writeBinary(FILE* file);
  31. void writeText(FILE* file);
  32. /**
  33. * Updates the file positon offsets of the Reference objects in the GamePlay binary file.
  34. * This needs to be called after all of the objects have been written.
  35. *
  36. * @param file The file pointer.
  37. */
  38. void updateOffsets(FILE* file);
  39. std::map<std::string, Reference>::iterator begin();
  40. std::map<std::string, Reference>::iterator end();
  41. private:
  42. std::map<std::string, Reference> _table;
  43. };
  44. }
  45. #endif