31 #ifndef IDATABASECONTROLLER_H_ 32 #define IDATABASECONTROLLER_H_ 35 #include "../Variable.h" 36 #include "../Sockets/RpcClientInfo.h" 37 #include "../Systems/Peer.h" 47 std::unordered_map<uint64_t, Role>
roles;
59 enum Enum { version = 0, upnpusn = 1, uniqueid = 2 };
64 virtual void init() = 0;
67 virtual void open(
const std::string &databasePath,
const std::string &databaseFilename,
const std::string &maintenanceDatabasePath,
bool databaseSynchronous,
bool databaseMemoryJournal,
bool databaseWALJournal,
const std::string &backupPath,
const std::string &maintenanceBackupPath,
const std::string &backupFilename) = 0;
68 virtual void hotBackup() = 0;
69 virtual bool isOpen() = 0;
70 virtual void initializeDatabase() = 0;
71 virtual bool convertDatabase(
const std::string &databasePath,
const std::string &databaseFilename,
const std::string &maintenanceDatabasePath,
bool databaseSynchronous,
bool databaseMemoryJournal,
bool databaseWALJournal,
const std::string &backupPath,
const std::string &maintenanceBackupPath,
const std::string &backupFilename) = 0;
72 virtual bool enableMaintenanceMode() = 0;
73 virtual bool disableMaintenanceMode() = 0;
74 virtual void createSavepointSynchronous(std::string &
name) = 0;
75 virtual void releaseSavepointSynchronous(std::string &name) = 0;
76 virtual void createSavepointAsynchronous(std::string &name) = 0;
77 virtual void releaseSavepointAsynchronous(std::string &name) = 0;
93 virtual std::shared_ptr<DataTable> getUiElements() = 0;
95 virtual void removeUiElement(uint64_t databaseId) = 0;
100 virtual uint64_t createUiNotification(
const BaseLib::PVariable ¬ificationDescription) = 0;
101 virtual BaseLib::PVariable getUiNotification(uint64_t databaseId,
const std::string& languageCode) = 0;
103 virtual void removeUiNotification(uint64_t databaseId) = 0;
107 virtual BaseLib::PVariable addBuildingPartToBuilding(uint64_t buildingId, uint64_t buildingPartId) = 0;
108 virtual BaseLib::PVariable addStoryToBuilding(uint64_t buildingId, uint64_t storyId) = 0;
115 virtual BaseLib::PVariable removeBuildingPartFromBuildings(uint64_t buildingPartId) = 0;
116 virtual BaseLib::PVariable removeBuildingPartFromBuilding(uint64_t buildingId, uint64_t buildingPartId) = 0;
118 virtual BaseLib::PVariable removeStoryFromBuilding(uint64_t buildingId, uint64_t storyId) = 0;
119 virtual bool buildingExists(uint64_t buildingId) = 0;
129 virtual bool buildingPartExists(uint64_t buildingPartId) = 0;
142 virtual BaseLib::PVariable removeRoomFromStory(uint64_t storyId, uint64_t roomId) = 0;
143 virtual bool storyExists(uint64_t storyId) = 0;
151 virtual std::string getRoomName(
PRpcClientInfo clientInfo, uint64_t roomId) = 0;
154 virtual bool roomExists(uint64_t roomId) = 0;
164 virtual bool categoryExists(uint64_t categoryId) = 0;
170 virtual void createDefaultRoles() = 0;
173 virtual void deleteAllRoles() = 0;
176 virtual bool roleExists(uint64_t roleId) = 0;
183 virtual BaseLib::PVariable getNodeData(
const std::string &node,
const std::string &key,
bool requestFromTrustedServer =
false) = 0;
184 virtual std::set<std::string> getAllNodeDataNodes() = 0;
185 virtual BaseLib::PVariable deleteNodeData(
const std::string &node,
const std::string &key) = 0;
192 virtual BaseLib::PVariable deleteMetadata(uint64_t peerId, std::string &serialNumber, std::string &dataId) = 0;
196 virtual void deleteSystemVariable(std::string &variableId) = 0;
197 virtual std::shared_ptr<BaseLib::Database::DataTable> getAllSystemVariables() = 0;
198 virtual std::shared_ptr<BaseLib::Database::DataTable> getSystemVariable(
const std::string &variableId) = 0;
199 virtual std::shared_ptr<BaseLib::Database::DataTable> getSystemVariablesInRoom(uint64_t roomId) = 0;
200 virtual void removeCategoryFromSystemVariables(uint64_t categoryId) = 0;
201 virtual void removeRoleFromSystemVariables(uint64_t roleId) = 0;
202 virtual void removeRoomFromSystemVariables(uint64_t roomId) = 0;
204 virtual BaseLib::PVariable setSystemVariableCategories(std::string &variableId,
const std::string &categories) = 0;
205 virtual BaseLib::PVariable setSystemVariableRoles(std::string &variableId,
const std::string &roles) = 0;
210 virtual bool createUser(
const std::string &name,
const std::vector<uint8_t> &passwordHash,
const std::vector<uint8_t> &salt,
const std::vector<uint64_t> &groups) = 0;
211 virtual bool deleteUser(uint64_t userId) = 0;
212 virtual std::shared_ptr<DataTable> getPassword(
const std::string &name) = 0;
213 virtual uint64_t getUserId(
const std::string &name) = 0;
214 virtual int64_t getUserKeyIndex1(uint64_t userId) = 0;
215 virtual int64_t getUserKeyIndex2(uint64_t userId) = 0;
217 virtual std::shared_ptr<DataTable> getUsers() = 0;
218 virtual std::vector<uint64_t> getUsersGroups(uint64_t userId) = 0;
219 virtual bool updateUser(uint64_t userId,
const std::vector<uint8_t> &passwordHash,
const std::vector<uint8_t> &salt,
const std::vector<uint64_t> &groups) = 0;
220 virtual void setUserKeyIndex1(uint64_t userId, int64_t keyIndex) = 0;
221 virtual void setUserKeyIndex2(uint64_t userId, int64_t keyIndex) = 0;
223 virtual bool userNameExists(
const std::string &name) = 0;
228 virtual BaseLib::PVariable getUserData(uint64_t userId,
const std::string &component,
const std::string &key) = 0;
229 virtual BaseLib::PVariable deleteUserData(uint64_t userId,
const std::string &component,
const std::string &key) = 0;
238 virtual bool groupExists(uint64_t groupId) = 0;
243 virtual void deleteFamily(int32_t
familyId) = 0;
245 virtual std::shared_ptr<BaseLib::Database::DataTable> getFamilyVariables(int32_t familyId) = 0;
250 virtual std::shared_ptr<DataTable> getDevices(uint32_t family) = 0;
251 virtual void deleteDevice(uint64_t
id) = 0;
252 virtual uint64_t saveDevice(uint64_t
id, int32_t address, std::string &serialNumber, uint32_t type, uint32_t family) = 0;
253 virtual void saveDeviceVariableAsynchronous(
DataRow &data) = 0;
254 virtual void deletePeers(int32_t deviceID) = 0;
255 virtual std::shared_ptr<DataTable> getPeers(uint64_t deviceID) = 0;
256 virtual std::shared_ptr<DataTable> getDeviceVariables(uint64_t deviceID) = 0;
260 virtual void deletePeer(uint64_t
id) = 0;
261 virtual uint64_t savePeer(uint64_t
id, uint32_t parentID, int32_t address, std::string &serialNumber, uint32_t type) = 0;
262 virtual uint64_t savePeerParameterSynchronous(
DataRow &data) = 0;
263 virtual void savePeerParameterAsynchronous(
DataRow &data) = 0;
264 virtual void saveSpecialPeerParameterAsynchronous(
DataRow &data) = 0;
269 virtual void savePeerVariableAsynchronous(
DataRow &data) = 0;
270 virtual std::shared_ptr<DataTable> getPeerParameters(uint64_t peerID) = 0;
271 virtual std::shared_ptr<DataTable> getPeerVariables(uint64_t peerID) = 0;
272 virtual void deletePeerParameter(uint64_t peerID,
DataRow &data) = 0;
274 virtual bool peerExists(uint64_t peerId) = 0;
275 virtual bool peerExists(
const std::string &serialNumber) = 0;
284 virtual bool setPeerID(uint64_t oldPeerId, uint64_t newPeerId) = 0;
285 virtual bool setPeerSerialNumber(uint64_t peer_id,
const std::string &new_serial_number) = 0;
289 virtual std::shared_ptr<DataTable> getServiceMessages(uint64_t peerId) = 0;
290 virtual void saveServiceMessageAsynchronous(uint64_t peerId,
DataRow &data) = 0;
291 virtual void saveGlobalServiceMessageAsynchronous(
DataRow &data) = 0;
292 virtual void deleteServiceMessage(uint64_t databaseID) = 0;
293 virtual void deleteGlobalServiceMessage(int32_t familyId, int32_t messageId, std::string &messageSubId, std::string &message) = 0;
297 virtual std::shared_ptr<DataTable> getLicenseVariables(int32_t
moduleId) = 0;
298 virtual void saveLicenseVariable(int32_t moduleId,
DataRow &data) = 0;
299 virtual void deleteLicenseVariable(int32_t moduleId, uint64_t mapKey) = 0;
304 virtual void deleteVariableProfile(uint64_t profileId) = 0;
305 virtual std::shared_ptr<BaseLib::Database::DataTable> getVariableProfiles() = 0;
std::shared_ptr< SystemVariable > PSystemVariable
Definition: IDatabaseController.h:51
Definition: BaseLib.cpp:34
Definition: IDatabaseController.h:58
std::shared_ptr< RpcClientInfo > PRpcClientInfo
Definition: ScriptInfo.h:47
uint64_t room
Definition: IDatabaseController.h:45
int32_t flags
Definition: IDatabaseController.h:48
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
std::string name
Definition: IDatabaseController.h:44
uint64_t peerId
Definition: UiElements.h:214
int32_t moduleId
Definition: Licensing.h:379
int32_t familyId
Definition: Licensing.h:380
IDatabaseController()
Definition: IDatabaseController.h:62
Definition: IDatabaseController.h:43
std::unordered_map< uint64_t, Role > roles
Definition: IDatabaseController.h:47
BaseLib::PVariable value
Definition: IDatabaseController.h:49
Enum
Definition: IDatabaseController.h:59
virtual ~IDatabaseController()
Definition: IDatabaseController.h:63
Base class for the database controller.
Definition: IDatabaseController.h:56
std::set< uint64_t > categories
Definition: IDatabaseController.h:46
std::deque< std::shared_ptr< DataColumn > > DataRow
Type definition to easily create a DataRow.
Definition: DatabaseTypes.h:181