mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2024-11-14 04:57:21 +01:00
Simple permission sorting.
This commit is contained in:
parent
9aa410c0cd
commit
7fcd38fff7
@ -1,5 +1,13 @@
|
||||
#include "rbac_permission.h"
|
||||
|
||||
bool RBACPermission::is_smaller(const Ref<RBACPermission> &b) const {
|
||||
if (!b.is_valid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return sort_order < b->sort_order;
|
||||
}
|
||||
|
||||
RBACPermission::RBACPermission() :
|
||||
Resource() {
|
||||
|
||||
|
@ -17,6 +17,8 @@ public:
|
||||
int sort_order;
|
||||
int permissions;
|
||||
|
||||
bool is_smaller(const Ref<RBACPermission> &b) const;
|
||||
|
||||
RBACPermission();
|
||||
~RBACPermission();
|
||||
};
|
||||
|
@ -1,5 +1,15 @@
|
||||
#include "rbac_rank.h"
|
||||
|
||||
void RBACRank::sort_permissions() {
|
||||
for (int i = 0; i < permissions.size(); ++i) {
|
||||
for (int j = i + 1; j < permissions.size(); ++j) {
|
||||
if (permissions[j]->is_smaller(permissions[i])) {
|
||||
permissions.swap(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RBACRank::RBACRank() :
|
||||
Resource() {
|
||||
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
|
||||
Vector<Ref<RBACPermission> > permissions;
|
||||
|
||||
void sort_permissions();
|
||||
|
||||
RBACRank();
|
||||
~RBACRank();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user