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 PolicyBucket.h
18 * @author Lukasz Wojciechowski <l.wojciechowski@partner.samsung.com>
19 * @author Aleksander Zdyb <a.zdyb@partner.samsung.com>
21 * @brief This file defines PolicyBucket type - a policy aggregation
25 #ifndef CYNARA_COMMON_TYPES_POLICYBUCKET_H
26 #define CYNARA_COMMON_TYPES_POLICYBUCKET_H
28 #include "PolicyCollection.h"
29 #include "PolicyKey.h"
31 #include "exceptions/NotImplementedException.h"
32 #include "types/pointers.h"
33 #include "types/PolicyType.h"
34 #include "PolicyBucketId.h"
42 // TODO: Move this const somewhere else
43 const PolicyBucketId defaultPolicyBucketId("");
48 PolicyBucket() : m_defaultPolicy(PolicyResult(PolicyType::DENY)) {}
49 PolicyBucket(const PolicyCollection &policies)
50 : m_policyCollection(policies),
51 m_defaultPolicy(PolicyResult(PolicyType::DENY)) {}
53 PolicyBucket filtered(const PolicyKey &key) const;
56 PolicyCollection m_policyCollection;
57 PolicyResult m_defaultPolicy;
61 const PolicyResult &defaultPolicy() const {
62 return m_defaultPolicy;
65 const PolicyBucketId &id() const {
69 PolicyCollection &policyCollection() {
70 return m_policyCollection;
73 const PolicyCollection &policyCollection() const {
74 return m_policyCollection;
77 void setDefaultPolicy(const PolicyResult &defaultPolicy) {
78 m_defaultPolicy = defaultPolicy;
82 } /* namespace Cynara */
83 #endif /* CYNARA_COMMON_TYPES_POLICYBUCKET_H */