Debian Codegraph @

Storage/StorageInterface.h

raw symbols SCIP
1 /*
2 RailControl - Model Railway Control Software
3
4 Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org
5
6 RailControl is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 RailControl is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with RailControl; see the file LICENCE. If not see
18 <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include <map>
24 #include <string>
25
26 #include "DataTypes.h"
27 #include "Hardware/HardwareParams.h"
28
29 namespace Storage
30 {
31 class StorageInterface
32 {
33 public:
34 // non virtual default constructor is needed to prevent polymorphism
35 StorageInterface() {};
36
37 // pure virtual destructor prevents polymorphism in derived class
38 virtual ~StorageInterface() {};
39
40 // save control
41 virtual void SaveHardwareParams(const Hardware::HardwareParams& hardwareParams) = 0;
42
43 // read controls
44 virtual void AllHardwareParams(std::map<ControlID,Hardware::HardwareParams*>& hardwareParams) = 0;
45
46 // delete control
47 virtual void DeleteHardwareParams(const ControlID controlID) = 0;
48
49 // save datamodelobject
50 virtual void SaveObject(const ObjectType objectType, const ObjectID objectID, const std::string& name, const std::string& object) = 0;
51
52 // delete datamodelobject
53 virtual void DeleteObject(const ObjectType objectType, const ObjectID objectID) = 0;
54
55 // read datamodelobject
56 virtual void ObjectsOfType(const ObjectType objectType, std::vector<std::string>& objects) = 0;
57
58 // save datamodelrelation
59 virtual void SaveRelation(const DataModel::Relation::RelationType type, const ObjectID objectID1, const ObjectType objectType2, const ObjectID objectID2, const Priority priority, const std::string& relation) = 0;
60
61 // delete datamodelrelation
62 virtual void DeleteRelationsFrom(const DataModel::Relation::RelationType type, const ObjectID objectID) = 0;
63
64 // delete datamodelrelation
65 virtual void DeleteRelationsTo(const ObjectType objectType, const ObjectID objectID) = 0;
66
67 // read datamodelrelation
68 virtual void RelationsFrom(const DataModel::Relation::RelationType type, const ObjectID objectID, std::vector<std::string>& relations) = 0;
69
70 // read datamodelrelation
71 virtual void RelationsTo(const ObjectType objectType, const ObjectID objectID, std::vector<std::string>& relations) = 0;
72
73 // save setting
74 virtual void SaveSetting(const std::string& key, const std::string& value) = 0;
75
76 // read setting
77 virtual std::string GetSetting(const std::string& key) = 0;
78
79 // start transaction
80 virtual void StartTransaction() {}
81
82 // commit transaction
83 virtual void CommitTransaction() {}
84 };
85 } // namespace
86