$search
00001 /*************************************************************************** 00002 tag: The SourceWorks Tue Sep 7 00:54:57 CEST 2010 operations_fixture.cpp 00003 00004 operations_fixture.cpp - description 00005 ------------------- 00006 begin : Tue September 07 2010 00007 copyright : (C) 2010 The SourceWorks 00008 email : peter@thesourceworks.com 00009 00010 *************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 00019 00020 #define BOOST_FUSION_INVOKE_MAX_ARITY 8 00021 #define BOOST_FUSION_UNFUSED_MAX_ARITY 7 00022 00023 #include "operations_fixture.hpp" 00024 #include <iostream> 00025 #include <TaskContext.hpp> 00026 #include <OperationCaller.hpp> 00027 #include <Operation.hpp> 00028 #include <Service.hpp> 00029 00030 using namespace std; 00031 using namespace boost; 00032 using namespace RTT; 00033 using namespace RTT::detail; 00034 00035 OperationsFixture::OperationsFixture() 00036 { 00037 ret = 0.0; 00038 i = -1; 00039 tc = new TaskContext("root"); 00040 this->createOperationCallerFactories(tc); 00041 tc->provides()->addAttribute("ret", ret ); 00042 caller = new TaskContext("caller"); 00043 caller->start(); 00044 tc->start(); 00045 } 00046 00047 OperationsFixture::~OperationsFixture() 00048 { 00049 tc->stop(); 00050 delete tc; 00051 delete caller; 00052 } 00053 00054 void OperationsFixture::createOperationCallerFactories(TaskContext* target) 00055 { 00056 Service::shared_ptr dat = Service::Create("test", target); 00057 dat->addAttribute("i", i); 00058 dat->addOperation("assert", &OperationsFixture::assertBool, this).doc("assert").arg("b", "bd"); 00059 dat->addOperation("assertEqual", &OperationsFixture::assertEqual, this); 00060 dat->addOperation("increase", &OperationsFixture::increase, this).doc("Return increasing i"); 00061 dat->addOperation("increaseCmd", &OperationsFixture::increase, this, OwnThread).doc("Return increasing i"); 00062 dat->addOperation("resetI", &OperationsFixture::resetI, this).doc("ResetI i"); 00063 dat->addOperation("assertMsg", &OperationsFixture::assertMsg, this).doc("Assert message").arg("bool", "").arg("text", "text"); 00064 dat->addOperation("isTrue", &OperationsFixture::isTrue, this).doc("Identity function").arg("bool", ""); 00065 dat->addOperation("fail", &OperationsFixture::fail, this).doc("Fails by throwing."); 00066 dat->addOperation("good", &OperationsFixture::good, this).doc("Returns true."); 00067 dat->addOperation("print", &OperationsFixture::print, this).doc("Print message"); 00068 dat->addOperation("printNumber", &OperationsFixture::printNumber, this).doc("Print message + number"); 00069 00070 createOperationCallerFactories0(target); 00071 createOperationCallerFactories1(target); 00072 createOperationCallerFactories2(target); 00073 createOperationCallerFactories3(target); 00074 createOperationCallerFactories4(target); 00075 createOperationCallerFactories5(target); 00076 createOperationCallerFactories6(target); 00077 createOperationCallerFactories7(target); 00078 00079 }