#include <areastore.h>
Inheritance diagram for AreaStore:
Collaboration diagram for AreaStore:Public Member Functions | |
| AreaStore () | |
| virtual | ~AreaStore ()=default |
| virtual void | reserve (size_t count) |
| size_t | size () const |
| virtual bool | insertArea (Area *a)=0 |
| Add an area to the store. | |
| virtual bool | removeArea (u32 id)=0 |
| Removes an area from the store by ID. | |
| void | getAreasForPos (std::vector< Area * > *result, v3s16 pos) |
| Finds areas that the passed position is contained in. | |
| virtual void | getAreasInArea (std::vector< Area * > *result, v3s16 minedge, v3s16 maxedge, bool accept_overlap)=0 |
| Finds areas that are completely contained inside the area defined by the passed edges. | |
| void | setCacheParams (bool enabled, u8 block_radius, size_t limit) |
| Sets cache parameters. | |
| const Area * | getArea (u32 id) const |
| Returns a pointer to the area coresponding to the passed ID, or NULL if it doesn't exist. | |
| void | serialize (std::ostream &is) const |
| Serializes the store's areas to a binary ostream. | |
| void | deserialize (std::istream &is) |
| Deserializes the Areas from a binary istream. | |
Static Public Member Functions | |
| static AreaStore * | getOptimalImplementation () |
Protected Types | |
| typedef std::map< u32, Area > | AreaMap |
Protected Member Functions | |
| void | invalidateCache () |
| Invalidates the getAreasForPos cache. | |
| virtual void | getAreasForPosImpl (std::vector< Area * > *result, v3s16 pos)=0 |
| Implementation of getAreasForPos. | |
| u32 | getNextId () const |
| Returns the next area ID and increments it. | |
Protected Attributes | |
| AreaMap | areas_map |
Static Private Member Functions | |
| static void | cacheMiss (void *data, const v3s16 &mpos, std::vector< Area * > *dest) |
| Called by the cache when a value isn't found in the cache. | |
Private Attributes | |
| bool | m_cache_enabled = true |
| u8 | m_cacheblock_radius = 64 |
| Range, in nodes, of the getAreasForPos cache. | |
| LRUCache< v3s16, std::vector< Area * > > | m_res_cache |
|
protected |
|
inline |
|
virtualdefault |
|
staticprivate |
Called by the cache when a value isn't found in the cache.
References getAreasInArea(), and m_cacheblock_radius.
Here is the call graph for this function:| void AreaStore::deserialize | ( | std::istream & | is | ) |
Deserializes the Areas from a binary istream.
This does not currently clear the AreaStore before adding the areas, making it possible to deserialize multiple serialized AreaStores.
References Area::data, insertArea(), Area::maxedge, Area::minedge, readU16(), readU32(), readU8(), readV3S16(), and U32_MAX.
Referenced by deserialization_helper(), and TestAreaStore::testSerialization().
Here is the call graph for this function:
Here is the caller graph for this function:| const Area * AreaStore::getArea | ( | u32 | id | ) | const |
Returns a pointer to the area coresponding to the passed ID, or NULL if it doesn't exist.
References areas_map.
Referenced by LuaAreaStore::l_get_area().
Here is the caller graph for this function:Finds areas that the passed position is contained in.
Stores output in passed vector.
References AST_CONTAINS_PT, getAreasForPosImpl(), getContainerPos(), LRUCache< K, V >::lookupCache(), m_cache_enabled, m_cacheblock_radius, and m_res_cache.
Referenced by TestAreaStore::genericStoreTest(), and LuaAreaStore::l_get_areas_for_pos().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedpure virtual |
Implementation of getAreasForPos.
getAreasForPos calls this if the cache is disabled.
Implemented in SpatialAreaStore, and VectorAreaStore.
Referenced by getAreasForPos().
Here is the caller graph for this function:
|
pure virtual |
Finds areas that are completely contained inside the area defined by the passed edges.
If accept_overlap is true this finds any areas that intersect with the passed area at any point.
Implemented in SpatialAreaStore, and VectorAreaStore.
Referenced by cacheMiss(), TestAreaStore::genericStoreTest(), and LuaAreaStore::l_get_areas_in_area().
Here is the caller graph for this function:
|
protected |
Returns the next area ID and increments it.
References areas_map.
Referenced by SpatialAreaStore::insertArea(), and VectorAreaStore::insertArea().
Here is the caller graph for this function:
|
static |
|
pure virtual |
Add an area to the store.
Updates the area's ID if it hasn't already been set.
Implemented in SpatialAreaStore, and VectorAreaStore.
Referenced by deserialize(), TestAreaStore::genericStoreTest(), and LuaAreaStore::l_insert_area().
Here is the caller graph for this function:
|
protected |
Invalidates the getAreasForPos cache.
Call after adding or removing an area.
References LRUCache< K, V >::invalidate(), m_cache_enabled, and m_res_cache.
Referenced by SpatialAreaStore::insertArea(), VectorAreaStore::insertArea(), SpatialAreaStore::removeArea(), VectorAreaStore::removeArea(), and setCacheParams().
Here is the call graph for this function:
Here is the caller graph for this function:
|
pure virtual |
Removes an area from the store by ID.
Implemented in SpatialAreaStore, and VectorAreaStore.
Referenced by TestAreaStore::genericStoreTest(), and LuaAreaStore::l_remove_area().
Here is the caller graph for this function:
|
inlinevirtual |
Reimplemented in VectorAreaStore.
Referenced by TestAreaStore::genericStoreTest(), and LuaAreaStore::l_reserve().
Here is the caller graph for this function:| void AreaStore::serialize | ( | std::ostream & | is | ) | const |
Serializes the store's areas to a binary ostream.
References areas_map, Area::data, Area::maxedge, Area::minedge, writeU16(), writeU32(), writeU8(), and writeV3S16().
Referenced by LuaAreaStore::l_to_file(), LuaAreaStore::l_to_string(), and TestAreaStore::testSerialization().
Here is the call graph for this function:
Here is the caller graph for this function:| void AreaStore::setCacheParams | ( | bool | enabled, |
| u8 | block_radius, | ||
| size_t | limit ) |
Sets cache parameters.
References invalidateCache(), m_cache_enabled, m_cacheblock_radius, m_res_cache, MYMAX, and LRUCache< K, V >::setLimit().
Referenced by LuaAreaStore::l_set_cache_params().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
References areas_map.
Referenced by TestAreaStore::genericStoreTest(), and TestAreaStore::testSerialization().
Here is the caller graph for this function:
|
protected |
|
private |
Referenced by getAreasForPos(), invalidateCache(), and setCacheParams().
|
private |
Range, in nodes, of the getAreasForPos cache.
If you modify this, call invalidateCache()
Referenced by cacheMiss(), getAreasForPos(), and setCacheParams().
Referenced by getAreasForPos(), invalidateCache(), and setCacheParams().