PdCom  4.0
Process data communication client
Process.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vim:tw=78
3  * $Id: Process.h,v 4d3cefee74da 2016/11/24 13:56:58 lerichi $
4  *
5  * Copyright (C) 2016 Richard Hacker (lerichi at gmx dot net)
6  *
7  * This file is part of the PdCom library.
8  *
9  * The PdCom library is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or (at your
12  * option) any later version.
13  *
14  * The PdCom library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
17  * License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
21  *
22  *****************************************************************************/
23 
26 #ifndef PDCOM_PROCESS_H
27 #define PDCOM_PROCESS_H
28 
29 #include <stddef.h>
30 #include <string>
31 #include <list>
32 #include <stdint.h>
33 
34 class IOLayer;
35 class ProtocolHandler;
36 
37 namespace PdCom {
38 
39  class Subscriber;
40  class Variable;
41 
87  class Process {
88  public:
90  Process();
91 
96  virtual ~Process();
97 
99  std::string name() const;
100 
102  std::string version() const;
103 
105  void reset();
106 
114  virtual std::string applicationName() const;
115 
120  virtual std::string hostname() const;
121 
148  virtual int read( char *buf, size_t count) = 0;
149 
178  virtual void write(const char *buf, size_t count) = 0;
179 
199  virtual void flush() = 0;
200 
215  int asyncData();
216 
230  virtual void connected() = 0;
231 
262  bool list(const std::string& path);
263 
277  virtual void listReply(
278  std::list<const Variable*>& variables,
279  std::list<std::string>& directories);
280 
297  bool find(const std::string& path);
298 
308  virtual void findReply(const Variable* variable);
309 
324  bool login(const char* mech, const char* clientData);
325 
328  void logout();
329 
345  virtual void loginReply(const char* mechlist,
346  const char* serverData, int finished);
347 
369  bool startTLS();
370 
378  virtual void startTLSReply();
379 
381  void ping();
382 
388  virtual void pingReply();
389 
398  virtual bool alive();
399 
439  void subscribe(Subscriber* subscriber,
440  const std::string& path, double interval, int id);
441 
444  void unsubscribe(Subscriber* subscriber);
445 
461  void parameterMonitor(Subscriber* subscriber, bool state);
462 
468  enum LogLevel_t {
469  Emergency,
470  Alert,
471  Critical,
472  Error,
473  Warn,
474  Info,
475  Debug,
476  Trace
477  };
478 
490  virtual void processMessage(
491  LogLevel_t level,
492  const std::string& path,
493  int index,
494  bool state,
495  uint64_t time_ns
496  );
497 
506  void messageHistory(unsigned int limit = 0);
507 
519  virtual void protocolLog(
520  LogLevel_t severity,
521  const std::string& message
522  );
523 
524  private:
525  ProtocolHandler *protocolHandler;
526  IOLayer* const io;
527 
528  std::string initialBuffer;
529  };
530 } // namespace
531 
532 #endif // PDCOM_PROCESS_H
virtual std::string hostname() const
Host name of remote server; used for TLS when multi-hosting.
int asyncData()
Library entry point for new data.
virtual std::string applicationName() const
Name of application user application.
virtual void listReply(std::list< const Variable *> &variables, std::list< std::string > &directories)
Reply to list() call.
virtual void startTLSReply()
TLS reply.
virtual bool alive()
Test from process whether client is alive.
void parameterMonitor(Subscriber *subscriber, bool state)
Turn parameter monitoring on/off.
bool startTLS()
Start TLS.
void subscribe(Subscriber *subscriber, const std::string &path, double interval, int id)
Subscribe to a variable.
bool find(const std::string &path)
Find a variable with a corresponding path.
std::string version() const
Remote process version string.
virtual void pingReply()
Ping reply.
Process()
Constructor.
void messageHistory(unsigned int limit=0)
Request history of messages from the process.
virtual void flush()=0
Flush unsent data in output buffer.
Class required to receive subscribed variables.
Definition: Subscriber.h:91
void logout()
Logout from server.
virtual void connected()=0
Protocol initialization completed.
LogLevel_t
Log levels.
Definition: Process.h:468
Process variable.
Definition: Variable.h:43
void ping()
Ping server.
virtual int read(char *buf, size_t count)=0
Read data from server.
Base class for PdCom protocol handler.
Definition: Process.h:87
virtual ~Process()
Destructor.
virtual void write(const char *buf, size_t count)=0
Write data to server.
virtual void findReply(const Variable *variable)
Reply to find()
virtual void protocolLog(LogLevel_t severity, const std::string &message)
Message event from protocol handler.
bool list(const std::string &path)
List a directory path.
void reset()
Reset communications and clean up internal buffers.
void unsubscribe(Subscriber *subscriber)
Unsubscribe all subscriptions from subscriber.
virtual void loginReply(const char *mechlist, const char *serverData, int finished)
SASL server reply to login()
Definition: Process.h:37
bool login(const char *mech, const char *clientData)
Perform SASL login step.
std::string name() const
Remote process name string.
virtual void processMessage(LogLevel_t level, const std::string &path, int index, bool state, uint64_t time_ns)
Message event from process.