w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rw11VirtTerm.cpp
Go to the documentation of this file.
1// $Id: Rw11VirtTerm.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2018-12-02 1076 1.1 use unique_ptr for New()
8// 2017-04-07 868 1.0.1 Dump(): add detail arg
9// 2013-03-06 495 1.0 Initial version
10// 2013-02-13 488 0.1 First draft
11// ---------------------------------------------------------------------------
12
16#include <memory>
17
19#include "librtools/RosFill.hpp"
20#include "Rw11VirtTermPty.hpp"
21#include "Rw11VirtTermTcp.hpp"
22
23#include "Rw11VirtTerm.hpp"
24
25using namespace std;
26
32// all method definitions in namespace Retro
33namespace Retro {
34
35//------------------------------------------+-----------------------------------
37
39 : Rw11Virt(punit),
40 fChannelId(),
41 fRcvCb()
42{
43 fStats.Define(kStatNVTRcvPoll, "NVTRcvPoll", "VT RcvPollHandler() calls");
44 fStats.Define(kStatNVTSnd, "NVTSnd", "VT Snd() calls");
45 fStats.Define(kStatNVTRcvByt, "NVTRcvByt", "VT bytes received");
46 fStats.Define(kStatNVTSndByt, "NVTSndByt", "VT bytes send");
47}
48
49//------------------------------------------+-----------------------------------
51
53{}
54
55//------------------------------------------+-----------------------------------
57
58std::unique_ptr<Rw11VirtTerm> Rw11VirtTerm::New(const std::string& url,
59 Rw11Unit* punit,
60 RerrMsg& emsg)
61{
62 string scheme = RparseUrl::FindScheme(url, "tcp");
63 unique_ptr<Rw11VirtTerm> up;
64
65 if (scheme == "pty") { // scheme -> pty:
66 up.reset(new Rw11VirtTermPty(punit));
67 if (!up->Open(url, emsg)) up.reset();
68
69 } else if (scheme == "tcp") { // scheme -> tcp:
70 up.reset(new Rw11VirtTermTcp(punit));
71 if (!up->Open(url, emsg)) up.reset();
72
73 } else { // scheme -> no match
74 emsg.Init("Rw11VirtTerm::New", string("Scheme '") + scheme +
75 "' is not supported");
76
77 }
78 return up;
79}
80
81//------------------------------------------+-----------------------------------
83
84void Rw11VirtTerm::Dump(std::ostream& os, int ind, const char* text,
85 int detail) const
86{
87 RosFill bl(ind);
88 os << bl << (text?text:"--") << "Rw11VirtTerm @ " << this << endl;
89
90 os << bl << " fChannelId: " << fChannelId << endl;
91 Rw11Virt::Dump(os, ind, " ^", detail);
92 return;
93}
94
95} // end namespace Retro
FIXME_docs.
Definition: RerrMsg.hpp:25
void Init(const std::string &meth, const std::string &text)
FIXME_docs.
Definition: RerrMsg.cpp:74
I/O appicator to generate fill characters.
Definition: RosFill.hpp:24
static std::string FindScheme(const std::string &url, const std::string &def="")
FIXME_docs.
Definition: RparseUrl.cpp:238
void Define(size_t ind, const std::string &name, const std::string &text)
FIXME_docs.
Definition: Rstats.cpp:72
FIXME_docs.
Definition: Rw11Unit.hpp:39
static std::unique_ptr< Rw11VirtTerm > New(const std::string &url, Rw11Unit *punit, RerrMsg &emsg)
FIXME_docs.
std::string fChannelId
channel id
~Rw11VirtTerm()
Destructor.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Rw11VirtTerm(Rw11Unit *punit)
Default constructor.
FIXME_docs.
Definition: Rw11Virt.hpp:34
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rw11Virt.cpp:60
Rstats fStats
statistics
Definition: Rw11Virt.hpp:68
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47