2 * Copyright (c) 2011 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.
20 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
25 #ifndef ACCESS_CONTROL_DAO_BASEATTRIBUTE_H_
26 #define ACCESS_CONTROL_DAO_BASEATTRIBUTE_H_
32 #include <dpl/assert.h>
37 typedef std::shared_ptr<BaseAttribute> BaseAttributePtr;
46 enum class Type { Subject, Environment, Resource, FunctionParam,
47 WidgetParam, Undefined };
52 UnaryPredicate(const AceDB::BaseAttribute *comp = NULL) :
57 bool operator()(const AceDB::BaseAttributePtr &comp)
59 Assert(m_priv != NULL);
60 if (m_priv->getName()->compare(*comp->getName()) != 0) {
63 return m_priv->getType() == comp->getType();
66 bool operator()(const AceDB::BaseAttributePtr &comp1,
67 const AceDB::BaseAttributePtr &comp2)
69 if (comp1->getType() != comp2->getType()) {
70 return comp1->getType() < comp2->getType();
72 return comp1->getName()->compare(*comp2->getName()) < 0;
76 const AceDB::BaseAttribute *m_priv;
81 m_typeId(Type::Undefined),
82 m_undetermindState(false)
85 virtual void setName(const std::string& name)
89 virtual void setName(const std::string* name)
94 virtual void setType(const Type& type)
98 virtual Type getType() const
103 virtual const std::string* getName() const
109 virtual void setUndetermind(bool tmp)
111 m_undetermindState = tmp;
113 virtual bool isUndetermind() const
115 return m_undetermindState;
117 virtual std::list<std::string> * getValue() const
119 return const_cast<std::list<std::string>* >(&value);
121 virtual bool isValueEmpty() const
123 return value.empty();
126 virtual void setValue(const std::list<std::string>& arg)
131 virtual ~BaseAttribute()
135 static const char * typeToString(Type type);
137 virtual std::string toString() const;
142 bool m_undetermindState;
143 std::list<std::string> value; //string bag list
146 typedef std::set<BaseAttributePtr, BaseAttribute::UnaryPredicate> BaseAttributeSet;