2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 * @file CacheInterface.h
18 * @author Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
19 * @author Zofia Abramowska <z.abramowska@samsung.com>
21 * @brief This file contains cache interface definitions.
24 #ifndef SRC_CLIENT_CACHE_CACHEINTERFACE_H_
25 #define SRC_CLIENT_CACHE_CACHEINTERFACE_H_
31 #include <cynara-client.h>
32 #include <types/PolicyKey.h>
33 #include <types/PolicyResult.h>
34 #include <types/PolicyType.h>
38 class InterpreterInterface;
39 typedef std::shared_ptr<InterpreterInterface> InterpreterInterfacePtr;
42 typedef std::shared_ptr<PluginCache> PluginCachePtr;
44 class ResultGetterInterface;
45 typedef std::shared_ptr<ResultGetterInterface> ResultGetterInterfacePtr;
47 class ResultGetterInterface {
49 virtual int requestResult(const PolicyKey &key, PolicyResult &result) noexcept = 0;
50 virtual ~ResultGetterInterface() = default;
53 class InterpreterInterface {
55 virtual bool isCacheable(const PolicyResult &result) noexcept = 0;
56 virtual bool isUsable(const PolicyResult &result) noexcept = 0;
57 virtual int toResult(const PolicyResult &result) noexcept = 0;
59 virtual ~InterpreterInterface() = default;
64 PluginCache(ResultGetterInterfacePtr getter) : m_getter(getter) {}
65 virtual int get(const std::string &session, const PolicyKey &key) = 0;
67 void registerPlugin(const PolicyType policyType, InterpreterInterfacePtr plugin) {
68 m_plugins[policyType] = plugin;
71 virtual void clear(void) {
75 virtual ~PluginCache() = default;
78 std::map<PolicyType, InterpreterInterfacePtr> m_plugins;
79 ResultGetterInterfacePtr m_getter;
84 #endif // SRC_CLIENT_CACHE_CACHEINTERFACE_H_