w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rw11VirtEth.cpp
Go to the documentation of this file.
1// $Id: Rw11VirtEth.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2014-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 Initial version
9// 2014-06-09 561 0.1 First draft
10// ---------------------------------------------------------------------------
11
15#include <memory>
16
18#include "librtools/RosFill.hpp"
19#include "Rw11VirtEthTap.hpp"
20
21#include "Rw11VirtEth.hpp"
22
23using namespace std;
24
30// all method definitions in namespace Retro
31namespace Retro {
32
33//------------------------------------------+-----------------------------------
35
37 : Rw11Virt(punit),
38 fChannelId(),
39 fRcvCb()
40{
41 fStats.Define(kStatNVTRcvPoll, "NVTRcvPoll", "VT RcvPollHandler() calls");
42 fStats.Define(kStatNVTSnd, "NVTSnd", "VT Snd() calls");
43 fStats.Define(kStatNVTRcvByt, "NVTRcvByt", "VT bytes received");
44 fStats.Define(kStatNVTSndByt, "NVTSndByt", "VT bytes send");
45}
46
47//------------------------------------------+-----------------------------------
49
51{}
52
53//------------------------------------------+-----------------------------------
55
56std::unique_ptr<Rw11VirtEth> Rw11VirtEth::New(const std::string& url,
57 Rw11Unit* punit,
58 RerrMsg& emsg)
59{
60 string scheme = RparseUrl::FindScheme(url, "tcp");
61 unique_ptr<Rw11VirtEth> up;
62
63 if (scheme == "tap") { // scheme -> tap:
64 up.reset(new Rw11VirtEthTap(punit));
65 if (!up->Open(url, emsg)) up.reset();
66
67 } else { // scheme -> no match
68 emsg.Init("Rw11VirtEth::New", string("Scheme '") + scheme +
69 "' is not supported");
70
71 }
72 return up;
73}
74
75//------------------------------------------+-----------------------------------
77
78void Rw11VirtEth::Dump(std::ostream& os, int ind, const char* text,
79 int detail) const
80{
81 RosFill bl(ind);
82 os << bl << (text?text:"--") << "Rw11VirtEth @ " << this << endl;
83
84 os << bl << " fChannelId: " << fChannelId << endl;
85 Rw11Virt::Dump(os, ind, " ^", detail);
86 return;
87}
88
89} // 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
~Rw11VirtEth()
Destructor.
Definition: Rw11VirtEth.cpp:50
std::string fChannelId
channel id
Definition: Rw11VirtEth.hpp:59
static std::unique_ptr< Rw11VirtEth > New(const std::string &url, Rw11Unit *punit, RerrMsg &emsg)
FIXME_docs.
Definition: Rw11VirtEth.cpp:56
Rw11VirtEth(Rw11Unit *punit)
Default constructor.
Definition: Rw11VirtEth.cpp:36
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rw11VirtEth.cpp:78
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