40 #include "rtt-typekit-config.h" 42 #include "../types/Types.hpp" 43 #include "../FlowStatus.hpp" 44 #include "../internal/DataSources.hpp" 45 #include "../typekit/Types.hpp" 46 #include "../rtt-fwd.hpp" 47 #include "../internal/mystd.hpp" 48 #include "../types/TemplateConstructor.hpp" 50 #include "../rt_string.hpp" 56 using namespace detail;
62 :
public std::unary_function<int, const std::vector<double>&>
64 typedef const std::vector<double>& (Signature)(
int );
65 mutable boost::shared_ptr< std::vector<double> > ptr;
67 : ptr( new
std::vector<double>() ) {}
68 const std::vector<double>& operator()(
int size )
const 79 struct array_varargs_ctor
81 typedef const std::vector<double>& result_type;
82 typedef double argument_type;
83 result_type operator()(
const std::vector<double>& args )
const 93 typedef NArityDataSource<array_varargs_ctor> ArrayDataSource;
100 :
public TypeConstructor
103 if (args.size() == 0 )
106 for(
unsigned int i=0; i != args.size(); ++i) {
119 :
public std::binary_function<int, double, const std::vector<double>&>
121 typedef const std::vector<double>& (Signature)(
int,
double );
122 mutable boost::shared_ptr< std::vector<double> > ptr;
124 : ptr( new
std::vector<double>() ) {}
125 const std::vector<double>& operator()(
int size,
double value )
const 128 ptr->assign( size, value );
133 double float_to_double(
float val ) {
return double(val);}
134 float double_to_float(
double val ) {
return float(val);}
136 int float_to_int(
float f) {
return int(f); }
137 float int_to_float(
int i) {
return float(i); }
138 int double_to_int(
double f) {
return int(f); }
139 double int_to_double(
int i) {
return double(i); }
140 unsigned int int_to_uint(
int i) {
return (
unsigned int)(i); }
141 int uint_to_int(
unsigned int ui) {
return int(ui); }
144 long long float_to_llong(
float f) {
return (
long long)(f); }
145 float llong_to_float(
long long i) {
return (
float)(i); }
146 long long double_to_llong(
double f) {
return (
long long)(f); }
147 double llong_to_double(
long long i) {
return (
double)(i); }
148 long long int_to_llong(
int i) {
return (
long long)(i); }
149 int llong_to_int(
long long i) {
return (
int)(i); }
150 long long uint_to_llong(
unsigned int i) {
return (
long long)(i); }
151 unsigned int llong_to_uint(
long long i) {
return (
unsigned int)(i); }
152 bool llong_to_bool(
long long i) {
return i != 0; }
155 unsigned long long float_to_ullong(
float f) {
return (
unsigned long long)(f); }
156 float ullong_to_float(
unsigned long long i) {
return (
float)(i); }
157 unsigned long long double_to_ullong(
double f) {
return (
unsigned long long)(f); }
158 double ullong_to_double(
unsigned long long i) {
return (
double)(i); }
159 unsigned long long int_to_ullong(
int i) {
return (
unsigned long long)(i); }
160 int ullong_to_int(
unsigned long long i) {
return (
int)(i); }
161 unsigned long long uint_to_ullong(
unsigned int i) {
return (
unsigned long long)(i); }
162 unsigned int ullong_to_uint(
unsigned long long i) {
return (
unsigned int)(i); }
163 unsigned long long llong_to_ullong(
long long i) {
return (
unsigned long long)(i); }
164 long long ullong_to_llong(
unsigned long long i) {
return (
long long)(i); }
170 bool int_to_bool(
int i) {
return i != 0; }
171 int bool_to_int(
bool b) {
return int(b); }
174 :
public std::unary_function<int, std::string>
176 typedef std::string (Signature)( int );
177 std::string operator()(
int size )
const 179 return std::string( size, std::string::value_type() );
184 struct rt_string_ctor_int
185 :
public std::unary_function<int, RTT::rt_string>
190 return rt_string( size, rt_string::value_type() );
194 struct rt_string_ctor_string
195 :
public std::unary_function<const std::string&, RTT::rt_string>
197 typedef rt_string (Signature)( std::string
const& );
198 rt_string operator()( std::string
const& arg )
const 204 struct string_ctor_rt_string
205 :
public std::unary_function<const rt_string&, std::string>
207 typedef std::string (Signature)(
rt_string const& );
208 std::string operator()(
rt_string const& arg )
const 210 return std::string( arg.c_str() );
221 ti->type(
"double")->addConstructor(
newConstructor( &float_to_double,
true ));
222 ti->type(
"double")->addConstructor(
newConstructor( &int_to_double,
true ));
223 ti->type(
"float")->addConstructor(
newConstructor( &int_to_float,
true ));
224 ti->type(
"float")->addConstructor(
newConstructor( &double_to_float,
true ));
225 ti->type(
"int")->addConstructor(
newConstructor( &float_to_int,
false ));
226 ti->type(
"int")->addConstructor(
newConstructor( &double_to_int,
false ));
227 ti->type(
"int")->addConstructor(
newConstructor( &uint_to_int,
true ));
228 ti->type(
"int")->addConstructor(
newConstructor( &bool_to_int,
true ));
229 ti->type(
"uint")->addConstructor(
newConstructor( &int_to_uint,
true ));
232 ti->type(
"llong")->addConstructor(
newConstructor( &float_to_llong,
true ));
233 ti->type(
"float")->addConstructor(
newConstructor( &llong_to_float,
true ));
234 ti->type(
"llong")->addConstructor(
newConstructor( &double_to_llong,
true ));
235 ti->type(
"double")->addConstructor(
newConstructor( &llong_to_double,
true ));
236 ti->type(
"llong")->addConstructor(
newConstructor( &int_to_llong,
true ));
237 ti->type(
"int")->addConstructor(
newConstructor( &llong_to_int,
true ));
238 ti->type(
"llong")->addConstructor(
newConstructor( &uint_to_llong,
true ));
239 ti->type(
"uint")->addConstructor(
newConstructor( &llong_to_uint,
true ));
240 ti->type(
"bool")->addConstructor(
newConstructor( &llong_to_bool,
true ));
243 ti->type(
"ullong")->addConstructor(
newConstructor( &float_to_ullong,
true ));
244 ti->type(
"float")->addConstructor(
newConstructor( &ullong_to_float,
true ));
245 ti->type(
"ullong")->addConstructor(
newConstructor( &double_to_ullong,
true ));
246 ti->type(
"double")->addConstructor(
newConstructor( &ullong_to_double,
true ));
247 ti->type(
"ullong")->addConstructor(
newConstructor( &int_to_ullong,
true ));
248 ti->type(
"int")->addConstructor(
newConstructor( &ullong_to_int,
true ));
249 ti->type(
"ullong")->addConstructor(
newConstructor( &uint_to_ullong,
true ));
250 ti->type(
"uint")->addConstructor(
newConstructor( &ullong_to_uint,
true ));
251 ti->type(
"ullong")->addConstructor(
newConstructor( &llong_to_ullong,
true ));
252 ti->type(
"llong")->addConstructor(
newConstructor( &ullong_to_llong,
true ));
254 ti->type(
"string")->addConstructor(
newConstructor( string_ctor() ) );
256 ti->type(
"rt_string")->addConstructor(
newConstructor( rt_string_ctor_int() ) );
257 ti->type(
"rt_string")->addConstructor(
newConstructor( rt_string_ctor_string() ) );
258 ti->type(
"string")->addConstructor(
newConstructor( string_ctor_rt_string() ) );
260 ti->type(
"bool")->addConstructor(
newConstructor( &flowstatus_to_bool,
true ) );
261 ti->type(
"bool")->addConstructor(
newConstructor( &writestatus_to_bool,
true ) );
262 ti->type(
"bool")->addConstructor(
newConstructor( &send_to_bool,
true ) );
263 ti->type(
"bool")->addConstructor(
newConstructor( &int_to_bool,
true ) );
std::basic_string< char, std::char_traits< char >, RTT::os::rt_allocator< char > > rt_string
Real-time allocatable, dynamically-sized string.
boost::intrusive_ptr< ArrayDataSource< T > > shared_ptr
TypeConstructor * newConstructor(Function *foo, bool automatic=false)
boost::intrusive_ptr< DataSource< double > > shared_ptr
virtual bool loadConstructors()
static shared_ptr Instance()
boost::intrusive_ptr< DataSourceBase > shared_ptr
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
boost::shared_ptr< TypeInfoRepository > shared_ptr