PdCom  5.0
Process data communication client
Process.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vim:tw=78
3  *
4  * Copyright (C) 2021 Richard Hacker (lerichi at gmx dot net),
5  * Florian Pose (fp at igh dot de),
6  * Bjarne von Horn (vh at igh dot de).
7  *
8  * This file is part of the PdCom library.
9  *
10  * The PdCom library is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or (at your
13  * option) any later version.
14  *
15  * The PdCom library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
22  *
23  *****************************************************************************/
24 
27 #ifndef PDCOM5_PROCESS_H
28 #define PDCOM5_PROCESS_H
29 
30 #include "ClientStatistics.h"
31 #include "pdcom5_export.h"
32 
33 #include <chrono>
34 #include <memory>
35 #include <stddef.h>
36 #include <stdint.h>
37 #include <string>
38 #include <vector>
39 
40 namespace PdCom {
41 namespace impl {
42 class Process;
43 }
44 
45 class SecureProcess;
46 class Variable;
47 class Sasl;
48 class MessageManagerBase;
49 
83 class PDCOM5_PUBLIC Process
84 {
85  friend class impl::Process;
86  friend class SecureProcess;
87 
88  public:
90  Process();
91  Process(Process &&) = delete;
92  Process(Process const &) = delete;
93  Process &operator=(Process &&) = delete;
94  Process &operator=(Process const &) = delete;
95 
96  protected:
101  virtual ~Process();
102 
103  public:
105  std::string name() const;
106 
108  std::string version() const;
109 
121  void asyncData();
122 
130  void callPendingCallbacks();
131 
137  void
138  broadcast(const std::string &message, const std::string &attr = "text");
139 
140  protected:
142  void reset();
143 
151  virtual std::string applicationName() const { return "pdcom5"; }
152 
163  virtual std::string hostname() const { return {}; }
164 
190  virtual int read(char *buf, int count) = 0;
191 
220  virtual void write(const char *buf, size_t count) = 0;
221 
241  virtual void flush() = 0;
242 
256  virtual void connected() = 0;
257 
288  bool list(const std::string &path = "");
289 
303  virtual void
304  listReply(std::vector<Variable> variables, std::vector<std::string> dirs);
305 
322  bool find(const std::string &path);
323 
333  virtual void findReply(const Variable &variable);
334 
339  void getClientStatistics();
340 
343  virtual void
344  clientStatisticsReply(std::vector<ClientStatistics> statistics);
345 
347  void ping();
348 
354  virtual void pingReply() {}
355 
364  virtual bool alive() { return true; }
365 
372  void setAuthManager(Sasl *);
373 
380  void setMessageManager(MessageManagerBase *);
381 
393  virtual void broadcastReply(
394  const std::string &message,
395  const std::string &attr,
396  std::chrono::nanoseconds time_ns,
397  const std::string &user);
398 
399  private:
400  std::shared_ptr<impl::Process> pimpl;
401 };
402 } // namespace PdCom
403 
404 #endif // PDCOM5_PROCESS_H
virtual std::string hostname() const
Host name of remote server.
Definition: Process.h:163
virtual std::string applicationName() const
Name of application user application.
Definition: Process.h:151
virtual bool alive()
Test from process whether client is alive.
Definition: Process.h:364
virtual void pingReply()
Ping reply.
Definition: Process.h:354
PdCom Variable interface.
Definition: Variable.h:66
Definition: SecureProcess.h:40
Base class for PdCom protocol handler.
Definition: Process.h:83
Definition: MessageManagerBase.h:67
SASL Interface for PdCom.
Definition: Sasl.h:41
library version string as "major.minor.patch"
Definition: ClientStatistics.h:31