Leosac  0.8.0
Open Source Access Control
Device.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2017 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 "hardware/HardwareFwd.hpp"
23 #include "tools/Uuid.hpp"
24 #include <cstdint>
25 #include <odb/callback.hxx>
26 #include <odb/core.hxx>
27 #include <string>
28 
29 namespace Leosac
30 {
31 namespace Hardware
32 {
33 
42 #pragma db object callback(validation_callback) \
43  optimistic polymorphic table("HARDWARE_Device")
44 class Device
45 {
46  public:
47  Device();
49 
50  virtual ~Device() = default;
51 
52  virtual void validation_callback(odb::callback_event e, odb::database &) const;
53 
54  UUID id() const;
55 
56  const std::string &name() const;
57 
58  void name(const std::string &name);
59 
60  DeviceClass device_class() const;
61 
62  void device_class(DeviceClass d);
63 
64  bool enabled() const;
65  void enabled(bool e);
66 
67  uint64_t odb_version() const;
68 
69  private:
70 #pragma db id
72 
80 #pragma db unique
81  std::string name_;
82 
84 
91  bool enabled_;
92 
93 #pragma db version
94  uint64_t version_;
95 
96  friend odb::access;
97 };
98 }
99 }
Uuid.hpp
Leosac::Hardware::DeviceClass
DeviceClass
An enumeration describing the class of the device.
Definition: HardwareFwd.hpp:42
Leosac::Hardware::Device::name_
std::string name_
Name of an hardware device must be unique due to an implementation details.
Definition: Device.hpp:81
Leosac::Hardware::Device::id_
DeviceId id_
Definition: Device.hpp:71
Leosac::Hardware::Device::version_
uint64_t version_
Definition: Device.hpp:94
Leosac::Hardware::Device::validation_callback
virtual void validation_callback(odb::callback_event e, odb::database &) const
Definition: Device.cpp:85
Leosac::Hardware::Device
Base class for hardware devices.
Definition: Device.hpp:44
Leosac::Hardware::Device::~Device
virtual ~Device()=default
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Hardware::Device::id
UUID id() const
Definition: Device.cpp:49
Leosac::Hardware::Device::enabled_
bool enabled_
Is this device supposed to be enabled?
Definition: Device.hpp:91
Leosac::Hardware::Device::device_class
DeviceClass device_class() const
Definition: Device.cpp:65
Leosac::Hardware::Device::Device
Device()
Definition: Device.cpp:31
Leosac::Hardware::Device::name
const std::string & name() const
Definition: Device.cpp:55
HardwareFwd.hpp
Leosac::Hardware::Device::enabled
bool enabled() const
Definition: Device.cpp:75
Leosac::Hardware::Device::odb_version
uint64_t odb_version() const
Definition: Device.cpp:44
Leosac::Hardware::Device::device_class_
DeviceClass device_class_
Definition: Device.hpp:83
Leosac::UUID
Thin wrapper around boost::uuids::uuid.
Definition: Uuid.hpp:35