Fawkes API  Fawkes Development Version
network.cpp
1 
2 /***************************************************************************
3  * network.cpp - Fawkes NetworkAspect initializer/finalizer
4  *
5  * Created: Tue Nov 23 23:47:59 2010
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/inifins/network.h>
25 #include <aspect/network.h>
26 #include <netcomm/service_discovery/service_browser.h>
27 #include <netcomm/service_discovery/service_publisher.h>
28 #include <netcomm/utils/resolver.h>
29 
30 namespace fawkes {
31 
32 /** @class NetworkAspectIniFin <aspect/inifins/network.h>
33  * Initializer/finalizer for the NetworkAspect.
34  * @author Tim Niemueller
35  */
36 
37 /** Constructor.
38  * @param nnresolver network name resolver to pass to threads
39  * @param service_browser service browser to pass to threads
40  * @param service_publisher service publisher resolver to pass to threads
41  */
43  ServicePublisher * service_publisher,
44  ServiceBrowser * service_browser)
45 : AspectIniFin("NetworkAspect")
46 {
47  nnresolver_ = nnresolver;
48  service_publisher_ = service_publisher;
49  service_browser_ = service_browser;
50 }
51 
52 void
54 {
55  NetworkAspect *network_thread;
56  network_thread = dynamic_cast<NetworkAspect *>(thread);
57  if (network_thread == NULL) {
58  throw CannotInitializeThreadException("Thread '%s' claims to have the "
59  "NetworkAspect, but RTTI says it "
60  "has not. ",
61  thread->name());
62  }
63 
64  network_thread->init_NetworkAspect(nnresolver_, service_publisher_, service_browser_);
65 }
66 
67 void
69 {
70 }
71 
72 } // end namespace fawkes
fawkes::NetworkAspectIniFin::finalize
virtual void finalize(Thread *thread)
Finalize thread.
Definition: network.cpp:68
fawkes::NetworkNameResolver
Network name and address resolver.
Definition: resolver.h:45
fawkes::ServiceBrowser
Service browser.
Definition: service_browser.h:33
fawkes::CannotInitializeThreadException
Thread cannot be initialized.
Definition: thread_initializer.h:34
fawkes::Thread::name
const char * name() const
Get name of thread.
Definition: thread.h:100
fawkes::AspectIniFin
Aspect initializer/finalizer base class.
Definition: inifin.h:34
fawkes::NetworkAspectIniFin::init
virtual void init(Thread *thread)
Initialize thread.
Definition: network.cpp:53
fawkes
Fawkes library namespace.
fawkes::NetworkAspectIniFin::NetworkAspectIniFin
NetworkAspectIniFin(NetworkNameResolver *nnresolver, ServicePublisher *service_publisher, ServiceBrowser *service_browser)
Constructor.
Definition: network.cpp:42
fawkes::ServicePublisher
Service publisher interface.
Definition: service_publisher.h:32
fawkes::Thread
Thread class encapsulation of pthreads.
Definition: thread.h:46
fawkes::NetworkAspect::init_NetworkAspect
void init_NetworkAspect(NetworkNameResolver *resolver, ServicePublisher *service_publisher, ServiceBrowser *service_browser)
Init network aspect.
Definition: network.cpp:80
fawkes::NetworkAspect
Thread aspect for network communication.
Definition: network.h:35