Fawkes API  Fawkes Development Version
network.cpp
1 
2 /***************************************************************************
3  * network.cpp - network aspect for Fawkes
4  *
5  * Created: Fri Jun 29 15:17:08 2007 (on flight to RoboCup 2007, Atlanta)
6  * Copyright 2006-2010 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. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #include <aspect/network.h>
25 
26 namespace fawkes {
27 #if 0 /* just to make Emacs auto-indent happy */
28 }
29 #endif
30 
31 /** @class NetworkAspect <aspect/network.h>
32  * Thread aspect for network communication.
33  * Give this aspect to your thread if you want to implement custom network
34  * communication. With this aspect you get access to the central network name
35  * resolver and you may publish service on the network and browse for existing
36  * services (for example using mDNS-SD via Avahi).
37  *
38  * It is guaranteed that if used properly from within plugins that
39  * init_NetworkAspect() is called before the thread is started.
40  *
41  * @ingroup Aspects
42  * @author Tim Niemueller
43  */
44 
45 
46 /** @var NetworkNameResolver NetworkAspect::nnresolver
47  * Network name resolver to lookup IP addresses of hostnames and vice versa.
48  * The nnresolver will remain valid for the whole lifetime of the
49  * thread.
50  */
51 
52 /** @var NetworkNameResolver NetworkAspect::service_publisher
53  * Service publisher to publish services on the network.
54  * The service_publisher will remain valid for the whole lifetime of the
55  * thread.
56  */
57 
58 /** @var NetworkNameResolver NetworkAspect::service_browser
59  * Service browser to browse services on the network.
60  * The service_browser will remain valid for the whole lifetime of the
61  * thread.
62  */
63 
64 /** Constructor. */
66 {
67  add_aspect("NetworkAspect");
68 }
69 
70 /** Virtual empty Destructor. */
72 {
73 }
74 
75 
76 /** Init network aspect.
77  * It is guaranteed that this is called for a thread having the
78  * netwok aspect before Thread::start() is called (when
79  * running regularly inside Fawkes).
80  * @param resolver network name resolver
81  * @param service_publisher service publisher
82  * @param service_browser service browser
83  */
84 void
88 {
89  this->nnresolver = resolver;
90  this->service_publisher = service_publisher;
91  this->service_browser = service_browser;
92 }
93 
94 } // end namespace fawkes
Service browser.
Service publisher interface.
void init_NetworkAspect(NetworkNameResolver *resolver, ServicePublisher *service_publisher, ServiceBrowser *service_browser)
Init network aspect.
Definition: network.cpp:85
ServicePublisher * service_publisher
Service publisher to publish services on the network.
Definition: network.h:49
Fawkes library namespace.
void add_aspect(const char *name)
Add an aspect to a thread.
Definition: aspect.cpp:52
NetworkAspect()
Constructor.
Definition: network.cpp:65
NetworkNameResolver * nnresolver
Network name resolver to lookup IP addresses of hostnames and vice versa.
Definition: network.h:48
Network name and address resolver.
Definition: resolver.h:48
ServiceBrowser * service_browser
Service browser to browse services on the network.
Definition: network.h:50
virtual ~NetworkAspect()
Virtual empty Destructor.
Definition: network.cpp:71