w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlinkPort.hpp
Go to the documentation of this file.
1// $Id: RlinkPort.hpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2011-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2019-06-07 1160 1.4.5 Stats() not longer const
8// 2018-12-16 1084 1.4.4 use =delete for noncopyable instead of boost
9// 2018-12-07 1078 1.4.3 use std::shared_ptr instead of boost
10// 2018-12-01 1076 1.4 2 use unique_ptr
11// 2017-04-07 868 1.4.1 Dump(): add detail arg
12// 2017-02-19 853 1.4 use Rtime, drop TimeOfDayAsDouble
13// 2015-04-11 666 1.3 add fXon, XonEnable()
14// 2014-12-10 611 1.2.2 add time stamps for Read/Write for logs
15// 2013-05-01 513 1.2.1 fTraceLevel now uint32_t
16// 2013-02-23 492 1.2 use RparseUrl
17// 2013-02-22 491 1.1 use new RlogFile/RlogMsg interfaces
18// 2013-01-27 477 1.0.3 add RawRead(),RawWrite() methods
19// 2012-12-26 465 1.0.2 add CloseFd() method
20// 2011-04-24 380 1.0.1 use boost::noncopyable (instead of private dcl's)
21// 2011-03-27 375 1.0 Initial version
22// 2011-01-15 356 0.1 First draft
23// ---------------------------------------------------------------------------
24
25
30#ifndef included_Retro_RlinkPort
31#define included_Retro_RlinkPort 1
32
33#include <string>
34#include <map>
35#include <memory>
36
37#include "librtools/RerrMsg.hpp"
39#include "librtools/Rstats.hpp"
41#include "librtools/Rtime.hpp"
42
43namespace Retro {
44
45 class RlinkPort {
46 public:
47 typedef std::unique_ptr<RlinkPort> port_uptr_t;
48
49 RlinkPort();
50 virtual ~RlinkPort();
51
52 RlinkPort(const RlinkPort&) = delete; // noncopyable
53 RlinkPort& operator=(const RlinkPort&) = delete; // noncopyable
54
55 virtual bool Open(const std::string& url, RerrMsg& emsg) = 0;
56 virtual void Close();
57
58 virtual int Read(uint8_t* buf, size_t size, const Rtime& timeout,
59 RerrMsg& emsg);
60 virtual int Write(const uint8_t* buf, size_t size, RerrMsg& emsg);
61 virtual bool PollRead(const Rtime& timeout);
62
63 int RawRead(uint8_t* buf, size_t size, bool exactsize,
64 const Rtime& timeout, Rtime& tused, RerrMsg& emsg);
65 int RawWrite(const uint8_t* buf, size_t size, RerrMsg& emsg);
66
67 bool IsOpen() const;
68
69 const RparseUrl& Url() const;
70 bool XonEnable() const;
71
72 int FdRead() const;
73 int FdWrite() const;
74
75 void SetLogFile(const std::shared_ptr<RlogFile>& splog);
76 void SetTraceLevel(uint32_t level);
77
78 uint32_t TraceLevel() const;
79
80 Rstats& Stats();
81
82 virtual void Dump(std::ostream& os, int ind=0, const char* text=0,
83 int detail=0) const;
84
85 // some constants (also defined in cpp)
86 static const int kEof = 0;
87 static const int kTout = -1;
88 static const int kErr = -2;
89
90 // statistics counter indices
91 enum stats {
99 };
100
101 protected:
102 void CloseFd(int& fd);
103
104 protected:
105 bool fIsOpen;
107 bool fXon;
110 std::shared_ptr<RlogFile> fspLog;
111 uint32_t fTraceLevel;
115 };
116
117} // end namespace Retro
118
119#include "RlinkPort.ipp"
120
121#endif
FIXME_docs.
Definition: RerrMsg.hpp:25
FIXME_docs.
Definition: RlinkPort.hpp:45
int RawRead(uint8_t *buf, size_t size, bool exactsize, const Rtime &timeout, Rtime &tused, RerrMsg &emsg)
FIXME_docs.
Definition: RlinkPort.cpp:249
int RawWrite(const uint8_t *buf, size_t size, RerrMsg &emsg)
FIXME_docs.
Definition: RlinkPort.cpp:279
virtual bool PollRead(const Rtime &timeout)
FIXME_docs.
Definition: RlinkPort.cpp:218
Rtime fTsLastWrite
time stamp last write
Definition: RlinkPort.hpp:113
static const int kEof
return code: end-of-file
Definition: RlinkPort.hpp:86
void CloseFd(int &fd)
FIXME_docs.
Definition: RlinkPort.cpp:310
int FdWrite() const
FIXME_docs.
Definition: RlinkPort.ipp:59
int fFdWrite
fd for write
Definition: RlinkPort.hpp:109
void SetTraceLevel(uint32_t level)
FIXME_docs.
Definition: RlinkPort.ipp:76
bool IsOpen() const
FIXME_docs.
Definition: RlinkPort.ipp:27
const RparseUrl & Url() const
FIXME_docs.
Definition: RlinkPort.ipp:35
RparseUrl fUrl
parsed url
Definition: RlinkPort.hpp:106
Rstats & Stats()
FIXME_docs.
Definition: RlinkPort.ipp:93
virtual ~RlinkPort()
Destructor.
Definition: RlinkPort.cpp:90
int fFdRead
fd for read
Definition: RlinkPort.hpp:108
bool fIsOpen
is open flag
Definition: RlinkPort.hpp:105
static const int kErr
return code: IO error
Definition: RlinkPort.hpp:88
RlinkPort()
Default constructor.
Definition: RlinkPort.cpp:67
std::shared_ptr< RlogFile > fspLog
log file ptr
Definition: RlinkPort.hpp:110
bool fXon
xon attribute set
Definition: RlinkPort.hpp:107
static const int kTout
return code: time out
Definition: RlinkPort.hpp:87
virtual int Read(uint8_t *buf, size_t size, const Rtime &timeout, RerrMsg &emsg)
FIXME_docs.
Definition: RlinkPort.cpp:115
bool XonEnable() const
FIXME_docs.
Definition: RlinkPort.ipp:43
virtual void Close()
FIXME_docs.
Definition: RlinkPort.cpp:98
void SetLogFile(const std::shared_ptr< RlogFile > &splog)
FIXME_docs.
Definition: RlinkPort.ipp:67
RlinkPort(const RlinkPort &)=delete
uint32_t TraceLevel() const
FIXME_docs.
Definition: RlinkPort.ipp:85
virtual int Write(const uint8_t *buf, size_t size, RerrMsg &emsg)
FIXME_docs.
Definition: RlinkPort.cpp:166
std::unique_ptr< RlinkPort > port_uptr_t
Definition: RlinkPort.hpp:47
Rtime fTsLastRead
time stamp last write
Definition: RlinkPort.hpp:112
Rstats fStats
statistics
Definition: RlinkPort.hpp:114
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: RlinkPort.cpp:288
uint32_t fTraceLevel
trace level
Definition: RlinkPort.hpp:111
int FdRead() const
FIXME_docs.
Definition: RlinkPort.ipp:51
RlinkPort & operator=(const RlinkPort &)=delete
virtual bool Open(const std::string &url, RerrMsg &emsg)=0
FIXME_docs.
Definition: RparseUrl.hpp:27
FIXME_docs.
Definition: Rstats.hpp:28
FIXME_docs.
Definition: Rtime.hpp:25
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47