6 #include <rtt/TaskContext.hpp> 7 #include <rtt/Logger.hpp> 8 #include <rtt/Property.hpp> 9 #include <rtt/Attribute.hpp> 10 #include <rtt/Operation.hpp> 11 #include <rtt/Port.hpp> 12 #include <rtt/Activity.hpp> 14 #include <ocl/OCL.hpp> 26 RTT::Property<std::string> property;
27 std::string attribute;
30 RTT::OutputPort<std::string> outport;
31 RTT::InputPort<std::string> bufferport;
34 log(Warning) <<
"in: void null_0" << endlog();
38 log(Warning) <<
"in: std::string op_0" << endlog();
39 return "inside operation_0";
42 bool op_1(std::string s) {
43 log(Warning) <<
"in: bool op_1(std::string s) " << s << endlog();
47 double op_2(std::string s,
double d) {
48 log(Warning) <<
"in: double op_2(std::string s, double d) " << s << d << endlog();
52 void op_1_out(
int &i) {
53 log(Warning) <<
"in: void op_1_out(int &i) " << i << endlog();
58 void op_3_out(std::string &s,
double &d,
int &i) {
59 log(Warning) <<
"in: void op_3_out(std::string &s, double &d, int &i) " << s << d << i << endlog();
60 s = s +
"-this-string-has-a-tail";
66 bool op_1_out_retval(
int &i) {
67 log(Warning) <<
"in: bool op_1_out_retval(int &i) " << i << endlog();
72 void throw_exception()
74 throw std::runtime_error(
"Alas, its time to go.");
77 bool op1_uint8(
unsigned char x)
90 OperationCaller<bool(std::string)> print;
98 property(
"the_property",
"the_property Description",
"Hello World"),
99 attribute(
"Hello World"),
100 constant(
"Hello World"),
102 outport(
"the_results",true),
104 bufferport(
"the_buffer_port",ConnPolicy::buffer(13,ConnPolicy::LOCK_FREE,true) )
109 this->setActivity(
new Activity(0, 0.01) );
112 assert( property.ready() );
115 this->properties()->addProperty( property);
117 this->addAttribute(
"the_attribute", attribute);
118 this->addConstant(
"the_constant", constant);
120 this->ports()->addPort( outport ).doc(
"dummy test port");
121 this->ports()->addPort( bufferport );
123 this->addOperation(
"null_0", &Testcomp::null_0,
this, OwnThread ).doc(
"'null_0' Description");
124 this->addOperation(
"op_0_ct", &Testcomp::op_0,
this, ClientThread ).doc(
"'op_0_ct', ClientThread variant");
125 this->addOperation(
"op_0_ot", &Testcomp::op_0,
this, ClientThread ).doc(
"'op_0_ot', OwnThread variant");
126 this->addOperation(
"op_1", &Testcomp::op_1,
this, OwnThread).doc(
"'op_1' Description").arg(
"mes",
"just any string.");
127 this->addOperation(
"op_2", &Testcomp::op_2,
this, OwnThread).doc(
"'op_2' Description").arg(
"mes",
"just any string.").arg(
"double",
"just any double");
128 this->addOperation(
"op_1_out", &Testcomp::op_1_out,
this, OwnThread).doc(
"'op_1_out' Description").arg(
"i",
"any int");
129 this->addOperation(
"op_3_out", &Testcomp::op_3_out,
this, OwnThread).doc(
"'op_3_out' Description").arg(
"mes",
"just any string.").arg(
"double",
"just any double").arg(
"i",
"just any int");
130 this->addOperation(
"op_1_out_retval", &Testcomp::op_1_out_retval,
this, OwnThread).doc(
"'op_1_out' Description").arg(
"i",
"any int");
132 this->addOperation(
"op1_uint8", &Testcomp::op1_uint8,
this, OwnThread).doc(
"'op1_uint8' Description").arg(
"x",
"any char, try 'x'");
134 this->addOperation(
"throw", &Testcomp::throw_exception,
this, ClientThread).doc(
"This operation throws an exception");
135 this->provides(
"printing")
136 ->addOperation(
"print", &Testcomp::op_1,
137 this, OwnThread).doc(
"'op_1' Description").arg(
"mes",
"just any string.");
139 this->requires(
"print_str")->addOperationCaller(print);
142 log(Info) <<
"**** Starting the 'Testcomp' component ****" <<endlog();
Testcomp(std::string name)
This example sets the interface up in the Constructor of the component.
This file contains the macros and definitions to create dynamically loadable components.
The Orocos Component Library.