Move AreaStore container selection logic into getOptimalImplementation

This commit is contained in:
ShadowNinja 2015-10-29 23:38:36 -04:00
parent 0079887b64
commit 2e74e9ee20
3 changed files with 13 additions and 9 deletions

View File

@ -25,9 +25,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "irr_v3d.h" #include "irr_v3d.h"
#include "util/areastore.h" #include "util/areastore.h"
#include "filesys.h" #include "filesys.h"
#ifndef ANDROID
#include "cmake_config.h"
#endif
#include <fstream> #include <fstream>
static inline void get_data_and_border_flags(lua_State *L, u8 start_i, static inline void get_data_and_border_flags(lua_State *L, u8 start_i,
@ -294,11 +291,7 @@ int LuaAreaStore::l_from_file(lua_State *L)
LuaAreaStore::LuaAreaStore() LuaAreaStore::LuaAreaStore()
{ {
#if USE_SPATIAL this->as = AreaStore::getOptimalImplementation();
this->as = new SpatialAreaStore();
#else
this->as = new VectorAreaStore();
#endif
} }
LuaAreaStore::LuaAreaStore(const std::string &type) LuaAreaStore::LuaAreaStore(const std::string &type)

View File

@ -44,6 +44,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
AST_OVERLAPS_IN_DIMENSION((amine), (amaxe), (b), Y) && \ AST_OVERLAPS_IN_DIMENSION((amine), (amaxe), (b), Y) && \
AST_OVERLAPS_IN_DIMENSION((amine), (amaxe), (b), Z)) AST_OVERLAPS_IN_DIMENSION((amine), (amaxe), (b), Z))
AreaStore *AreaStore::getOptimalImplementation()
{
#if USE_SPATIAL
return new SpatialAreaStore();
#else
return new VectorAreaStore();
#endif
}
u16 AreaStore::size() const u16 AreaStore::size() const
{ {
return areas_map.size(); return areas_map.size();

View File

@ -52,7 +52,6 @@ struct Area {
std::string data; std::string data;
}; };
std::vector<std::string> get_areastore_typenames();
class AreaStore { class AreaStore {
protected: protected:
@ -93,6 +92,8 @@ public:
const Area *getArea(u32 id) const; const Area *getArea(u32 id) const;
u16 size() const; u16 size() const;
static AreaStore *getOptimalImplementation();
#if 0 #if 0
bool deserialize(std::istream &is); bool deserialize(std::istream &is);
void serialize(std::ostream &is) const; void serialize(std::ostream &is) const;