2016-01-07 13:19:55 -05:00
|
|
|
#ifndef ENGINE_HPP
|
|
|
|
#define ENGINE_HPP
|
2013-12-13 12:32:24 -05:00
|
|
|
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "contractor/query_edge.hpp"
|
2013-12-13 12:32:24 -05:00
|
|
|
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "osrm/json_container.hpp"
|
|
|
|
#include "osrm/osrm.hpp"
|
2015-01-08 08:49:10 -05:00
|
|
|
|
2014-10-08 13:30:42 -04:00
|
|
|
#include <memory>
|
2014-05-09 12:40:07 -04:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <string>
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
namespace storage
|
|
|
|
{
|
|
|
|
struct SharedBarriers;
|
|
|
|
}
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace util
|
|
|
|
{
|
|
|
|
namespace json
|
|
|
|
{
|
|
|
|
struct Object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace engine
|
|
|
|
{
|
2016-01-07 13:19:55 -05:00
|
|
|
struct EngineConfig;
|
2016-01-05 10:51:13 -05:00
|
|
|
struct RouteParameters;
|
|
|
|
namespace plugins
|
|
|
|
{
|
|
|
|
class BasePlugin;
|
|
|
|
}
|
|
|
|
namespace datafacade
|
|
|
|
{
|
2014-05-07 10:17:14 -04:00
|
|
|
template <class EdgeDataT> class BaseDataFacade;
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
2014-02-11 05:35:29 -05:00
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
class Engine final
|
2014-05-07 10:17:14 -04:00
|
|
|
{
|
|
|
|
private:
|
2016-01-05 10:51:13 -05:00
|
|
|
using PluginMap = std::unordered_map<std::string, std::unique_ptr<plugins::BasePlugin>>;
|
2014-05-07 10:17:14 -04:00
|
|
|
|
|
|
|
public:
|
2016-01-07 13:19:55 -05:00
|
|
|
Engine(EngineConfig &config_);
|
Takes care of proper special member generation globally, fixes #1689
Phew, a lot of classes were affected by this. The rationale for the
changes are as follows:
- When a type X declares any constructor, the default constructor is
not declared, so there is no need for X() = delete there. In fact,
there is brutal difference between those two: deleted members
participate in overload resolution, but not-declared members do not!
- When a type X wants to be non-copyable (e.g. to be only movable, like
threads, unique_ptrs, and so on), you can either do it by inheriting
from boost::noncopyable (the old way), or better declare both (!) the
copy constructor _and_ the copy assignment operator as deleted:
X(X const&) = delete;
X& operator=(X const&) = delete;
We had tons of types with deleted copy constructors that were lacking
a corresponding deleted copy assignment operator, making them still
copyable and you wouldn't even notice (read: scary)!
References:
- http://accu.org/content/conf2014/Howard_Hinnant_Accu_2014.pdf
- http://www.boost.org/doc/libs/master/libs/core/doc/html/core/noncopyable.html
Note: I know, I'm quoting Hinnant's extraordinary slides a lot, but
getting the sematic right here is so incredibly important.
2016-01-27 05:20:55 -05:00
|
|
|
|
2016-01-07 13:19:55 -05:00
|
|
|
Engine(const Engine &) = delete;
|
Takes care of proper special member generation globally, fixes #1689
Phew, a lot of classes were affected by this. The rationale for the
changes are as follows:
- When a type X declares any constructor, the default constructor is
not declared, so there is no need for X() = delete there. In fact,
there is brutal difference between those two: deleted members
participate in overload resolution, but not-declared members do not!
- When a type X wants to be non-copyable (e.g. to be only movable, like
threads, unique_ptrs, and so on), you can either do it by inheriting
from boost::noncopyable (the old way), or better declare both (!) the
copy constructor _and_ the copy assignment operator as deleted:
X(X const&) = delete;
X& operator=(X const&) = delete;
We had tons of types with deleted copy constructors that were lacking
a corresponding deleted copy assignment operator, making them still
copyable and you wouldn't even notice (read: scary)!
References:
- http://accu.org/content/conf2014/Howard_Hinnant_Accu_2014.pdf
- http://www.boost.org/doc/libs/master/libs/core/doc/html/core/noncopyable.html
Note: I know, I'm quoting Hinnant's extraordinary slides a lot, but
getting the sematic right here is so incredibly important.
2016-01-27 05:20:55 -05:00
|
|
|
Engine &operator=(const Engine &) = delete;
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
2013-12-13 12:32:24 -05:00
|
|
|
|
2014-05-07 10:17:14 -04:00
|
|
|
private:
|
2016-01-05 10:51:13 -05:00
|
|
|
void RegisterPlugin(plugins::BasePlugin *plugin);
|
2013-12-13 12:32:24 -05:00
|
|
|
PluginMap plugin_map;
|
2014-10-08 13:30:42 -04:00
|
|
|
// will only be initialized if shared memory is used
|
2016-01-07 13:19:55 -05:00
|
|
|
std::unique_ptr<storage::SharedBarriers> barrier;
|
2014-05-07 10:17:14 -04:00
|
|
|
// base class pointer to the objects
|
2016-01-05 10:51:13 -05:00
|
|
|
datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData> *query_data_facade;
|
2015-01-22 06:35:46 -05:00
|
|
|
|
|
|
|
// decrease number of concurrent queries
|
|
|
|
void decrease_concurrent_query_count();
|
|
|
|
// increase number of concurrent queries
|
|
|
|
void increase_concurrent_query_count();
|
2013-12-13 12:32:24 -05:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
2013-12-13 12:32:24 -05:00
|
|
|
|
2015-01-27 10:35:19 -05:00
|
|
|
#endif // OSRM_IMPL_HPP
|