w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RtclRw11UnitBase.ipp
Go to the documentation of this file.
1// $Id: RtclRw11UnitBase.ipp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-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.3.7 use RtclStats::Exec()
8// 2019-02-23 1114 1.3.6 use std::bind instead of lambda
9// 2018-12-15 1082 1.3.5 use lambda instead of boost::bind
10// 2018-12-09 1080 1.3.4 use HasVirt(); Virt() returns ref
11// 2018-12-07 1078 1.3.3 use std::shared_ptr instead of boost
12// 2018-12-01 1076 1.3.2 use unique_ptr
13// 2017-04-15 875 1.3.1 add attached,attachutl getters
14// 2017-04-08 870 1.3 add TUV,TB; add TUV* ObjUV(); inherit from TB
15// 2017-04-02 863 1.2 add AttachDone()
16// 2015-05-14 680 1.1 fGets: add enabled (moved from RtclRw11UnitDisk)
17// 2013-03-06 495 1.0 Initial version
18// 2013-02-16 488 0.1 First draft
19// ---------------------------------------------------------------------------
20
25#include <functional>
26
29
35// all method definitions in namespace Retro
36namespace Retro {
38// Note on coding style:
39// all base class members must be qualified with "this->" to ensure proper
40// name lookup. Otherwise one gets errors like "no declarations were found
41// by argument-dependent lookup at the point of instantiation"
42//
43// Reason is the according to C++ standart in a first pass all names which
44// are not template parameter dependent are resolved. If a name is not found
45// one gets above mentioned error. All other names are looked up in a second
46// pass. Adding "this->" makes the name template parameter dependent.
47//
48// Prefixing a "TC::" can also be used, e.g. for constants like TB::kOK.
49
50//------------------------------------------+-----------------------------------
52
53template <class TU, class TUV, class TB>
54inline RtclRw11UnitBase<TU,TUV,TB>::RtclRw11UnitBase(const std::string& type,
55 const std::shared_ptr<TU>& spunit)
56 : TB(type),
57 fspObj(spunit)
58{
59 this->AddMeth("stats", std::bind(&RtclRw11UnitBase<TU,TUV,TB>::M_stats,
60 this, std::placeholders::_1));
61
62 TU* pobj = fspObj.get();
63
64 // the following construction is neccessary because the base class is a
65 // template argument. Access to "this->fGets" is done via a local variable
66 // 'gets' to a local variable. Otherwise processing of the template functions
67 // Add<...> will cause obscure "expected primary-expression before ‘>’ "
68 // error messages. Simply too much nested templating...
69
70 RtclGetList& gets = this->fGets;
71 gets.Add<size_t> ("index", std::bind(&TU::Index, pobj));
72 gets.Add<std::string> ("name", std::bind(&TU::Name, pobj));
73 gets.Add<bool> ("enabled", std::bind(&TU::Enabled, pobj));
74 gets.Add<bool> ("attached", std::bind(&TU::IsAttached, pobj));
75 gets.Add<const std::string&> ("attachurl",std::bind(&TU::AttachUrl,pobj));
76}
77
78//------------------------------------------+-----------------------------------
80
81template <class TU, class TUV, class TB>
83{}
84
85//------------------------------------------+-----------------------------------
87
88template <class TU, class TUV, class TB>
90{
91 return *fspObj;
92}
93
94//------------------------------------------+-----------------------------------
96
97template <class TU, class TUV, class TB>
99{
100 return *fspObj;
101}
102
103//------------------------------------------+-----------------------------------
105
106template <class TU, class TUV, class TB>
108{
109 return fspObj->Cpu();
110}
111
112//------------------------------------------+-----------------------------------
114
115template <class TU, class TUV, class TB>
116inline const std::shared_ptr<TU>& RtclRw11UnitBase<TU,TUV,TB>::ObjSPtr()
117{
118 return fspObj;
119}
120
121//------------------------------------------+-----------------------------------
123
124template <class TU, class TUV, class TB>
126{
127 if (!Obj().HasVirt()) return;
128 std::unique_ptr<RtclRw11Virt> pvirt(RtclRw11VirtFactory(&Obj().Virt()));
129 if (!pvirt) return;
130 this->fupVirt = move(pvirt);
131 this->AddMeth("virt", std::bind(&RtclRw11Unit::M_virt, this,
132 std::placeholders::_1));
133 return;
134}
135
136//------------------------------------------+-----------------------------------
138
139template <class TU, class TUV, class TB>
141{
143 if (!RtclStats::GetArgs(args, cntx)) return TB::kERR;
144 if (!RtclStats::Exec(args, cntx, Obj().Stats())) return TB::kERR;
145 if (Obj().HasVirt()) {
146 if (!RtclStats::Exec(args, cntx, Obj().Virt().Stats())) return TB::kERR;
147 }
148 return TB::kOK;
149}
150
151} // end namespace Retro
FIXME_docs.
Definition: RtclArgs.hpp:41
void Add(const std::string &name, get_uptr_t &&upget)
FIXME_docs.
Definition: RtclGetList.cpp:52
Implemenation (all inline) of RtclRw11UnitBase.
virtual void AttachDone()
FIXME_docs.
RtclRw11UnitBase(const std::string &type, const std::shared_ptr< TU > &spunit)
Constructor.
std::shared_ptr< TU > fspObj
sptr to managed object
virtual Rw11Cpu & Cpu() const
FIXME_docs.
virtual TUV & ObjUV()
FIXME_docs.
const std::shared_ptr< TU > & ObjSPtr()
FIXME_docs.
virtual TU & Obj()
FIXME_docs.
int M_stats(RtclArgs &args)
FIXME_docs.
int M_virt(RtclArgs &args)
FIXME_docs.
static bool Exec(RtclArgs &args, const Context &cntx, Rstats &stats)
FIXME_docs.
Definition: RtclStats.cpp:75
static bool GetArgs(RtclArgs &args, Context &cntx)
FIXME_docs.
Definition: RtclStats.cpp:37
FIXME_docs.
Definition: Rw11Cpu.hpp:66
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47
std::unique_ptr< RtclRw11Virt > RtclRw11VirtFactory(Rw11Virt *pobj)
FIXME_docs.