Leosac  0.8.0
Open Source Access Control
Leosac::Auth::Group Class Reference

A authentication group regroup users that share permissions. More...

#include <Group.hpp>

+ Inheritance diagram for Leosac::Auth::Group:
+ Collaboration diagram for Leosac::Auth::Group:

Public Member Functions

 Group ()
 
 Group (const std::string &group_name)
 
GroupId id () const
 Retrieve the unique identifier of the group. More...
 
void id (const GroupId &new_id)
 Manually set the ID of a group. More...
 
const std::string & name () const
 
void name (const std::string &name)
 
const std::string & description () const
 
void description (const std::string &desc)
 
const std::vector< UserPtr > & members () const
 
std::vector< UserLPtrlazy_members () const
 Retrieve lazy pointers to members. More...
 
std::vector< Tools::ScheduleMappingLWPtrlazy_schedules_mapping () const
 Returns the vector of lazy_weak_ptr to schedule mapping. More...
 
UserGroupMembershipPtr member_add (UserPtr m, GroupRank rank=GroupRank::MEMBER)
 
IAccessProfilePtr profile ()
 
void profile (IAccessProfilePtr p)
 
const UserGroupMembershipSetuser_memberships () const
 Retrieve the UserGroupMembership that this group is involved with. More...
 
bool member_has (Auth::UserId user_id, GroupRank *rank_out=nullptr) const
 Check if user_id is a member of this group. More...
 
void schedule_mapping_added (const Tools::ScheduleMappingPtr &sched_mapping)
 The group has been mapped by a schedule. More...
 

Private Member Functions

void odb_callback (odb::callback_event e, odb::database &) const
 

Private Attributes

GroupId id_
 The group identifier. More...
 
UserGroupMembershipSet membership_
 
std::vector< Tools::ScheduleMappingLWPtrschedules_mapping_
 
std::vector< UserPtrloaded_members_
 This returns a vector of loaded User object. More...
 
std::string name_
 
std::string description_
 A (potentially long) description of the group. More...
 
IAccessProfilePtr profile_
 
const size_t version_
 

Friends

class odb::access
 
class GroupValidator
 
class Leosac::TestAccess
 

Detailed Description

A authentication group regroup users that share permissions.

Definition at line 57 of file Group.hpp.

Constructor & Destructor Documentation

◆ Group() [1/2]

Group::Group ( )

Definition at line 28 of file Group.cpp.

◆ Group() [2/2]

Group::Group ( const std::string &  group_name)
explicit

Definition at line 34 of file Group.cpp.

Member Function Documentation

◆ description() [1/2]

const std::string & Group::description ( ) const

Definition at line 133 of file Group.cpp.

◆ description() [2/2]

void Group::description ( const std::string &  desc)

Definition at line 138 of file Group.cpp.

◆ id() [1/2]

GroupId Group::id ( ) const

Retrieve the unique identifier of the group.

Definition at line 83 of file Group.cpp.

◆ id() [2/2]

void Group::id ( const GroupId new_id)

Manually set the ID of a group.

Note
This is generally not recommended.

Definition at line 88 of file Group.cpp.

◆ lazy_members()

std::vector< UserLPtr > Group::lazy_members ( ) const

Retrieve lazy pointers to members.

Definition at line 93 of file Group.cpp.

◆ lazy_schedules_mapping()

std::vector< Tools::ScheduleMappingLWPtr > Group::lazy_schedules_mapping ( ) const

Returns the vector of lazy_weak_ptr to schedule mapping.

Definition at line 157 of file Group.cpp.

◆ member_add()

UserGroupMembershipPtr Group::member_add ( UserPtr  m,
GroupRank  rank = GroupRank::MEMBER 
)

Definition at line 61 of file Group.cpp.

◆ member_has()

bool Group::member_has ( Auth::UserId  user_id,
GroupRank rank_out = nullptr 
) const

Check if user_id is a member of this group.

If it is a member, then rank_out (if non null) is set to the rank of the user inside the group.

Definition at line 143 of file Group.cpp.

◆ members()

const std::vector< UserPtr > & Group::members ( ) const

Definition at line 46 of file Group.cpp.

◆ name() [1/2]

const std::string & Group::name ( ) const

Definition at line 41 of file Group.cpp.

◆ name() [2/2]

void Group::name ( const std::string &  name)

Definition at line 107 of file Group.cpp.

◆ odb_callback()

void Group::odb_callback ( odb::callback_event  e,
odb::database &  db 
) const
private

Definition at line 113 of file Group.cpp.

◆ profile() [1/2]

IAccessProfilePtr Group::profile ( )

Definition at line 73 of file Group.cpp.

◆ profile() [2/2]

void Group::profile ( IAccessProfilePtr  p)

Definition at line 78 of file Group.cpp.

◆ schedule_mapping_added()

void Group::schedule_mapping_added ( const Tools::ScheduleMappingPtr sched_mapping)

The group has been mapped by a schedule.

See also
Auth::Door::schedule_mapping_added

Definition at line 162 of file Group.cpp.

◆ user_memberships()

const UserGroupMembershipSet & Group::user_memberships ( ) const

Retrieve the UserGroupMembership that this group is involved with.

While the set is always eagerly loaded, the group() and user() method in each Membership will return lazy weak pointer.

Definition at line 128 of file Group.cpp.

Friends And Related Function Documentation

◆ GroupValidator

friend class GroupValidator
friend

Definition at line 124 of file Group.hpp.

◆ Leosac::TestAccess

friend class Leosac::TestAccess
friend

Definition at line 125 of file Group.hpp.

◆ odb::access

friend class odb::access
friend

Definition at line 123 of file Group.hpp.

Member Data Documentation

◆ description_

std::string Leosac::Auth::Group::description_
private

A (potentially long) description of the group.

Definition at line 161 of file Group.hpp.

◆ id_

GroupId Leosac::Auth::Group::id_
private

The group identifier.

This is a the primary key for the object.

Definition at line 135 of file Group.hpp.

◆ loaded_members_

std::vector<UserPtr> Leosac::Auth::Group::loaded_members_
mutableprivate

This returns a vector of loaded User object.

When members() is called, this vector is populated by copying some pointers from membership_.

Definition at line 149 of file Group.hpp.

◆ membership_

UserGroupMembershipSet Leosac::Auth::Group::membership_
private

Definition at line 138 of file Group.hpp.

◆ name_

std::string Leosac::Auth::Group::name_
private

Definition at line 154 of file Group.hpp.

◆ profile_

IAccessProfilePtr Leosac::Auth::Group::profile_
private

Definition at line 164 of file Group.hpp.

◆ schedules_mapping_

std::vector<Tools::ScheduleMappingLWPtr> Leosac::Auth::Group::schedules_mapping_
private

Definition at line 141 of file Group.hpp.

◆ version_

const size_t Leosac::Auth::Group::version_
private

Definition at line 167 of file Group.hpp.


The documentation for this class was generated from the following files: