w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RtclGet.ipp
Go to the documentation of this file.
1// $Id: RtclGet.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-02-16 1112 1.2.5 use const& for oper() of string& and Rtime&
8// 2018-12-22 1091 1.2.4 <float> add float cast (-Wdouble-promotion fix)
9// 2018-12-18 1089 1.2.3 use c++ style casts
10// 2018-12-15 1083 1.2.2 ctor: use rval ref and move semantics
11// 2018-12-14 1081 1.2.1 use std::function instead of boost
12// 2017-04-16 876 1.2 add Tcl_Obj*
13// 2017-02-20 854 1.1 add Rtime
14// 2013-02-12 487 1.0 Initial version
15// ---------------------------------------------------------------------------
16
26#include "librtools/Rtime.hpp"
27#include <iostream>
28
29// all method definitions in namespace Retro
30namespace Retro {
31
32//------------------------------------------+-----------------------------------
34
35template <class TP>
36inline RtclGet<TP>::RtclGet(std::function<TP()>&& get)
37 : fGet(move(get))
38{}
39
40//------------------------------------------+-----------------------------------
42
43template <class TP>
45{}
46
47//------------------------------------------+-----------------------------------
49
50template <>
51inline Tcl_Obj* RtclGet<bool>::operator()() const
52{
53 bool val = fGet();
54 return Tcl_NewBooleanObj(int(val));
55}
56
57//------------------------------------------+-----------------------------------
59
60template <>
61inline Tcl_Obj* RtclGet<char>::operator()() const
62{
63 char val = fGet();
64 return Tcl_NewIntObj(int(val));
65}
66
67//------------------------------------------+-----------------------------------
69
70template <>
71inline Tcl_Obj* RtclGet<signed char>::operator()() const
72{
73 signed char val = fGet();
74 return Tcl_NewIntObj(int(val));
75}
76
77//------------------------------------------+-----------------------------------
79
80template <>
81inline Tcl_Obj* RtclGet<unsigned char>::operator()() const
82{
83 unsigned char val = fGet();
84 return Tcl_NewIntObj(int(val));
85}
86
87//------------------------------------------+-----------------------------------
89
90template <>
91inline Tcl_Obj* RtclGet<short>::operator()() const
92{
93 short val = fGet();
94 return Tcl_NewIntObj(int(val));
95}
96
97//------------------------------------------+-----------------------------------
99
100template <>
102{
103 unsigned short val = fGet();
104 return Tcl_NewIntObj(int(val));
105}
106
107//------------------------------------------+-----------------------------------
109
110template <>
111inline Tcl_Obj* RtclGet<int>::operator()() const
112{
113 int val = fGet();
114 return Tcl_NewIntObj(val);
115}
116
117//------------------------------------------+-----------------------------------
119
120template <>
121inline Tcl_Obj* RtclGet<unsigned int>::operator()() const
122{
123 unsigned int val = fGet();
124 return Tcl_NewIntObj(int(val));
125}
126
127//------------------------------------------+-----------------------------------
129
130template <>
131inline Tcl_Obj* RtclGet<long>::operator()() const
132{
133 long val = fGet();
134 return Tcl_NewLongObj(val);
135}
136
137//------------------------------------------+-----------------------------------
139
140template <>
142{
143 unsigned long val = fGet();
144 return Tcl_NewLongObj(long(val));
145}
146
147//------------------------------------------+-----------------------------------
149
150template <>
151inline Tcl_Obj* RtclGet<float>::operator()() const
152{
153 float val = fGet();
154 return Tcl_NewDoubleObj(double(val));
155}
156
157//------------------------------------------+-----------------------------------
159
160template <>
161inline Tcl_Obj* RtclGet<double>::operator()() const
162{
163 double val = fGet();
164 return Tcl_NewDoubleObj(val);
165}
166
167//------------------------------------------+-----------------------------------
169
170template <>
171inline Tcl_Obj* RtclGet<std::string>::operator()() const
172{
173 std::string val = fGet();
174 return Tcl_NewStringObj(val.data(), val.length());
175}
176
177//------------------------------------------+-----------------------------------
179
180template <>
182{
183 const std::string& val = fGet();
184 return Tcl_NewStringObj(val.data(), val.length());
185}
186
187//------------------------------------------+-----------------------------------
189
190template <>
191inline Tcl_Obj* RtclGet<Rtime>::operator()() const
192{
193 Rtime val = fGet();
194 return Tcl_NewDoubleObj(double(val));
195}
196
197//------------------------------------------+-----------------------------------
199
200template <>
201inline Tcl_Obj* RtclGet<const Rtime&>::operator()() const
202{
203 const Rtime& val = fGet();
204 return Tcl_NewDoubleObj(double(val));
205}
206
207//------------------------------------------+-----------------------------------
209
210template <>
211inline Tcl_Obj* RtclGet<Tcl_Obj*>::operator()() const
212{
213 return fGet();
214}
215
216
217} // end namespace Retro
218
~RtclGet()
FIXME_docs.
Definition: RtclGet.ipp:44
virtual Tcl_Obj * operator()() const
RtclGet(std::function< TP()> &&get)
FIXME_docs.
Definition: RtclGet.ipp:36
FIXME_docs.
Definition: Rtime.hpp:25
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47