file_object_element_finder.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef FILE_OBJECT_ELEMENT_FINDER_H
  2. #define FILE_OBJECT_ELEMENT_FINDER_H
  3. #include "file_node_visitor.h"
  4. namespace binom {
  5. class FileNodeVisitor::ObjectElementFinder{
  6. public:
  7. struct ObjectElement{
  8. ValType type;
  9. ui64 name_size;
  10. const void* name;
  11. virtual_index index;
  12. };
  13. private:
  14. // Node Control
  15. FileMemoryManager& fmm;
  16. virtual_index node_index;
  17. RWGuard& rw_gurad;
  18. ObjectElementPosition pos;
  19. ObjectDescriptor getObjectDescriptor();
  20. ObjectNameLength getNameBlockDescriptor(ui64 index);
  21. ObjectElementFinder& findBlock(ValType type, block_size name_length);
  22. inline bool isNameBlockFinded() const {return pos.name_block_index != pos.descriptor.length_element_count;}
  23. ObjectElementFinder& findNameInBlock(void* name);
  24. inline bool isNameFinded() {return pos.name_shift != pos.descriptor.name_block_size;}
  25. public:
  26. ObjectElementFinder(FileNodeVisitor& node_visitor);
  27. ObjectElementFinder(FileMemoryManager& fmm, virtual_index node_index, RWGuard& rw_gurad);
  28. ObjectElementFinder& dropPosition();
  29. bool findElement(BufferArray name);
  30. NamePosition getNamePosition();
  31. BufferArray getName();
  32. inline ui64 getElementCount() const {return pos.descriptor.index_count;}
  33. virtual_index getNodeIndex() const;
  34. inline ObjectElementPosition getObjectElementPosition() const {return pos;}
  35. void insert(BufferArray name, virtual_index node_index);
  36. bool remove(BufferArray name);
  37. void foreach(std::function<void(ObjectElement)> handler);
  38. };
  39. }
  40. #endif // FILE_OBJECT_ELEMENT_FINDER_H