Fawkes API  Fawkes Development Version
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-2010  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 #if 0 /* just to make Emacs auto-indent happy */
00028 }
00029 #endif
00030 
00031 /** @class NetworkAspect <aspect/network.h>
00032  * Thread aspect for network communication.
00033  * Give this aspect to your thread if you want to implement custom network
00034  * communication. With this aspect you get access to the central network name
00035  * resolver and you may publish service on the network and browse for existing
00036  * services (for example using mDNS-SD via Avahi).
00037  *
00038  * It is guaranteed that if used properly from within plugins that
00039  * init_NetworkAspect() is called before the thread is started.
00040  *
00041  * @ingroup Aspects
00042  * @author Tim Niemueller
00043  */
00044 
00045 
00046 /** @var NetworkNameResolver NetworkAspect::nnresolver
00047  * Network name resolver to lookup IP addresses of hostnames and vice versa.
00048  * The nnresolver will remain valid for the whole lifetime of the
00049  * thread.
00050  */
00051 
00052 /** @var NetworkNameResolver NetworkAspect::service_publisher
00053  * Service publisher to publish services on the network.
00054  * The service_publisher will remain valid for the whole lifetime of the
00055  * thread.
00056  */
00057 
00058 /** @var NetworkNameResolver NetworkAspect::service_browser
00059  * Service browser to browse services on the network.
00060  * The service_browser will remain valid for the whole lifetime of the
00061  * thread.
00062  */
00063 
00064 /** Constructor. */
00065 NetworkAspect::NetworkAspect()
00066 {
00067   add_aspect("NetworkAspect");
00068 }
00069 
00070 /** Virtual empty Destructor. */
00071 NetworkAspect::~NetworkAspect()
00072 {
00073 }
00074 
00075 
00076 /** Init network aspect.
00077  * It is guaranteed that this is called for a thread having the
00078  * netwok aspect before Thread::start() is called (when
00079  * running regularly inside Fawkes).
00080  * @param resolver network name resolver
00081  * @param service_publisher service publisher
00082  * @param service_browser service browser
00083  */
00084 void
00085 NetworkAspect::init_NetworkAspect(NetworkNameResolver *resolver,
00086                                   ServicePublisher *service_publisher,
00087                                   ServiceBrowser *service_browser)
00088 {
00089   this->nnresolver = resolver;
00090   this->service_publisher = service_publisher;
00091   this->service_browser = service_browser;
00092 }
00093 
00094 } // end namespace fawkes