Leosac  0.8.0
Open Source Access Control
Zone.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 
22 #include "LeosacFwd.hpp"
23 #include "core/auth/IZone.hpp"
24 #include <odb/callback.hxx>
25 
26 namespace Leosac
27 {
28 namespace Auth
29 {
30 
32 {
33  public:
43  static void validate(const Zone &z, std::set<ZoneId> &zone_ids);
44 
51  static void validate_type(IZone::Type value);
52 };
53 
59 #pragma db object callback(validation_callback) optimistic
60 class Zone : public virtual IZone
61 {
62  public:
63  Zone();
64  virtual ZoneId id() const override;
65 
66  virtual std::string alias() const override;
67 
68  virtual std::string description() const override;
69 
70  virtual void alias(const std::string &alias) override;
71 
72  virtual void description(const std::string &desc) override;
73 
74  virtual Type type() const override;
75 
76  virtual void type(Type t) override;
77 
78  virtual std::vector<ZoneLPtr> children() const override;
79 
80  virtual std::vector<DoorLPtr> doors() const override;
81 
82  virtual void clear_children() override;
83 
84  virtual void clear_doors() override;
85 
86  virtual void add_door(DoorLPtr door) override;
87 
88  virtual void add_child(ZoneLPtr zone) override;
89 
97  void validation_callback(odb::callback_event e, odb::database &) const;
98 
99  protected:
100 #pragma db id auto
102 
103  std::string alias_;
104  std::string description_;
106 
107 #pragma db value_not_null
108  std::vector<ZoneLPtr> children_;
109 
110 #pragma db value_not_null
111  std::vector<DoorLPtr> doors_;
112 
113 #pragma db value_not_null inverse(children_)
114  std::vector<ZoneLWPtr> parents_;
115 
116 #pragma db version
117  const size_t version_;
118 
119  private:
120  friend class odb::access;
121  friend class Leosac::TestAccess;
122  friend class ZoneValidator;
123 };
124 }
125 }
126 
127 #ifdef ODB_COMPILER
128 #include "core/auth/Door.hpp"
129 #endif
Leosac::Auth::Zone::id_
ZoneId id_
Definition: Zone.hpp:101
Leosac::Auth::Zone::type
virtual Type type() const override
Definition: Zone.cpp:60
Leosac::Auth::Zone::add_door
virtual void add_door(DoorLPtr door) override
Definition: Zone.cpp:90
Leosac::Auth::Zone::children
virtual std::vector< ZoneLPtr > children() const override
Retrieve the children zones.
Definition: Zone.cpp:70
Leosac::Auth::ZoneId
unsigned long ZoneId
Definition: AuthFwd.hpp:119
Leosac::Auth::Zone::alias
virtual std::string alias() const override
Definition: Zone.cpp:40
IZone.hpp
Leosac::Auth::IZone
The interface for zones.
Definition: IZone.hpp:47
LeosacFwd.hpp
Leosac::Auth::Zone::clear_doors
virtual void clear_doors() override
Definition: Zone.cpp:85
Leosac::Auth::Zone::doors
virtual std::vector< DoorLPtr > doors() const override
Retrieve the doors associated with the zones.
Definition: Zone.cpp:75
Leosac::Auth::Zone::alias_
std::string alias_
Definition: Zone.hpp:103
Leosac::Auth::Zone::version_
const size_t version_
Definition: Zone.hpp:117
Leosac::Auth::Zone::children_
std::vector< ZoneLPtr > children_
Definition: Zone.hpp:108
Leosac::Auth::Zone::description_
std::string description_
Definition: Zone.hpp:104
Leosac::Auth::Zone::parents_
std::vector< ZoneLWPtr > parents_
Definition: Zone.hpp:114
Leosac::Auth::Zone::description
virtual std::string description() const override
Definition: Zone.cpp:45
Leosac::Auth::Zone::Zone
Zone()
Definition: Zone.cpp:28
Door.hpp
Leosac::Auth::Zone
A Zone is a container for doors and other zone.
Definition: Zone.hpp:60
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Auth::ZoneValidator::validate_type
static void validate_type(IZone::Type value)
Validate that the integer value of the type is a correct type for a zone.
Definition: Zone.cpp:162
Leosac::Auth::Zone::clear_children
virtual void clear_children() override
Definition: Zone.cpp:80
Leosac::Auth::Zone::type_
Type type_
Definition: Zone.hpp:105
Leosac::Auth::Zone::id
virtual ZoneId id() const override
Definition: Zone.cpp:35
Leosac::Auth::Zone::add_child
virtual void add_child(ZoneLPtr zone) override
Definition: Zone.cpp:95
Leosac::Auth::Zone::validation_callback
void validation_callback(odb::callback_event e, odb::database &) const
Callback function called by ODB before/after database operation against a Zone object.
Definition: Zone.cpp:100
Leosac::Auth::ZoneValidator
Definition: Zone.hpp:31
Leosac::Auth::Zone::access
friend class odb::access
Definition: Zone.hpp:120
Leosac::TestAccess
This is class that can be used to access some object's internal.
Definition: LeosacFwd.hpp:59
Leosac::Auth::ZoneLPtr
odb::lazy_shared_ptr< Zone > ZoneLPtr
Definition: AuthFwd.hpp:123
Leosac::Auth::IZone::Type
Type
Zone's type.
Definition: IZone.hpp:53
Leosac::Auth::ZoneValidator::validate
static void validate(const Zone &z, std::set< ZoneId > &zone_ids)
Perform validation of the zone.
Definition: Zone.cpp:121
Leosac::Auth::DoorLPtr
odb::lazy_shared_ptr< Door > DoorLPtr
Definition: AuthFwd.hpp:111
Leosac::Auth::Zone::doors_
std::vector< DoorLPtr > doors_
Definition: Zone.hpp:111