Fawkes API
Fawkes Development Version
broker_thread.cpp
1
2
/***************************************************************************
3
* broker_thread.cpp - NaoQi broker providing Thread
4
*
5
* Created: Thu May 12 19:03:40 2011
6
* Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#include "broker_thread.h"
24
25
#include "naoqi_broker.h"
26
27
#include <alcommon/albrokermanager.h>
28
#include <alcore/alerror.h>
29
#include <sys/wait.h>
30
31
#include <cerrno>
32
#include <csignal>
33
#include <unistd.h>
34
35
using namespace
fawkes
;
36
37
/** @class NaoQiBrokerThread "broker_thread.h"
38
* NaoQi Broker Thread.
39
* This thread maintains a NaoQi broker which can be used by other
40
* threads and is provided via the NaoQiAspect.
41
*
42
* @author Tim Niemueller
43
*/
44
45
/** Constructor. */
46
NaoQiBrokerThread::NaoQiBrokerThread
()
47
:
Thread
(
"NaoQiBrokerThread"
,
Thread
::OPMODE_WAITFORWAKEUP),
48
AspectProviderAspect
(
"NaoQiAspect"
, &naoqi_aspect_inifin_)
49
{
50
}
51
52
/** Destructor. */
53
NaoQiBrokerThread::~NaoQiBrokerThread
()
54
{
55
}
56
57
void
58
NaoQiBrokerThread::init
()
59
{
60
if
(fawkes::naoqi::broker) {
61
broker_ = fawkes::naoqi::broker;
62
logger
->
log_debug
(
name
(),
"Using NaoQi Module broker"
);
63
}
else
{
64
throw
Exception
(
"NaoQi broker not set, embedding of NaoQi "
65
"not implemented, yet"
);
66
}
67
68
/*
69
std::vector<AL::ALModuleInfo>::iterator m;
70
AL::ALPtr<std::vector<AL::ALModuleInfo> >
71
modules(new std::vector<AL::ALModuleInfo>);
72
73
broker_->getModuleList(modules);
74
for (m = modules->begin(); m != modules->end(); ++m) {
75
printf("Module: %s @ %s:%i\n", m->name.c_str(), m->ip.c_str(), m->port);
76
}
77
78
modules->clear();
79
broker_->getGlobalModuleList(modules);
80
for (m = modules->begin(); m != modules->end(); ++m) {
81
printf("Global Module: %s @ %s:%i\n", m->name.c_str(), m->ip.c_str(), m->port);
82
}
83
*/
84
85
naoqi_aspect_inifin_.
set_naoqi_broker
(broker_);
86
}
87
88
void
89
NaoQiBrokerThread::finalize
()
90
{
91
broker_.reset();
92
naoqi_aspect_inifin_.
set_naoqi_broker
(broker_);
93
}
94
95
void
96
NaoQiBrokerThread::loop
()
97
{
98
}
NaoQiBrokerThread::loop
virtual void loop()
Code to execute in the thread.
Definition:
broker_thread.cpp:96
fawkes::AspectProviderAspect
Definition:
aspect_provider.h:39
fawkes::Thread::name
const char * name() const
Definition:
thread.h:99
NaoQiBrokerThread::finalize
virtual void finalize()
Finalize the thread.
Definition:
broker_thread.cpp:89
fawkes::LoggingAspect::logger
Logger * logger
Definition:
logging.h:50
fawkes
fawkes::NaoQiAspectIniFin::set_naoqi_broker
void set_naoqi_broker(AL::ALPtr< AL::ALBroker > naoqi_broker)
Set the NaoQi broker to use for aspect initialization.
Definition:
naoqi_inifin.cpp:72
NaoQiBrokerThread::~NaoQiBrokerThread
virtual ~NaoQiBrokerThread()
Destructor.
Definition:
broker_thread.cpp:53
NaoQiBrokerThread::init
virtual void init()
Initialize the thread.
Definition:
broker_thread.cpp:58
fawkes::Thread
Definition:
thread.h:44
fawkes::Logger::log_debug
virtual void log_debug(const char *component, const char *format,...)=0
NaoQiBrokerThread::NaoQiBrokerThread
NaoQiBrokerThread()
Constructor.
Definition:
broker_thread.cpp:46
fawkes::Exception
Definition:
exception.h:39
src
plugins
nao
broker_thread.cpp
Generated by
1.8.16