database-dummy.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <map>
  18. #include <set>
  19. #include <string>
  20. #include "database.h"
  21. #include "irrlichttypes.h"
  22. class Database_Dummy : public MapDatabase, public PlayerDatabase, public ModStorageDatabase
  23. {
  24. public:
  25. bool saveBlock(const v3s16 &pos, std::string_view data);
  26. void loadBlock(const v3s16 &pos, std::string *block);
  27. bool deleteBlock(const v3s16 &pos);
  28. void listAllLoadableBlocks(std::vector<v3s16> &dst);
  29. void savePlayer(RemotePlayer *player);
  30. bool loadPlayer(RemotePlayer *player, PlayerSAO *sao);
  31. bool removePlayer(const std::string &name);
  32. void listPlayers(std::vector<std::string> &res);
  33. void getModEntries(const std::string &modname, StringMap *storage);
  34. void getModKeys(const std::string &modname, std::vector<std::string> *storage);
  35. bool getModEntry(const std::string &modname,
  36. const std::string &key, std::string *value);
  37. bool hasModEntry(const std::string &modname, const std::string &key);
  38. bool setModEntry(const std::string &modname,
  39. const std::string &key,std::string_view value);
  40. bool removeModEntry(const std::string &modname, const std::string &key);
  41. bool removeModEntries(const std::string &modname);
  42. void listMods(std::vector<std::string> *res);
  43. void beginSave() {}
  44. void endSave() {}
  45. private:
  46. std::map<s64, std::string> m_database;
  47. std::set<std::string> m_player_database;
  48. std::unordered_map<std::string, StringMap> m_mod_storage_database;
  49. };