Fawkes API  Fawkes Development Version
webview.cpp
1 
2 /***************************************************************************
3  * webview.cpp - Fawkes WebviewAspect initializer/finalizer
4  *
5  * Created: Thu Nov 25 23:12:01 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/webview.h>
25 #include <aspect/webview.h>
26 #include <core/threading/thread_finalizer.h>
27 #include <webview/url_manager.h>
28 #include <webview/nav_manager.h>
29 #include <webview/request_manager.h>
30 
31 namespace fawkes {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
36 /** @class WebviewAspectIniFin <aspect/inifins/webview.h>
37  * Initializer/finalizer for the WebviewAspect.
38  * @author Tim Niemueller
39  */
40 
41 /** Constructor. */
43  : AspectIniFin("WebviewAspect")
44 {
45  __url_manager = new WebUrlManager();
46  __nav_manager = new WebNavManager();
47  __request_manager = new WebRequestManager();
48 }
49 
50 /** Destructor. */
52 {
53  delete __url_manager;
54  delete __nav_manager;
55  delete __request_manager;
56 }
57 
58 
59 void
61 {
62  WebviewAspect *webview_thread;
63  webview_thread = dynamic_cast<WebviewAspect *>(thread);
64  if (webview_thread == NULL) {
65  throw CannotInitializeThreadException("Thread '%s' claims to have the "
66  "WebviewAspect, but RTTI says it "
67  "has not. ", thread->name());
68  }
69 
70  webview_thread->init_WebviewAspect(__url_manager, __nav_manager, __request_manager);
71 }
72 
73 
74 void
76 {
77  WebviewAspect *webview_thread;
78  webview_thread = dynamic_cast<WebviewAspect *>(thread);
79  if (webview_thread == NULL) {
80  throw CannotFinalizeThreadException("Thread '%s' claims to have the "
81  "WebviewAspect, but RTTI says it "
82  "has not. ", thread->name());
83  }
84 }
85 
86 } // end namespace fawkes
WebviewAspectIniFin()
Constructor.
Definition: webview.cpp:42
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
~WebviewAspectIniFin()
Destructor.
Definition: webview.cpp:51
virtual void init(Thread *thread)
Initialize thread.
Definition: webview.cpp:60
Thread cannot be initialized.
Manage URL mappings.
Definition: url_manager.h:37
virtual void finalize(Thread *thread)
Finalize thread.
Definition: webview.cpp:75
Manage visible navigation entries.
Definition: nav_manager.h:36
Probides information about ongoing requests.
const char * name() const
Get name of thread.
Definition: thread.h:95
void init_WebviewAspect(WebUrlManager *url_manager, WebNavManager *nav_manager, WebRequestManager *request_manager)
Set URL manager.
Definition: webview.cpp:74
Thread cannot be finalized.
Thread aspect to provide web pages via Webview.
Definition: webview.h:38
Aspect initializer/finalizer base class.
Definition: inifin.h:36