Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * broker_thread.cpp - NaoQi broker providing Thread 00004 * 00005 * Created: Thu May 12 19:03:40 2011 00006 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "broker_thread.h" 00024 #include "naoqi_broker.h" 00025 00026 #include <cerrno> 00027 #include <csignal> 00028 #include <unistd.h> 00029 #include <sys/wait.h> 00030 00031 #include <alcommon/albrokermanager.h> 00032 #include <alcore/alerror.h> 00033 00034 using namespace fawkes; 00035 00036 /** @class NaoQiBrokerThread "broker_thread.h" 00037 * NaoQi Broker Thread. 00038 * This thread maintains a NaoQi broker which can be used by other 00039 * threads and is provided via the NaoQiAspect. 00040 * 00041 * @author Tim Niemueller 00042 */ 00043 00044 /** Constructor. */ 00045 NaoQiBrokerThread::NaoQiBrokerThread() 00046 : Thread("NaoQiBrokerThread", Thread::OPMODE_WAITFORWAKEUP), 00047 AspectProviderAspect("NaoQiAspect", &__naoqi_aspect_inifin) 00048 { 00049 } 00050 00051 00052 /** Destructor. */ 00053 NaoQiBrokerThread::~NaoQiBrokerThread() 00054 { 00055 } 00056 00057 00058 void 00059 NaoQiBrokerThread::init() 00060 { 00061 if (fawkes::naoqi::broker) { 00062 __broker = fawkes::naoqi::broker; 00063 logger->log_debug(name(), "Using NaoQi Module broker"); 00064 } else { 00065 throw Exception("NaoQi broker not set, embedding of NaoQi " 00066 "not implemented, yet"); 00067 } 00068 00069 /* 00070 std::vector<AL::ALModuleInfo>::iterator m; 00071 AL::ALPtr<std::vector<AL::ALModuleInfo> > 00072 modules(new std::vector<AL::ALModuleInfo>); 00073 00074 __broker->getModuleList(modules); 00075 for (m = modules->begin(); m != modules->end(); ++m) { 00076 printf("Module: %s @ %s:%i\n", m->name.c_str(), m->ip.c_str(), m->port); 00077 } 00078 00079 modules->clear(); 00080 __broker->getGlobalModuleList(modules); 00081 for (m = modules->begin(); m != modules->end(); ++m) { 00082 printf("Global Module: %s @ %s:%i\n", m->name.c_str(), m->ip.c_str(), m->port); 00083 } 00084 */ 00085 00086 __naoqi_aspect_inifin.set_naoqi_broker(__broker); 00087 } 00088 00089 00090 void 00091 NaoQiBrokerThread::finalize() 00092 { 00093 __broker.reset(); 00094 __naoqi_aspect_inifin.set_naoqi_broker(__broker); 00095 } 00096 00097 00098 void 00099 NaoQiBrokerThread::loop() 00100 { 00101 }