Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
fountain_thread.cpp
1
2
/***************************************************************************
3
* fountain_thread.h - Fountain main thread
4
*
5
* Created: Fri Nov 16 11:22:30 2007
6
* Copyright 2005-2007 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 "fountain_thread.h"
24
25
#include <core/exceptions/software.h>
26
#include <fvutils/net/fuse_server.h>
27
28
#include <string>
29
#include <cstdio>
30
31
using namespace
fawkes;
32
using namespace
firevision;
33
34
/** @class FountainThread "fountain_thread.h"
35
* Fountain main thread.
36
* @author Tim Niemueller
37
*/
38
39
/** Constructor. */
40
FountainThread::FountainThread
()
41
:
Thread
(
"FountainThread"
, OPMODE_WAITFORWAKEUP)
42
{
43
__fuse_server = NULL;
44
__service = NULL;
45
}
46
47
48
/** Destructor. */
49
FountainThread::~FountainThread
()
50
{
51
if
( __fuse_server ) {
52
thread_collector
->
remove
(__fuse_server);
53
delete
__fuse_server;
54
__fuse_server = NULL;
55
}
56
delete
__service;
57
__service = NULL;
58
}
59
60
61
void
62
FountainThread::init
()
63
{
64
// Start FUSE server
65
unsigned
int
port = 0;
66
try
{
67
port =
config
->
get_uint
(
"/firevision/fountain/tcp_port"
);
68
if
( port > 0xFFFF ) {
69
throw
OutOfBoundsException
(
"Network port out of bounds"
, port, 0, 0xFFFF);
70
}
71
__fuse_server =
new
FuseServer
(port,
thread_collector
);
72
thread_collector
->
add
(__fuse_server);
73
}
catch
(
Exception
&e) {
74
e.
print_trace
();
75
throw
;
76
}
77
78
// Announce service
79
std::string sname =
"Fountain on "
;
80
sname +=
nnresolver
->
short_hostname
();
81
__service =
new
NetworkService
(sname.c_str(),
"_fountain._tcp"
, port);
82
service_publisher
->
publish_service
(__service);
83
}
84
85
86
void
87
FountainThread::finalize
()
88
{
89
service_publisher
->
unpublish_service
(__service);
90
91
thread_collector
->
remove
(__fuse_server);
92
delete
__fuse_server;
93
__fuse_server = NULL;
94
delete
__service;
95
__service = NULL;
96
}
97
98
99
void
100
FountainThread::loop
()
101
{
102
// do nothing, but implement to not exit
103
printf(
"Sucker Loop\n"
);
104
}
src
plugins
perception
fountain
fountain_thread.cpp
Generated by
1.8.1.1