Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
LocalStorage.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2013-2020 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#pragma once
23
24#include "Application.h"
25#include "ImprovedConfigFile.h"
26#include "RefCountingObject.h"
27
28#include <angelscript.h>
29
30namespace RoR {
31
34
38class LocalStorage : public ImprovedConfigFile, public RefCountingObject<LocalStorage>
39{
40public:
41 LocalStorage(std::string filename, const std::string& section_name, const std::string& rg_name /* = RGN_CACHE*/);
42 virtual ~LocalStorage() override;
43
44 void copyFrom(LocalStoragePtr other);
45 void changeSection(const std::string& section);
46
47 std::string get(std::string key);
48 void set(std::string key, const std::string& value);
49
50 int getInt(std::string key);
51 void set(std::string key, const int value);
52
53 float getFloat(std::string key);
54 void set(std::string key, const float value);
55
56 bool getBool(std::string key);
57 void set(std::string key, const bool value);
58
59 Ogre::Vector3 getVector3(std::string key);
60 void set(std::string key, const Ogre::Vector3& value);
61
62 Ogre::Quaternion getQuaternion(std::string key);
63 void set(std::string key, const Ogre::Quaternion& value);
64
65 Ogre::Radian getRadian(std::string key);
66 void set(std::string key, const Ogre::Radian& value);
67
68 Ogre::Degree getDegree(std::string key);
69 void set(std::string key, const Ogre::Degree& value);
70
71 void saveDict();
72 // int extendDict();
73 bool loadDict();
74
75 // removes a key and its associated value
76 void eraseKey(std::string key);
77
78 // Returns true if the key is set
79 bool exists(std::string key);
80
81 // Deletes all keys
82 void deleteAll();
83
84 // parses a key
85 void parseKey(std::string& inout_key, std::string& out_section);
86
87 SettingsBySection getSettings() { return mSettingsPtr; }
88 std::string getFilename() { return m_filename; }
89 std::string getSection() { return sectionName; }
90
91protected:
92 std::string m_filename;
93 std::string m_resource_group;
94 bool saved;
95 std::string sectionName;
96};
97
99
100} // namespace RoR
Central state/object manager and communications hub.
Used by AngelScript local storage.
Self reference-counting objects, as requred by AngelScript garbage collector.
A class that allows scripts to store data persistently.
Ogre::Degree getDegree(std::string key)
void parseKey(std::string &inout_key, std::string &out_section)
std::string getSection()
std::string m_filename
int getInt(std::string key)
void eraseKey(std::string key)
std::string getFilename()
Ogre::Radian getRadian(std::string key)
SettingsBySection getSettings()
Ogre::Vector3 getVector3(std::string key)
Ogre::Quaternion getQuaternion(std::string key)
bool saved
Inverted 'dirty flag'.
std::string m_resource_group
float getFloat(std::string key)
void changeSection(const std::string &section)
virtual ~LocalStorage() override
bool exists(std::string key)
std::string sectionName
void copyFrom(LocalStoragePtr other)
void set(std::string key, const std::string &value)
bool getBool(std::string key)
std::string get(std::string key)