network.cpp

00001 
00002 /***************************************************************************
00003  *  network.cpp - network aspect for Fawkes
00004  *
00005  *  Created: Fri Jun 29 15:17:08 2007 (on flight to RoboCup 2007, Atlanta)
00006  *  Copyright  2006-2007  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. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #include <aspect/network.h>
00025 
00026 namespace fawkes {
00027 
00028 /** @class NetworkAspect <aspect/network.h>
00029  * Thread aspect for network communication.
00030  * Give this aspect to your thread if you want to implement custom network
00031  * communication. With this aspect you get access to the central network name
00032  * resolver and you may publish service on the network and browse for existing
00033  * services (for example using mDNS-SD via Avahi).
00034  *
00035  * It is guaranteed that if used properly from within plugins that
00036  * initNetworkAspect() is called before the thread is started.
00037  *
00038  * @ingroup Aspects
00039  * @author Tim Niemueller
00040  */
00041 
00042 
00043 /** @var NetworkNameResolver NetworkAspect::nnresolver
00044  * Network name resolver to lookup IP addresses of hostnames and vice versa.
00045  * The nnresolver will remain valid for the whole lifetime of the
00046  * thread.
00047  */
00048 
00049 /** @var NetworkNameResolver NetworkAspect::service_publisher
00050  * Service publisher to publish services on the network.
00051  * The service_publisher will remain valid for the whole lifetime of the
00052  * thread.
00053  */
00054 
00055 /** @var NetworkNameResolver NetworkAspect::service_browser
00056  * Service browser to browse services on the network.
00057  * The service_browser will remain valid for the whole lifetime of the
00058  * thread.
00059  */
00060 
00061 /** Virtual empty Destructor. */
00062 NetworkAspect::~NetworkAspect()
00063 {
00064 }
00065 
00066 
00067 /** Init network aspect.
00068  * It is guaranteed that this is called for a thread having the
00069  * netwok aspect before Thread::start() is called (when
00070  * running regularly inside Fawkes).
00071  * @param resolver network name resolver
00072  * @param service_publisher service publisher
00073  * @param service_browser service browser
00074  */
00075 void
00076 NetworkAspect::init_NetworkAspect(NetworkNameResolver *resolver,
00077                                   ServicePublisher *service_publisher,
00078                                   ServiceBrowser *service_browser)
00079 {
00080   this->nnresolver = resolver;
00081   this->service_publisher = service_publisher;
00082   this->service_browser = service_browser;
00083 }
00084 
00085 } // end namespace fawkes