Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * url_manager.cpp - Web URL manager 00004 * 00005 * Created: Thu Nov 25 21:56:19 2010 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. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include <webview/nav_manager.h> 00024 #include <core/threading/mutex.h> 00025 #include <core/threading/mutex_locker.h> 00026 #include <core/exception.h> 00027 00028 namespace fawkes { 00029 #if 0 /* just to make Emacs auto-indent happy */ 00030 } 00031 #endif 00032 00033 00034 /** @class WebNavManager <webview/nav_manager.h> 00035 * Manage visible navigation entries. 00036 * This class maintains a map from URLs to names, which are to be added to 00037 * the page navigation. 00038 * @author Tim Niemueller 00039 */ 00040 00041 /** Constructor. */ 00042 WebNavManager::WebNavManager() 00043 { 00044 __mutex = new Mutex(); 00045 } 00046 00047 00048 /** Destructor. */ 00049 WebNavManager::~WebNavManager() 00050 { 00051 delete __mutex; 00052 } 00053 00054 00055 /** Add a navigation entry. 00056 * @param baseurl URL for the navigation target 00057 * @param name name to display to the user 00058 * @exception Exception thrown if navigation entry already exists 00059 */ 00060 void 00061 WebNavManager::add_nav_entry(std::string baseurl, std::string name) 00062 { 00063 MutexLocker lock(__mutex); 00064 if (__nav_entries.find(baseurl) != __nav_entries.end()) { 00065 throw Exception("Navigation entry for %s has already been added", 00066 baseurl.c_str()); 00067 } 00068 __nav_entries[baseurl] = name; 00069 } 00070 00071 00072 /** Remove a navigation entry. 00073 * @param baseurl URL for which to remove the navigation entry. 00074 */ 00075 void 00076 WebNavManager::remove_nav_entry(std::string baseurl) 00077 { 00078 MutexLocker lock(__mutex); 00079 __nav_entries.erase(baseurl); 00080 } 00081 00082 } // end namespace fawkes