Leosac  0.8.0
Open Source Access Control
ExternalMessage.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2022 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/Device.hpp"
23 #include "hardware/HardwareFwd.hpp"
24 #include <odb/callback.hxx>
25 #include <odb/core.hxx>
26 #include <string>
27 
28 namespace Leosac
29 {
30 namespace Hardware
31 {
32 
40 #pragma db object callback(validation_callback) table("HARDWARE_ExternalMessage")
41 class ExternalMessage : public Device
42 {
43  public:
44  enum class Direction
45  {
46  Subscribe = 0,
47  Publish = 1
48  };
49 
51 
52  void validation_callback(odb::callback_event, odb::database &) const override;
53 
54  std::string subject() const;
55 
56  void subject(const std::string& subject);
57 
58  Direction direction() const;
59 
61 
62  DeviceClass virtualtype() const;
63 
65 
66  std::string payload() const;
67 
68  void payload(const std::string& payload);
69 
70  protected:
71  std::string subject_;
74  std::string payload_;
75 
76  private:
77  friend odb::access;
78 };
79 }
80 }
Leosac::Hardware::ExternalMessage::direction_
Direction direction_
Definition: ExternalMessage.hpp:72
Leosac::Hardware::DeviceClass
DeviceClass
An enumeration describing the class of the device.
Definition: HardwareFwd.hpp:42
Leosac::Hardware::ExternalMessage::payload
std::string payload() const
Definition: ExternalMessage.cpp:65
Leosac::Hardware::ExternalMessage::subject
std::string subject() const
Definition: ExternalMessage.cpp:35
Leosac::Hardware::ExternalMessage::Direction::Publish
@ Publish
Leosac::Hardware::ExternalMessage::ExternalMessage
ExternalMessage()
Definition: ExternalMessage.cpp:27
Leosac::Hardware::ExternalMessage::payload_
std::string payload_
Definition: ExternalMessage.hpp:74
Leosac::Hardware::Device
Base class for hardware devices.
Definition: Device.hpp:44
Leosac::Hardware::ExternalMessage::Direction::Subscribe
@ Subscribe
Leosac::Hardware::ExternalMessage::direction
Direction direction() const
Definition: ExternalMessage.cpp:45
Leosac::Hardware::ExternalMessage::validation_callback
void validation_callback(odb::callback_event, odb::database &) const override
Definition: ExternalMessage.cpp:75
Device.hpp
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
HardwareFwd.hpp
Leosac::Hardware::ExternalMessage
Abstraction of an External Messaging device.
Definition: ExternalMessage.hpp:41
Leosac::Hardware::ExternalMessage::virtualtype_
DeviceClass virtualtype_
Definition: ExternalMessage.hpp:73
Leosac::Hardware::ExternalMessage::virtualtype
DeviceClass virtualtype() const
Definition: ExternalMessage.cpp:55
Leosac::Hardware::ExternalMessage::Direction
Direction
Definition: ExternalMessage.hpp:44
Leosac::Hardware::ExternalMessage::subject_
std::string subject_
Definition: ExternalMessage.hpp:71