BlockRegistry.h 508 B

1234567891011121314151617181920212223
  1. #ifndef BLOCKREGISTRY_H
  2. #define BLOCKREGISTRY_H
  3. #include "common/block/Block.h"
  4. #include "common/block/BlockTypes.h"
  5. #include "utils/HashMap.h"
  6. #include "utils/List.h"
  7. class BlockRegistry final {
  8. List<Block> blocks;
  9. HashMap<BlockName, BlockId> registryToId;
  10. public:
  11. BlockRegistry();
  12. void forEach(void (*f)(const Block&)) const;
  13. const Block& getBlock(const BlockName& registry) const;
  14. const Block& getBlock(BlockId id) const;
  15. private:
  16. void add(const char* registry);
  17. };
  18. #endif