Tizen 2.1 base
[framework/web/wrt-commons.git] / modules / ace / include / dpl / ace / Rule.h
1 /*
2  * Copyright (c) 2011 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 //
18 //
19 //  @ Project : Access Control Engine
20 //  @ File Name : Rule.h
21 //  @ Date : 2009-05-06
22 //  @ Author : Samsung
23 //
24 //
25
26 #if !defined(_RULE_H)
27 #define _RULE_H
28
29 #include "Attribute.h"
30 #include "Effect.h"
31 #include "Condition.h"
32 #include <dpl/assert.h>
33
34 class Rule : public AbstractTreeElement
35 {
36   public:
37
38     Effect evaluateRule(const AttributeSet * attrSet) const;
39
40     // KW   Rule(Effect effect, Condition condition) : effect(effect), condition(condition) {
41     // KW       //TODO we should set it to deny or smth, not inapplicable
42     // KW   }
43
44     Rule()
45     {
46         //TODO we should set it to deny or smth, not inapplicable
47         this->effect = Inapplicable;
48     }
49
50     // KW   Effect getEffect() const {
51     // KW       return this->effect;
52     // KW   };
53
54     void setEffect(Effect effect)
55     {
56         //We should not allow to set "Inapplicable" effect.
57         //Rules cannot have effect that is inapplicable, evaluation of the rules may however
58         //render the effect inapplicable.
59         Assert(effect != Inapplicable);
60         this->effect = effect;
61     }
62     void setCondition(Condition condition)
63     {
64         this->condition = condition;
65     }
66     void getAttributes(AttributeSet * attrSet)
67     {
68         condition.getAttributes(attrSet);
69     }
70
71     //deserialize
72     Rule(std::istream& is);
73     void serialize(std::ostream& os);
74
75     //DEBUG methods
76     std::string printEffect(const Effect effect) const;
77     void printData();
78
79   private:
80
81     Effect effect;
82     Condition condition;
83 };
84
85 #endif  //_RULE_H