1 #ifndef BLANK_WORLD_CHUNKSTORE_HPP_
2 #define BLANK_WORLD_CHUNKSTORE_HPP_
16 ChunkStore(const BlockTypeRegistry &);
19 ChunkStore(const ChunkStore &) = delete;
20 ChunkStore &operator =(const ChunkStore &) = delete;
23 ChunkIndex &MakeIndex(const Chunk::Pos &base, int extent);
24 void UnregisterIndex(ChunkIndex &);
26 /// returns nullptr if given position is not loaded
27 Chunk *Get(const Chunk::Pos &);
28 /// returns nullptr if given position is not indexed
29 Chunk *Allocate(const Chunk::Pos &);
31 std::list<Chunk>::iterator begin() noexcept { return loaded.begin(); }
32 std::list<Chunk>::iterator end() noexcept { return loaded.end(); }
34 std::size_t NumLoaded() const noexcept { return loaded.size(); }
36 /// returns true if one of the indices is incomplete
37 bool HasMissing() const noexcept;
38 /// get the total number of missing chunks
39 /// this is an estimate and represents the upper bound since
40 /// chunks may be counted more than once if indices overlap
41 int EstimateMissing() const noexcept;
43 /// get coordinates of a missing chunk
44 /// this will return garbage if none are actually missing
45 Chunk::Pos NextMissing() noexcept;
50 const BlockTypeRegistry &types;
52 std::list<Chunk> loaded;
53 std::list<Chunk> free;
55 std::list<ChunkIndex> indices;