pianod2
multisource multiuser scriptable networked music player
ownership.h
Go to the documentation of this file.
1 
9 #ifndef __pianod__ownership__
10 #define __pianod__ownership__
11 
12 #include <config.h>
13 
14 #include "fundamentals.h"
15 #include "lookup.h"
16 
18 class PrimaryOwnership : public Ownership {
19 private:
21  User *owner = nullptr;
22 public:
23  PrimaryOwnership (void);
24  PrimaryOwnership (Type rule, User *owner = nullptr);
25  ~PrimaryOwnership (void);
26  void abandon (void);
27  void abandon (const User *user);
28  User *getOwner (void) const { return owner; };
29  inline bool isOwned (void) const { return owner != nullptr; };
30  const std::string &ownerName (void) const;
31  virtual bool isOwnedBy (const User *user) const override;
32  virtual bool hasPermission (const User *user, Action action) const override;
33 };
34 
35 
38 protected:
39  virtual Ownership *parentOwner (void) const = 0;
40 public:
41  virtual bool isOwnedBy (const User *user) const override;
42  virtual bool hasPermission (const User *user, Action action) const override;
43 };
44 
45 
48 
49 
50 #endif // defined(__pianod__ownership__)
Class to map between enumerations and their text values.
Definition: lookup.h:30
Privilege management for media sources.
Definition: fundamentals.h:351
Action
Access actions for an object.
Definition: fundamentals.h:364
Type
Access levels for an object.
Definition: fundamentals.h:355
@ DISOWNED
Object has no owner.
Ownership where privilege is defined within the object.
Definition: ownership.h:18
~PrimaryOwnership(void)
Definition: ownership.cpp:33
Type access
Definition: ownership.h:20
User * getOwner(void) const
Definition: ownership.h:28
virtual bool hasPermission(const User *user, Action action) const override
Determine if a user has permission to use this item in some manner.
Definition: ownership.cpp:74
PrimaryOwnership(void)
Default construct ownership: No owner, private access.
Definition: ownership.cpp:21
void abandon(void)
Disassociate ownership from any owner, and mark as disowned.
Definition: ownership.cpp:46
virtual bool isOwnedBy(const User *user) const override
Check if we are owned by a user.
Definition: ownership.cpp:64
User * owner
Definition: ownership.h:21
const std::string & ownerName(void) const
Retrieve the name of the owner.
Definition: ownership.cpp:39
bool isOwned(void) const
Definition: ownership.h:29
Ownership where privilege is regulated by some parent object.
Definition: ownership.h:37
virtual bool isOwnedBy(const User *user) const override
Definition: ownership.cpp:83
virtual bool hasPermission(const User *user, Action action) const override
Definition: ownership.cpp:88
virtual Ownership * parentOwner(void) const =0
Data about each user.
Definition: user.h:53
Essential data structures and support.
Action
Definition: json_format.cpp:84
Lookup tables.
const LookupTable< Ownership::Type > OwnershipLookup
Definition: ownership.h:46
OwnershipLookup OWNERSHIP