alaCarte Maps
Renderer for OpenStreetMap tiles
StylesheetManager Class Reference

The StylesheetManager provides an interface to get arbitrary Stylesheets from the stylesheet directory. More...

#include <stylesheet_manager.hpp>

Inheritance diagram for StylesheetManager:

Public Member Functions

 StylesheetManager (const shared_ptr< Configuration > &config)
 Creates a new StylesheetManager with the given Configuration. More...
 
TESTABLE void startStylesheetObserving (const shared_ptr< RequestManager > &manager)
 starts observing the Stylesheet directory. More...
 
TESTABLE void stopStylesheetObserving ()
 Stops the folder observation. More...
 
TESTABLE shared_ptr< StylesheetgetStylesheet (const string &path)
 Returns the Stylesheet Object for the Stylesheet specified. More...
 
TESTABLE bool hasStylesheet (const string &path)
 

Private Member Functions

TESTABLE void onNewStylesheet (const fs::path &stylesheet_path)
 tries to read and parse the given file. More...
 
TESTABLE void onRemovedStylesheet (const fs::path &stylesheet_path)
 removes the Stylesheet from the Stylesheet Cache and the prerendered tiles from the Cache. More...
 
TESTABLE void onFileSystemEvent (const boost::system::error_code &ec, const boost::asio::dir_monitor_event &ev)
 handler method for dirwatch, forwards only .mapcss files to onNewStylesheet and onRemovedStylesheet More...
 

Static Private Member Functions

static shared_ptr< StylesheetmakeFallbackStylesheet (const shared_ptr< Geodata > &geodata)
 

Private Attributes

shared_ptr< Configurationconfig
 
weak_ptr< RequestManagermanager
 
boost::shared_mutex stylesheetsLock
 
boost::unordered_map< fs::path, shared_ptr< Stylesheet > > parsedStylesheets
 
fs::path stylesheetFolder
 
boost::asio::io_service ioService
 
boost::thread monitorThread
 
boost::scoped_ptr< boost::asio::dir_monitor > monitorService
 

Detailed Description

The StylesheetManager provides an interface to get arbitrary Stylesheets from the stylesheet directory.

Additionally, it observes the stylesheet directory for changes to prerender new stylesheets, and drop deleted ones off the Cache.

Definition at line 45 of file stylesheet_manager.hpp.

Constructor & Destructor Documentation

StylesheetManager::StylesheetManager ( const shared_ptr< Configuration > &  config)

Creates a new StylesheetManager with the given Configuration.

This file is part of alaCarte.

Parameters
configthe Configuration object to read the stylesheet directory path and prerender level from

alaCarte is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

alaCarte is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with alaCarte. If not, see http://www.gnu.org/licenses/.

Copyright alaCarte 2012-2013 Simon Dreher, Florian Jacob, Tobias Kahlert, Patrick Niklaus, Bernhard Scheirle, Lisa Winter Maintainer: Florian Jacob

Definition at line 38 of file stylesheet_manager.cpp.

Member Function Documentation

shared_ptr< Stylesheet > StylesheetManager::getStylesheet ( const string path)

Returns the Stylesheet Object for the Stylesheet specified.

Parameters
pathpath of the stylesheet
Returns
the Stylesheet specified or the default Stylesheet

Definition at line 83 of file stylesheet_manager.cpp.

bool StylesheetManager::hasStylesheet ( const string path)

Definition at line 73 of file stylesheet_manager.cpp.

shared_ptr< Stylesheet > StylesheetManager::makeFallbackStylesheet ( const shared_ptr< Geodata > &  geodata)
staticprivate

Definition at line 215 of file stylesheet_manager.cpp.

void StylesheetManager::onFileSystemEvent ( const boost::system::error_code &  ec,
const boost::asio::dir_monitor_event &  ev 
)
private

handler method for dirwatch, forwards only .mapcss files to onNewStylesheet and onRemovedStylesheet

Definition at line 161 of file stylesheet_manager.cpp.

void StylesheetManager::onNewStylesheet ( const fs::path &  stylesheet_path)
private

tries to read and parse the given file.

If that succeeds, saves it in the Stylesheet Cache and enqueues it for prerendering.

Definition at line 100 of file stylesheet_manager.cpp.

void StylesheetManager::onRemovedStylesheet ( const fs::path &  stylesheet_path)
private

removes the Stylesheet from the Stylesheet Cache and the prerendered tiles from the Cache.

Definition at line 150 of file stylesheet_manager.cpp.

void StylesheetManager::startStylesheetObserving ( const shared_ptr< RequestManager > &  manager)

starts observing the Stylesheet directory.

On new or changed stylesheet files, the Tiles to prerender get enqueued in the RequestManager. On changed or deleted stylesheet files, the Cache gets notified to drop the cached Tiles.

Parameters
managerthe RequestManager to use to enqueue new Tiles to prerender

Definition at line 46 of file stylesheet_manager.cpp.

void StylesheetManager::stopStylesheetObserving ( )

Stops the folder observation.

Stops the internal mechanism, which is used to watch the stylesheet folder.

Definition at line 67 of file stylesheet_manager.cpp.

Member Data Documentation

shared_ptr<Configuration> StylesheetManager::config
private

Definition at line 100 of file stylesheet_manager.hpp.

boost::asio::io_service StylesheetManager::ioService
private

Definition at line 110 of file stylesheet_manager.hpp.

weak_ptr<RequestManager> StylesheetManager::manager
private

Definition at line 101 of file stylesheet_manager.hpp.

boost::scoped_ptr<boost::asio::dir_monitor> StylesheetManager::monitorService
private

Definition at line 112 of file stylesheet_manager.hpp.

boost::thread StylesheetManager::monitorThread
private

Definition at line 111 of file stylesheet_manager.hpp.

boost::unordered_map<fs::path, shared_ptr<Stylesheet> > StylesheetManager::parsedStylesheets
private

Definition at line 104 of file stylesheet_manager.hpp.

fs::path StylesheetManager::stylesheetFolder
private

Definition at line 106 of file stylesheet_manager.hpp.

boost::shared_mutex StylesheetManager::stylesheetsLock
private

Definition at line 103 of file stylesheet_manager.hpp.


The documentation for this class was generated from the following files: