1 /***************************************************************************
2 * Copyright (C) 2008 by Sverre Rabbelier *
3 * sverre@rabbelier.nl *
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. *
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. *
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
) :
31 throw std::invalid_argument("Permission::Permission(), m_permission == NULL!");
34 Permission::~Permission(void)
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
)
52 ValuePtr
value(new FieldValue(db::TableImpls::Get()->PERMISSIONS
->GRANT
, grant
? 1 : 0));
53 m_permission
->setValue(value
);
56 void Permission::setLog(bool log
)
59 ValuePtr
value(new FieldValue(db::TableImpls::Get()->PERMISSIONS
->LOG
, log
? 1 : 0));
60 m_permission
->setValue(value
);
63 void Permission::Delete()
66 m_permission
->erase();
69 void Permission::Save()
75 void Permission::Discard()
78 m_permission
->discard();
81 bool Permission::Exists()
84 return m_permission
->exists();
87 SavableManagerPtr
Permission::getManager() const
92 TableImplPtr
Permission::getTable() const
94 return m_permission
->getTable();