Right.cpp revision 54b6cfa9a9e5b861a9930af873580d6dc20f773c
1/* 2 * Copyright (C) 2007 The Android Open Source Project 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#include <rights/Right.h> 17#include <rights/OperationPermission.h> 18#include <rights/Constraint.h> 19 20/** see Right.h */ 21Right::Right() 22{ 23 24} 25 26/** see Right.h */ 27Right::~Right() 28{ 29 vector<OperationPermission*>::iterator it; 30 31 for (it = mOpList.begin(); it != mOpList.end(); it++) 32 { 33 delete(*it); 34 } 35 36 mOpList.clear(); 37} 38 39/** see Right.h */ 40void Right::addAssetID(const string& id) 41{ 42 mAssetNameList.push_back(id); 43} 44 45/** see Right.h */ 46void Right::addOperationPermission(OperationPermission* op) 47{ 48 mOpList.push_back(op); 49} 50 51/** see Right.h */ 52bool Right::checkPermission(OperationPermission::OPERATION type) 53{ 54 for (vector<OperationPermission*>::iterator it = mOpList.begin(); 55 it != mOpList.end(); it++) 56 { 57 if ((*it)->getType() == type) 58 { 59 return true; 60 } 61 } 62 63 return false; 64} 65 66/** see Right.h */ 67Constraint* Right::getConstraint(OperationPermission::OPERATION type) 68{ 69 for (vector<OperationPermission*>::iterator it = mOpList.begin(); 70 it != mOpList.end(); it++) 71 { 72 if ((*it)->getType() == type) 73 { 74 return (*it)->getConstraint(); 75 } 76 } 77 78 return NULL; 79} 80