Leosac  0.8.0
Open Source Access Control
Leosac::DBService Class Reference

Provides various database-related services to consumer. More...

#include <DBService.hpp>

+ Collaboration diagram for Leosac::DBService:

Public Types

enum  Flag { DEFAULT = 0, THROW_IF_NOT_FOUND = 1 }
 

Public Member Functions

 DBService (DBPtr db)
 
DBPtr db () const
 Simply returns the underlying database pointer. More...
 
size_t operation_count () const
 Return the number of operation against the database. More...
 
Auth::GroupPtr find_group_by_id (const Auth::GroupId &id, Flag f=Flag::DEFAULT)
 Retrieve a group by its id. More...
 
Auth::UserPtr find_user_by_id (const Auth::UserId &id, Flag f=Flag::DEFAULT)
 Find a user by its id. More...
 
Auth::UserGroupMembershipPtr find_membership_by_id (const Auth::UserGroupMembershipId &id, Flag f=Flag::DEFAULT)
 
Cred::ICredentialPtr find_credential_by_id (const Cred::CredentialId &id, Flag f=Flag::DEFAULT)
 
Tools::ISchedulePtr find_schedule_by_id (const Tools::ScheduleId &id, Flag f=Flag::DEFAULT)
 
Auth::IDoorPtr find_door_by_id (const Auth::DoorId &id, Flag f=Flag::DEFAULT)
 
Auth::IZonePtr find_zone_by_id (const Auth::ZoneId &id, Flag f=Flag::DEFAULT)
 
Audit::IAuditEntryPtr find_audit_by_id (const Audit::AuditEntryId &id, Flag f=Flag::DEFAULT)
 
Auth::IAccessPointPtr find_access_point_by_id (const Auth::AccessPointId &id, Flag f=Flag::DEFAULT)
 
update::IUpdatePtr find_update_by_id (const update::UpdateId &id, Flag f=Flag::DEFAULT)
 
void persist (Audit::IAuditEntry &)
 Persist an audit entry object. More...
 
void update (Audit::IAuditEntry &)
 Update the object. More...
 

Private Attributes

const DBPtr database_
 

Detailed Description

Provides various database-related services to consumer.

Definition at line 34 of file DBService.hpp.

Member Enumeration Documentation

◆ Flag

Enumerator
DEFAULT 
THROW_IF_NOT_FOUND 

Definition at line 37 of file DBService.hpp.

Constructor & Destructor Documentation

◆ DBService()

DBService::DBService ( DBPtr  db)

Definition at line 40 of file DBService.cpp.

Member Function Documentation

◆ db()

DBPtr DBService::db ( ) const

Simply returns the underlying database pointer.

Definition at line 46 of file DBService.cpp.

◆ find_access_point_by_id()

Auth::IAccessPointPtr DBService::find_access_point_by_id ( const Auth::AccessPointId id,
DBService::Flag  flags = Flag::DEFAULT 
)

Definition at line 151 of file DBService.cpp.

◆ find_audit_by_id()

Audit::IAuditEntryPtr DBService::find_audit_by_id ( const Audit::AuditEntryId id,
Flag  f = Flag::DEFAULT 
)

Definition at line 137 of file DBService.cpp.

◆ find_credential_by_id()

Cred::ICredentialPtr DBService::find_credential_by_id ( const Cred::CredentialId id,
DBService::Flag  flags = Flag::DEFAULT 
)

Definition at line 92 of file DBService.cpp.

◆ find_door_by_id()

Auth::IDoorPtr DBService::find_door_by_id ( const Auth::DoorId id,
DBService::Flag  flags = Flag::DEFAULT 
)

Definition at line 114 of file DBService.cpp.

◆ find_group_by_id()

Auth::GroupPtr DBService::find_group_by_id ( const Auth::GroupId id,
Flag  f = Flag::DEFAULT 
)

Retrieve a group by its id.

Returns
The group, or nullptr.

Definition at line 61 of file DBService.cpp.

◆ find_membership_by_id()

Auth::UserGroupMembershipPtr DBService::find_membership_by_id ( const Auth::UserGroupMembershipId id,
Flag  f = Flag::DEFAULT 
)

Definition at line 82 of file DBService.cpp.

◆ find_schedule_by_id()

Tools::ISchedulePtr DBService::find_schedule_by_id ( const Tools::ScheduleId id,
DBService::Flag  flags = Flag::DEFAULT 
)

Definition at line 103 of file DBService.cpp.

◆ find_update_by_id()

update::IUpdatePtr DBService::find_update_by_id ( const update::UpdateId id,
DBService::Flag  flags = Flag::DEFAULT 
)

Definition at line 162 of file DBService.cpp.

◆ find_user_by_id()

Auth::UserPtr DBService::find_user_by_id ( const Auth::UserId id,
Flag  f = Flag::DEFAULT 
)

Find a user by its id.

Definition at line 71 of file DBService.cpp.

◆ find_zone_by_id()

Auth::IZonePtr DBService::find_zone_by_id ( const Auth::ZoneId id,
DBService::Flag  flags = Flag::DEFAULT 
)

Definition at line 125 of file DBService.cpp.

◆ operation_count()

size_t DBService::operation_count ( ) const

Return the number of operation against the database.

Definition at line 51 of file DBService.cpp.

◆ persist()

void DBService::persist ( Audit::IAuditEntry ientry)

Persist an audit entry object.

Begin and commit a new transaction if there is currently no transaction in progress. Otherwise, simple persist the object in the current transaction, but does not call commit().

Note
The object may not be const because its using an automatically assigned database id.

Definition at line 190 of file DBService.cpp.

◆ update()

void DBService::update ( Audit::IAuditEntry ientry)

Update the object.

Definition at line 195 of file DBService.cpp.

Member Data Documentation

◆ database_

const DBPtr Leosac::DBService::database_
private

Definition at line 106 of file DBService.hpp.


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