libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
DeviceTranslations.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base 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  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef DEVICETRANSLATIONS_H_
32 #define DEVICETRANSLATIONS_H_
33 
34 #include <vector>
35 #include <memory>
36 #include <mutex>
37 #include <unordered_set>
38 
40 #include "ParameterGroup.h"
41 
42 namespace BaseLib
43 {
44 
45 class SharedObjects;
46 
47 namespace DeviceDescription
48 {
49 
54  public:
55  DeviceTranslations(BaseLib::SharedObjects *baseLib, int32_t family);
56  virtual ~DeviceTranslations() = default;
57  void clear();
58  PVariable getTypeDescription(const std::string &filename, const std::string &language, const std::string &deviceId);
59  PVariable getTypeLongDescription(const std::string &filename, const std::string &language, const std::string &deviceId);
60  PVariable getParameterLabel(const std::string &filename, const std::string &language, ParameterGroup::Type::Enum parameterGroupType, const std::string &parameterGroupId, const std::string &parameterId);
61  PVariable getParameterDescription(const std::string &filename, const std::string &language, ParameterGroup::Type::Enum parameterGroupType, const std::string &parameterGroupId, const std::string &parameterId);
62  protected:
64  int32_t _family = -1;
66  std::unordered_map<std::string, std::unordered_map<std::string, PHomegearDeviceTranslation>> _deviceTranslations;
67 
68  std::unordered_set<std::string> getLanguages();
69  std::unordered_map<std::string, PHomegearDeviceTranslation> getTranslations(const std::string &filename);
70  PHomegearDeviceTranslation getTranslation(const std::string &filename, const std::string &language);
71  PHomegearDeviceTranslation load(const std::string &filename, const std::string &language);
72 };
73 
74 }
75 }
76 #endif
PVariable getParameterLabel(const std::string &filename, const std::string &language, ParameterGroup::Type::Enum parameterGroupType, const std::string &parameterGroupId, const std::string &parameterId)
Definition: DeviceTranslations.cpp:222
PHomegearDeviceTranslation load(const std::string &filename, const std::string &language)
Definition: DeviceTranslations.cpp:47
int32_t deviceId
Definition: Licensing.h:381
This is the base library main class.
Definition: BaseLib.h:95
Definition: BaseLib.cpp:34
DeviceTranslations(BaseLib::SharedObjects *baseLib, int32_t family)
Definition: DeviceTranslations.cpp:38
std::unordered_map< std::string, std::unordered_map< std::string, PHomegearDeviceTranslation > > _deviceTranslations
Definition: DeviceTranslations.h:66
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
PHomegearDeviceTranslation getTranslation(const std::string &filename, const std::string &language)
Definition: DeviceTranslations.cpp:123
std::shared_ptr< HomegearDeviceTranslation > PHomegearDeviceTranslation
Helper type for HomegearDeviceTranslation pointers.
Definition: HomegearDeviceTranslation.h:53
PVariable getParameterDescription(const std::string &filename, const std::string &language, ParameterGroup::Type::Enum parameterGroupType, const std::string &parameterGroupId, const std::string &parameterId)
Definition: DeviceTranslations.cpp:279
std::unordered_map< std::string, PHomegearDeviceTranslation > getTranslations(const std::string &filename)
Definition: DeviceTranslations.cpp:87
Class to work with translations of device description files of one device family. ...
Definition: DeviceTranslations.h:53
void clear()
Definition: DeviceTranslations.cpp:43
int32_t _family
Definition: DeviceTranslations.h:64
PVariable getTypeDescription(const std::string &filename, const std::string &language, const std::string &deviceId)
Definition: DeviceTranslations.cpp:164
std::unordered_set< std::string > getLanguages()
Definition: DeviceTranslations.cpp:71
BaseLib::SharedObjects * _bl
Definition: DeviceTranslations.h:63
std::mutex _deviceTranslationsMutex
Definition: DeviceTranslations.h:65
PVariable getTypeLongDescription(const std::string &filename, const std::string &language, const std::string &deviceId)
Definition: DeviceTranslations.cpp:193