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 "Exception.h"
31 #include "visibility.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 
86 class PDCOM5_PUBLIC Process
87 {
88  friend class impl::Process;
89  friend class SecureProcess;
90 
91  public:
92  struct PDCOM5_PUBLIC protocol_error : Exception
93  {
94  using Exception::Exception;
95  };
96 
98  Process();
99  Process(Process &&) = delete;
100  Process &operator=(Process &&) = delete;
101 
106  virtual ~Process();
107 
109  std::string name() const;
110 
112  std::string version() const;
113 
115  void reset();
116 
124  virtual std::string applicationName() const { return "pdcom5"; }
125 
136  virtual std::string hostname() const { return {}; }
137 
138  private:
165  virtual size_t read(char *buf, size_t count) = 0;
166 
195  virtual void write(const char *buf, size_t count) = 0;
196 
216  virtual void flush() = 0;
217 
218  public:
230  void asyncData();
231 
239  void callPendingCallbacks();
240 
241  private:
255  virtual void connected() = 0;
256 
257  public:
288  bool list(const std::string &path = "");
289 
290  private:
304  virtual void
305  listReply(std::vector<Variable> variables, std::vector<std::string> dirs);
306 
307  public:
324  bool find(const std::string &path);
325 
335  virtual void findReply(const Variable &variable);
336 
337  public:
339  void ping();
340 
341  private:
347  virtual void pingReply() {}
348 
357  virtual bool alive() { return true; }
358 
372  virtual void transmitSemaphore(bool /* state */) {}
373 
374  public:
381  void setAuthManager(Sasl *);
382 
388  void
389  broadcast(const std::string &message, const std::string &attr = "text");
390 
391  private:
403  virtual void broadcastReply(
404  const std::string &message,
405  const std::string &attr,
406  std::chrono::nanoseconds time_ns,
407  const std::string &user);
408 
409  private:
410  std::unique_ptr<impl::Process> pimpl;
411 };
412 } // namespace PdCom
413 
414 #endif // PDCOM5_PROCESS_H
virtual std::string hostname() const
Host name of remote server.
Definition: Process.h:136
virtual std::string applicationName() const
Name of application user application.
Definition: Process.h:124
Definition: Exception.h:33
PdCom Variable interface.
Definition: Variable.h:56
Definition: Process.h:92
Base class for PdCom protocol handler.
Definition: Process.h:86
library version string as "major.minor.patch"
Definition: details.h:37