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