Leosac  0.7.0
OpenSourceAccessControl
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 }
unsigned long UpdateId
Definition: UpdateFwd.hpp:56
unsigned long AccessPointId
Definition: AuthFwd.hpp:128
Auth::IDoorPtr find_door_by_id(const Auth::DoorId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:114
std::shared_ptr< IZone > IZonePtr
Definition: AuthFwd.hpp:116
This is the header file for a generated source file, GitSHA1.cpp.
Auth::UserGroupMembershipPtr find_membership_by_id(const Auth::UserGroupMembershipId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:82
unsigned long UserGroupMembershipId
Definition: AuthFwd.hpp:82
const DBPtr database_
Definition: DBService.hpp:106
unsigned long AuditEntryId
Definition: AuditFwd.hpp:31
DBPtr db() const
Simply returns the underlying database pointer.
Definition: DBService.cpp:46
std::shared_ptr< IAuditEntry > IAuditEntryPtr
Definition: AuditFwd.hpp:40
void persist(Audit::IAuditEntry &)
Persist an audit entry object.
Definition: DBService.cpp:190
std::shared_ptr< IDoor > IDoorPtr
Definition: AuthFwd.hpp:104
std::shared_ptr< IAccessPoint > IAccessPointPtr
Definition: AuthFwd.hpp:127
unsigned long GroupId
Definition: AuthFwd.hpp:41
update::IUpdatePtr find_update_by_id(const update::UpdateId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:162
unsigned long UserId
Definition: AuthFwd.hpp:34
Auth::IAccessPointPtr find_access_point_by_id(const Auth::AccessPointId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:151
unsigned long DoorId
Definition: AuthFwd.hpp:107
std::shared_ptr< ICredential > ICredentialPtr
std::shared_ptr< IUpdate > IUpdatePtr
Definition: UpdateFwd.hpp:42
Auth::IZonePtr find_zone_by_id(const Auth::ZoneId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:125
std::shared_ptr< Group > GroupPtr
Definition: AuthFwd.hpp:37
Audit::IAuditEntryPtr find_audit_by_id(const Audit::AuditEntryId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:137
Base interface to Audit object.
Definition: IAuditEntry.hpp:47
Tools::ISchedulePtr find_schedule_by_id(const Tools::ScheduleId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:103
DBService(DBPtr db)
Definition: DBService.cpp:40
std::shared_ptr< User > UserPtr
Definition: AuthFwd.hpp:31
Auth::GroupPtr find_group_by_id(const Auth::GroupId &id, Flag f=Flag::DEFAULT)
Retrieve a group by its id.
Definition: DBService.cpp:61
std::shared_ptr< UserGroupMembership > UserGroupMembershipPtr
Definition: AuthFwd.hpp:81
Provides various database-related services to consumer.
Definition: DBService.hpp:34
void update(Audit::IAuditEntry &)
Update the object.
Definition: DBService.cpp:195
unsigned long ScheduleId
Definition: ToolsFwd.hpp:33
Auth::UserPtr find_user_by_id(const Auth::UserId &id, Flag f=Flag::DEFAULT)
Find a user by its id.
Definition: DBService.cpp:71
std::shared_ptr< ISchedule > ISchedulePtr
Definition: ToolsFwd.hpp:37
unsigned long ZoneId
Definition: AuthFwd.hpp:119
Cred::ICredentialPtr find_credential_by_id(const Cred::CredentialId &id, Flag f=Flag::DEFAULT)
Definition: DBService.cpp:92
unsigned long CredentialId
std::shared_ptr< odb::database > DBPtr
Definition: db_fwd.hpp:31
size_t operation_count() const
Return the number of operation against the database.
Definition: DBService.cpp:51