Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
l_storage.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation; either version 2.1 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License along
17with this program; if not, write to the Free Software Foundation, Inc.,
1851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#pragma once
22
23#include "l_metadata.h"
24#include "lua_api/l_base.h"
25#include "content/mods.h"
26
28{
29protected:
30 static int l_get_mod_storage(lua_State *L);
31
32public:
33 static void Initialize(lua_State *L, int top);
34};
35
36class StorageRef : public MetaDataRef
37{
38private:
40
41 static const luaL_Reg methods[];
42
43 virtual IMetadata *getmeta(bool auto_create);
44 virtual void clearMeta();
45
46public:
47 StorageRef(const std::string &mod_name, ModStorageDatabase *db): m_object(mod_name, db) {}
48 ~StorageRef() = default;
49
50 static void Register(lua_State *L);
51 static void create(lua_State *L, const std::string &mod_name, ModStorageDatabase *db);
52
53 static const char className[];
54};
Definition metadata.h:29
Definition l_metadata.h:33
Definition l_base.h:43
Definition l_storage.h:28
static void Initialize(lua_State *L, int top)
Definition l_storage.cpp:39
static int l_get_mod_storage(lua_State *L)
Definition l_storage.cpp:25
Definition database.h:89
Definition mods.h:114
Definition l_storage.h:37
static void create(lua_State *L, const std::string &mod_name, ModStorageDatabase *db)
Definition l_storage.cpp:44
ModStorage m_object
Definition l_storage.h:39
StorageRef(const std::string &mod_name, ModStorageDatabase *db)
Definition l_storage.h:47
~StorageRef()=default
virtual void clearMeta()
Definition l_storage.cpp:62
static const char className[]
Definition l_storage.h:53
static const luaL_Reg methods[]
Definition l_storage.h:68
virtual IMetadata * getmeta(bool auto_create)
Definition l_storage.cpp:57