Leosac  0.8.0
Open Source Access Control
FExternalServer.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 <string>
23 #include <zmqpp/zmqpp.hpp>
24 
25 namespace Leosac
26 {
27 namespace Hardware
28 {
29 
39 {
40  public:
46  FExternalServer(zmqpp::context &ctx, const std::string &server_name);
47 
48  FExternalServer(const FExternalServer &) = delete;
49 
50  FExternalServer &operator=(const FExternalServer &) = delete;
51 
52  ~FExternalServer() = default;
53 
57  bool connect();
58 
62  bool disconnect();
63 
67  bool isConnected() const;
68 
72  const std::string &name() const;
73 
74  private:
75 
80  bool send_to_backend(zmqpp::message &m);
81 
85  zmqpp::socket backend_;
86 
87  std::string name_;
88 };
89 }
90 }
Leosac::Hardware::FExternalServer::operator=
FExternalServer & operator=(const FExternalServer &)=delete
Leosac::Hardware::FExternalServer::backend_
zmqpp::socket backend_
A socket to talk to the backend server.
Definition: FExternalServer.hpp:85
Leosac::Hardware::FExternalServer::connect
bool connect()
Connect to the server.
Definition: FExternalServer.cpp:31
Leosac::Hardware::FExternalServer
Facade object for a Wiegand Reader device.
Definition: FExternalServer.hpp:38
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::Hardware::FExternalServer::disconnect
bool disconnect()
Disconnect from the server.
Definition: FExternalServer.cpp:39
Leosac::Hardware::FExternalServer::~FExternalServer
~FExternalServer()=default
Leosac::Hardware::FExternalServer::name_
std::string name_
Definition: FExternalServer.hpp:87
Leosac::Hardware::FExternalServer::FExternalServer
FExternalServer(zmqpp::context &ctx, const std::string &server_name)
Construct a facade to an external server; this facade will connect to the server.
Definition: FExternalServer.cpp:24
Leosac::Hardware::FExternalServer::isConnected
bool isConnected() const
Check if is connected to the server.
Leosac::Hardware::FExternalServer::name
const std::string & name() const
Returns the device's name.
Definition: FExternalServer.cpp:59
Leosac::Hardware::FExternalServer::send_to_backend
bool send_to_backend(zmqpp::message &m)
Send a message to the backend_ server and wait for a response.
Definition: FExternalServer.cpp:47