Leosac  0.8.0
Open Source Access Control
DBService.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
23 #include "core/auth/AuthFwd.hpp"
26 #include "tools/ToolsFwd.hpp"
27 #include "tools/db/db_fwd.hpp"
28 
29 namespace Leosac
30 {
34 class DBService
35 {
36  public:
37  enum Flag
38  {
39  DEFAULT = 0,
41  };
43 
47  DBPtr db() const;
48 
52  size_t operation_count() const;
53 
59  Auth::GroupPtr find_group_by_id(const Auth::GroupId &id, Flag f = Flag::DEFAULT);
60 
64  Auth::UserPtr find_user_by_id(const Auth::UserId &id, Flag f = Flag::DEFAULT);
65 
68  Flag f = Flag::DEFAULT);
69 
71  Flag f = Flag::DEFAULT);
72 
74  Flag f = Flag::DEFAULT);
75 
76  Auth::IDoorPtr find_door_by_id(const Auth::DoorId &id, Flag f = Flag::DEFAULT);
77 
78  Auth::IZonePtr find_zone_by_id(const Auth::ZoneId &id, Flag f = Flag::DEFAULT);
79 
81  Flag f = Flag::DEFAULT);
82 
84  Flag f = Flag::DEFAULT);
85 
87  Flag f = Flag::DEFAULT);
99 
103  void update(Audit::IAuditEntry &);
104 
105  private:
107 };
108 }
Leosac::Tools::ISchedulePtr
std::shared_ptr< ISchedule > ISchedulePtr
Definition: ToolsFwd.hpp:37
Leosac::Auth::ZoneId
unsigned long ZoneId
Definition: AuthFwd.hpp:119
Leosac::DBService::find_update_by_id
update::IUpdatePtr find_update_by_id(const update::UpdateId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:162
Leosac::DBService::database_
const DBPtr database_
Definition: DBService.hpp:106
Leosac::DBService::DEFAULT
@ DEFAULT
Definition: DBService.hpp:39
AuthFwd.hpp
Leosac::DBService::find_door_by_id
Auth::IDoorPtr find_door_by_id(const Auth::DoorId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:114
Leosac::DBService::operation_count
size_t operation_count() const
Return the number of operation against the database.
Definition: DBService.cpp:51
Leosac::Auth::UserPtr
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Leosac::update::IUpdatePtr
std::shared_ptr< IUpdate > IUpdatePtr
Definition: UpdateFwd.hpp:42
Leosac::Audit::AuditEntryId
unsigned long AuditEntryId
Definition: AuditFwd.hpp:31
Leosac::DBPtr
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
Leosac::Audit::IAuditEntryPtr
std::shared_ptr< IAuditEntry > IAuditEntryPtr
Definition: AuditFwd.hpp:40
Leosac::Auth::IAccessPointPtr
std::shared_ptr< IAccessPoint > IAccessPointPtr
Definition: AuthFwd.hpp:127
Leosac::DBService
Provides various database-related services to consumer.
Definition: DBService.hpp:34
Leosac::DBService::update
void update(Audit::IAuditEntry &)
Update the object.
Definition: DBService.cpp:195
Leosac::DBService::Flag
Flag
Definition: DBService.hpp:37
Leosac::DBService::find_audit_by_id
Audit::IAuditEntryPtr find_audit_by_id(const Audit::AuditEntryId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:137
Leosac::DBService::find_schedule_by_id
Tools::ISchedulePtr find_schedule_by_id(const Tools::ScheduleId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:103
ToolsFwd.hpp
Leosac::DBService::DBService
DBService(DBPtr db)
Definition: DBService.cpp:40
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::DBService::find_credential_by_id
Cred::ICredentialPtr find_credential_by_id(const Cred::CredentialId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:92
Leosac::Auth::DoorId
unsigned long DoorId
Definition: AuthFwd.hpp:107
Leosac::Auth::UserGroupMembershipId
unsigned long UserGroupMembershipId
Definition: AuthFwd.hpp:82
Leosac::Auth::IDoorPtr
std::shared_ptr< IDoor > IDoorPtr
Definition: AuthFwd.hpp:104
Leosac::Tools::ScheduleId
unsigned long ScheduleId
Definition: ToolsFwd.hpp:33
Leosac::Auth::GroupPtr
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
Leosac::DBService::find_membership_by_id
Auth::UserGroupMembershipPtr find_membership_by_id(const Auth::UserGroupMembershipId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:82
Leosac::Auth::UserGroupMembershipPtr
std::shared_ptr< UserGroupMembership > UserGroupMembershipPtr
Definition: AuthFwd.hpp:81
Leosac::DBService::find_group_by_id
Auth::GroupPtr find_group_by_id(const Auth::GroupId &id, Flag f=Flag::DEFAULT)
Retrieve a group by its id.
Definition: DBService.cpp:61
Leosac::DBService::find_access_point_by_id
Auth::IAccessPointPtr find_access_point_by_id(const Auth::AccessPointId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:151
Leosac::Audit::IAuditEntry
Base interface to Audit object.
Definition: IAuditEntry.hpp:47
Leosac::Cred::ICredentialPtr
std::shared_ptr< ICredential > ICredentialPtr
Definition: CredentialFwd.hpp:32
Leosac::Cred::CredentialId
unsigned long CredentialId
Definition: CredentialFwd.hpp:35
Leosac::Auth::GroupId
unsigned long GroupId
Definition: AuthFwd.hpp:41
Leosac::DBService::db
DBPtr db() const
Simply returns the underlying database pointer.
Definition: DBService.cpp:46
Leosac::DBService::find_user_by_id
Auth::UserPtr find_user_by_id(const Auth::UserId &id, Flag f=Flag::DEFAULT)
Find a user by its id.
Definition: DBService.cpp:71
db_fwd.hpp
Leosac::DBService::THROW_IF_NOT_FOUND
@ THROW_IF_NOT_FOUND
Definition: DBService.hpp:40
IAuditEntry.hpp
Leosac::Auth::IZonePtr
std::shared_ptr< IZone > IZonePtr
Definition: AuthFwd.hpp:116
Leosac::DBService::persist
void persist(Audit::IAuditEntry &)
Persist an audit entry object.
Definition: DBService.cpp:190
Leosac::Auth::UserId
unsigned long UserId
Definition: AuthFwd.hpp:34
CredentialFwd.hpp
UpdateFwd.hpp
Leosac::DBService::find_zone_by_id
Auth::IZonePtr find_zone_by_id(const Auth::ZoneId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:125
Leosac::update::UpdateId
unsigned long UpdateId
Definition: UpdateFwd.hpp:56
Leosac::Auth::AccessPointId
unsigned long AccessPointId
Definition: AuthFwd.hpp:128