Add a filter-by-from/to-chunk in ExitManager::List.
[UnsignedByte.git] / src / DB / Savables / Permission.cpp
blobfa22e223c112ce42ac4436df35b7e14d647165dc
1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "Permission.h"
22 #include "PermissionManager.h"
23 #include "TableImpls.h"
25 using mud::Permission;
27 Permission::Permission(SavableManagerPtr area) :
28 m_permission(area)
30 if(!m_permission)
31 throw std::invalid_argument("Permission::Permission(), m_permission == NULL!");
34 Permission::~Permission(void)
36 Unlock();
39 bool Permission::hasGrant() const
41 return m_permission->getValue(db::TableImpls::Get()->PERMISSIONS->GRANT)->getBoolValue();
44 bool Permission::hasLog() const
46 return m_permission->getValue(db::TableImpls::Get()->PERMISSIONS->LOG)->getBoolValue();
49 void Permission::setGrant(bool grant)
51 Lock();
52 ValuePtr value(new FieldValue(db::TableImpls::Get()->PERMISSIONS->GRANT, grant ? 1 : 0));
53 m_permission->setValue(value);
56 void Permission::setLog(bool log)
58 Lock();
59 ValuePtr value(new FieldValue(db::TableImpls::Get()->PERMISSIONS->LOG, log ? 1 : 0));
60 m_permission->setValue(value);
63 void Permission::Delete()
65 Lock();
66 m_permission->erase();
69 void Permission::Save()
71 Lock();
72 m_permission->save();
75 void Permission::Discard()
77 Lock();
78 m_permission->discard();
81 bool Permission::Exists()
83 Lock();
84 return m_permission->exists();
87 SavableManagerPtr Permission::getManager() const
89 return m_permission;
92 TableImplPtr Permission::getTable() const
94 return m_permission->getTable();