alaCarte Maps
Renderer for OpenStreetMap tiles
job.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef JOB_HPP
23 #define JOB_HPP
24 
25 #include "settings.hpp"
26 
28 #include "utils/statistic.hpp"
29 
30 class MetaIdentifier;
31 class Tile;
32 class RequestManager;
33 class Configuration;
34 class Stylesheet;
35 class HttpRequest;
36 class RenderCanvas;
37 
41 class Job
42 {
43 public:
44  Job(const shared_ptr<MetaIdentifier>& mid,
45  const shared_ptr<Configuration>& config,
46  const shared_ptr<RequestManager>& manager,
47  const shared_ptr<RenderCanvas>& canvas);
48 
49  void process();
50  void deliver();
51  void addRequest(const shared_ptr<HttpRequest>& req, const shared_ptr<TileIdentifier>& id)
52  {
53  requests[*id].push_back(req);
54  }
55  bool isEmpty() { return empty; }
56  const shared_ptr<MetaIdentifier>& getIdentifier() { return mid; }
57 
58 private:
59  TESTABLE shared_ptr<Tile> computeEmpty();
60  TESTABLE FixedRect computeRect(const shared_ptr<TileIdentifier>& ti);
61  TESTABLE FixedRect computeRect(const shared_ptr<MetaIdentifier>& ti);
62  bool initTiles();
63 
64 private:
66  shared_ptr<RequestManager> manager;
68  shared_ptr<RenderCanvas> canvas;
69  shared_ptr<Configuration> config;
70  shared_ptr<MetaIdentifier> mid;
71  bool empty;
72  bool cached;
74  std::vector<shared_ptr<Tile>> tiles;
75  boost::unordered_map<TileIdentifier, std::list<shared_ptr<HttpRequest>>> requests;
76 
78  shared_ptr<Statistic::JobMeasurement> measurement;
79 };
80 
81 #endif
const shared_ptr< MetaIdentifier > & getIdentifier()
Definition: job.hpp:56
void addRequest(const shared_ptr< HttpRequest > &req, const shared_ptr< TileIdentifier > &id)
Definition: job.hpp:51
shared_ptr< Statistic::JobMeasurement > measurement
used to generate statistics
Definition: job.hpp:78
void deliver()
Definition: job.cpp:205
std::vector< shared_ptr< Tile > > tiles
initialized by initTiles
Definition: job.hpp:74
Definition: tile.hpp:30
A Stylesheet parses a given MapCSS Stylesheet file and stores the defined rules.
Definition: stylesheet.hpp:39
TESTABLE FixedRect computeRect(const shared_ptr< TileIdentifier > &ti)
Computes an rectangle for the given TileIdentifier.
Definition: job.cpp:68
shared_ptr< RenderCanvas > canvas
supplied by worker thread
Definition: job.hpp:68
boost::unordered_map< TileIdentifier, std::list< shared_ptr< HttpRequest > > > requests
Definition: job.hpp:75
Abstract Class which computes Tiles by a given TileIdentifier.
Definition: job.hpp:41
TESTABLE shared_ptr< Tile > computeEmpty()
Computes an empty Tile.
Definition: job.cpp:113
A MetaIdentifier identifies a set of Tiles that a rendered together.
shared_ptr< MetaIdentifier > mid
Definition: job.hpp:70
Represents a set of options accessible via strings.
void process()
Computes a all tiles contained in the MetaIdentifier.
Definition: job.cpp:156
#define TESTABLE
Definition: settings.hpp:85
shared_ptr< Configuration > config
Definition: job.hpp:69
bool empty
Definition: job.hpp:71
shared_ptr< RequestManager > manager
RequestManager which holds all important components.
Definition: job.hpp:66
bool isEmpty()
Definition: job.hpp:55
bool cached
Definition: job.hpp:72
Job(const shared_ptr< MetaIdentifier > &mid, const shared_ptr< Configuration > &config, const shared_ptr< RequestManager > &manager, const shared_ptr< RenderCanvas > &canvas)
Creates a new Job and sets the RequestManager.
Definition: job.cpp:51
bool initTiles()
Inits the internal list of tiles that are part of the MetaTile.
Definition: job.cpp:139