My program has three different types of users:
1. Basic User
2. System Administrator (There are multiple "systems" in my program)
3. Overall Site Administrator (A "super user" who can do everything a SysAdmin does, and creates other users)
My inheritance scheme thus far is (with relevant functionality included):
Code:
class BasicUser{
// ...
protected:
unsigned char key;
};
class SysAdmin : public BasicUser{
// ....
void setUserKey( BasicUser& basicUser );
protected:
unsigned char mySystemKey;
};
class SiteAdmin : public SysAdmin{
// ...
BasicUser* makeBasicUser( int id, string name );
SysAdmin* makeSysAdmin( int id, string name, unsigned char sysKey );
}:
A basic user can navigate the program and do things granted their key allows them to (I'm setting their key with a bitwise OR and checking their key with a bitwise AND).
A SysAdmin has "mySystemKey" which they use to grant a user access to their system.
A SiteAdmin and only a SiteAdmin creates both BasicUsers and SysAdmins.
Here's the problem:
I will need to group all 3 kinds of users together (which I can becasuse they are all BasicUsers). However, it is possible that a user can be a BasicUser in one system, AND a SysAdmin in another system. I'd really like to avoid duplicating a user who has different roles on different systems without giving a BasicUser all the functionality of SysAdmin and saying they can only use that functionality if they have "permission" to do so.
In other words, I don't want to eliminate the "SysAdmin" role by giving "mySystemKey" and "setUserKey()" to a BasicUser and then check to see if they can actually "use" those functions. I'd like to keep the roles as separate classes, but I also don't want to duplicate any user who might belong to multiple systems.
Is this possible?
Any ideas?
Thank you all in advance.