w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Rw11UnitVirt.ipp
Go to the documentation of this file.
1// $Id: Rw11UnitVirt.ipp 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-17 1085 1.4.1 use std::lock_guard instead of boost
8// 2018-12-09 1080 1.4 add HasVirt(); return ref for Virt()
9// 2018-12-01 1076 1.3 use unique_ptr instead of scoped_ptr
10// 2017-04-15 875 1.2.2 add VirtBase()
11// 2017-04-07 868 1.2.1 Dump(): add detail arg
12// 2015-05-13 680 1.2 Attach(): check for Enabled()
13// 2014-11-02 600 1.1.1 add (bool) cast, needed in 4.8.2
14// 2013-05-03 515 1.1 use AttachDone(),DetachCleanup(),DetachDone()
15// 2013-03-03 494 1.0 Initial version
16// 2013-02-05 483 0.1 First draft
17// ---------------------------------------------------------------------------
18
23#include "librtools/RosFill.hpp"
24
25#include "Rw11UnitVirt.hpp"
26
32// all method definitions in namespace Retro
33namespace Retro {
35//------------------------------------------+-----------------------------------
38template <class TV>
40 : Rw11Unit(pcntl, index),
41 fupVirt()
42{}
43
44//------------------------------------------+-----------------------------------
46
47template <class TV>
49{}
50
51//------------------------------------------+-----------------------------------
53
54template <class TV>
55inline bool Rw11UnitVirt<TV>::HasVirt() const
56{
57 return bool(fupVirt);
58}
59
60//------------------------------------------+-----------------------------------
62
63template <class TV>
65{
66 return *fupVirt;
67}
68
69//------------------------------------------+-----------------------------------
71
72template <class TV>
73inline const TV& Rw11UnitVirt<TV>::Virt() const
74{
75 return *fupVirt;
76}
77
78//------------------------------------------+-----------------------------------
80
81template <class TV>
83{
84 return fupVirt.get();
85}
86
87//------------------------------------------+-----------------------------------
89
90template <class TV>
91inline bool Rw11UnitVirt<TV>::Attach(const std::string& url, RerrMsg& emsg)
92{
93 // synchronize with server thread
94 std::lock_guard<RlinkConnect> lock(Connect());
95 if (fupVirt) Detach();
96 if (!Enabled()) {
97 emsg.Init("Rw11UnitVirt::Attach","unit not enabled");
98 return false;
99 }
100 fupVirt = std::move(TV::New(url, this, emsg));
101 if (fupVirt) AttachDone();
102 return bool(fupVirt);
103}
104
105//------------------------------------------+-----------------------------------
107
108template <class TV>
110{
111 // synchronize with server thread
112 std::lock_guard<RlinkConnect> lock(Connect());
113 if (!fupVirt) return;
114 DetachCleanup();
115 fupVirt.reset();
116 DetachDone();
117 return;
118}
119
120//------------------------------------------+-----------------------------------
122
123template <class TV>
124void Rw11UnitVirt<TV>::Dump(std::ostream& os, int ind, const char* text,
125 int detail) const
126{
127 RosFill bl(ind);
128 os << bl << (text?text:"--") << "Rw11UnitVirt @ " << this << std::endl;
129 if (fupVirt) {
130 fupVirt->Dump(os, ind+2, "*fupVirt: ", detail);
131 } else {
132 os << bl << " fupVirt: " << fupVirt.get() << std::endl;
133 }
134
135 Rw11Unit::Dump(os, ind, " ^", detail);
136 return;
137}
138
139} // 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
FIXME_docs.
Definition: Rw11Cntl.hpp:42
TV & Virt()
FIXME_docs.
Rw11UnitVirt(Rw11Cntl *pcntl, size_t index)
Default constructor.
virtual void Detach()
FIXME_docs.
~Rw11UnitVirt()
Destructor.
virtual Rw11Virt * VirtBase() const
FIXME_docs.
virtual bool Attach(const std::string &url, RerrMsg &emsg)
FIXME_docs.
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
bool HasVirt() const
FIXME_docs.
FIXME_docs.
Definition: Rw11Unit.hpp:39
virtual void Dump(std::ostream &os, int ind=0, const char *text=0, int detail=0) const
FIXME_docs.
Definition: Rw11Unit.cpp:99
FIXME_docs.
Definition: Rw11Virt.hpp:34
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47