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