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