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 ChunkIndex *ClosestIndex(const Chunk::Pos &pos);
28 /// returns nullptr if given position is not loaded
29 Chunk *Get(const Chunk::Pos &);
30 /// returns nullptr if given position is not indexed
31 Chunk *Allocate(const Chunk::Pos &);
33 std::list<Chunk>::iterator begin() noexcept { return loaded.begin(); }
34 std::list<Chunk>::iterator end() noexcept { return loaded.end(); }
36 std::size_t NumLoaded() const noexcept { return loaded.size(); }
38 /// returns true if one of the indices is incomplete
39 bool HasMissing() const noexcept;
40 /// get the total number of missing chunks
41 /// this is an estimate and represents the upper bound since
42 /// chunks may be counted more than once if indices overlap
43 int EstimateMissing() const noexcept;
45 /// get coordinates of a missing chunk
46 /// this will return garbage if none are actually missing
47 Chunk::Pos NextMissing() noexcept;
52 const BlockTypeRegistry &types;
54 std::list<Chunk> loaded;
55 std::list<Chunk> free;
57 std::list<ChunkIndex> indices;