Mark all TEEC APIs as deprecated since Tizen 6.5
[platform/core/webapi/libteec.git] / src / teec / TeecManager.h
1 /**
2  * Copyright (c) 2017-2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file
18  * @author Lukasz Kostyra (l.kostyra@samsung.com)
19  * @brief  TeecManager singleton class declaration
20  */
21
22 #ifndef LIBTEEC_TEEC_MANAGER_H_
23 #define LIBTEEC_TEEC_MANAGER_H_
24
25 #include <unordered_map>
26 #include <list>
27 #include <string>
28 #include <memory>
29 #include <mutex>
30
31 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
32 #include <tee_client_api.h>
33
34 #include "TeecContext.h"
35
36
37 namespace extension {
38 namespace libteec {
39
40 using TeecContextMap = std::unordered_map<std::string, TeecContextPtr>;
41 using TeecOperationMap = std::unordered_map<uint32_t, TEEC_Operation>;
42
43 class TeecManager final
44 {
45 public:
46     static TeecManager& Instance();
47
48     TeecContextPtr GetContext(const std::string& contextName);
49
50     uint32_t CreateOperation();
51     TEEC_Operation GetOperation(uint32_t id) const;
52     void RemoveOperation(uint32_t id);
53
54 private:
55     TeecManager() = default;
56     ~TeecManager() = default;
57     TeecManager(const TeecManager&) = delete;
58     TeecManager(TeecManager&&) = delete;
59     TeecManager& operator=(const TeecManager&) = delete;
60     TeecManager& operator=(TeecManager&&) = delete;
61
62     TeecContextMap mContexts;
63     TeecOperationMap mOperations;
64     mutable std::mutex mOperationListMutex;
65 };
66
67 } // namespace libteec
68 } // namespace extension
69
70 #endif // LIBTEEC_TEEC_MANAGER_H_