Switched to std::shared_ptr in Contractor/
This commit is contained in:
parent
d13cd4d4b3
commit
5265f38c35
@ -41,8 +41,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/lambda/lambda.hpp>
|
#include <boost/lambda/lambda.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@ -234,7 +232,7 @@ class Contractor
|
|||||||
std::cout << "merged " << edges.size() - edge << " edges out of " << edges.size()
|
std::cout << "merged " << edges.size() - edge << " edges out of " << edges.size()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
edges.resize(edge);
|
edges.resize(edge);
|
||||||
_graph = boost::make_shared<_DynamicGraph>(nodes, edges);
|
_graph = std::make_shared<_DynamicGraph>(nodes, edges);
|
||||||
edges.clear();
|
edges.clear();
|
||||||
std::vector<_ContractorEdge>().swap(edges);
|
std::vector<_ContractorEdge>().swap(edges);
|
||||||
BOOST_ASSERT(0 == edges.capacity());
|
BOOST_ASSERT(0 == edges.capacity());
|
||||||
@ -396,7 +394,7 @@ class Contractor
|
|||||||
|
|
||||||
// create new graph
|
// create new graph
|
||||||
std::sort(newSetOfEdges.begin(), newSetOfEdges.end());
|
std::sort(newSetOfEdges.begin(), newSetOfEdges.end());
|
||||||
_graph = boost::make_shared<_DynamicGraph>(remainingNodes.size(), newSetOfEdges);
|
_graph = std::make_shared<_DynamicGraph>(remainingNodes.size(), newSetOfEdges);
|
||||||
|
|
||||||
newSetOfEdges.clear();
|
newSetOfEdges.clear();
|
||||||
flushedContractor = true;
|
flushedContractor = true;
|
||||||
@ -939,7 +937,7 @@ class Contractor
|
|||||||
return a < b;
|
return a < b;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<_DynamicGraph> _graph;
|
std::shared_ptr<_DynamicGraph> _graph;
|
||||||
std::vector<_DynamicGraph::InputEdge> contractedEdges;
|
std::vector<_DynamicGraph::InputEdge> contractedEdges;
|
||||||
unsigned edge_storage_slot;
|
unsigned edge_storage_slot;
|
||||||
uint64_t temp_edge_counter;
|
uint64_t temp_edge_counter;
|
||||||
|
@ -31,14 +31,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
|
|
||||||
EdgeBasedGraphFactory::EdgeBasedGraphFactory(
|
EdgeBasedGraphFactory::EdgeBasedGraphFactory(
|
||||||
const boost::shared_ptr<NodeBasedDynamicGraph> &node_based_graph,
|
const std::shared_ptr<NodeBasedDynamicGraph> &node_based_graph,
|
||||||
std::unique_ptr<RestrictionMap> restriction_map,
|
std::unique_ptr<RestrictionMap> restriction_map,
|
||||||
std::vector<NodeID> &barrier_node_list,
|
std::vector<NodeID> &barrier_node_list,
|
||||||
std::vector<NodeID> &traffic_light_node_list,
|
std::vector<NodeID> &traffic_light_node_list,
|
||||||
|
@ -49,7 +49,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "GeometryCompressor.h"
|
#include "GeometryCompressor.h"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
|
|
||||||
@ -63,7 +62,7 @@ class EdgeBasedGraphFactory : boost::noncopyable
|
|||||||
public:
|
public:
|
||||||
struct SpeedProfileProperties;
|
struct SpeedProfileProperties;
|
||||||
|
|
||||||
explicit EdgeBasedGraphFactory(const boost::shared_ptr<NodeBasedDynamicGraph> &node_based_graph,
|
explicit EdgeBasedGraphFactory(const std::shared_ptr<NodeBasedDynamicGraph> &node_based_graph,
|
||||||
std::unique_ptr<RestrictionMap> restricion_map,
|
std::unique_ptr<RestrictionMap> restricion_map,
|
||||||
std::vector<NodeID> &barrier_node_list,
|
std::vector<NodeID> &barrier_node_list,
|
||||||
std::vector<NodeID> &traffic_light_node_list,
|
std::vector<NodeID> &traffic_light_node_list,
|
||||||
@ -107,7 +106,7 @@ class EdgeBasedGraphFactory : boost::noncopyable
|
|||||||
std::vector<EdgeBasedNode> m_edge_based_node_list;
|
std::vector<EdgeBasedNode> m_edge_based_node_list;
|
||||||
DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
|
DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
|
||||||
|
|
||||||
boost::shared_ptr<NodeBasedDynamicGraph> m_node_based_graph;
|
std::shared_ptr<NodeBasedDynamicGraph> m_node_based_graph;
|
||||||
boost::unordered_set<NodeID> m_barrier_nodes;
|
boost::unordered_set<NodeID> m_barrier_nodes;
|
||||||
boost::unordered_set<NodeID> m_traffic_lights;
|
boost::unordered_set<NodeID> m_traffic_lights;
|
||||||
|
|
||||||
|
@ -36,8 +36,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -84,8 +82,8 @@ class TemporaryStorage
|
|||||||
{
|
{
|
||||||
bool write_mode;
|
bool write_mode;
|
||||||
boost::filesystem::path temp_path;
|
boost::filesystem::path temp_path;
|
||||||
boost::shared_ptr<boost::filesystem::fstream> temp_file;
|
std::shared_ptr<boost::filesystem::fstream> temp_file;
|
||||||
boost::shared_ptr<boost::mutex> readWriteMutex;
|
std::shared_ptr<boost::mutex> readWriteMutex;
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
|
|
||||||
StreamData()
|
StreamData()
|
||||||
@ -93,7 +91,7 @@ class TemporaryStorage
|
|||||||
TemporaryFilePattern.begin(), TemporaryFilePattern.end()))),
|
TemporaryFilePattern.begin(), TemporaryFilePattern.end()))),
|
||||||
temp_file(new boost::filesystem::fstream(
|
temp_file(new boost::filesystem::fstream(
|
||||||
temp_path, std::ios::in | std::ios::out | std::ios::trunc | std::ios::binary)),
|
temp_path, std::ios::in | std::ios::out | std::ios::trunc | std::ios::binary)),
|
||||||
readWriteMutex(boost::make_shared<boost::mutex>())
|
readWriteMutex(std::make_shared<boost::mutex>())
|
||||||
{
|
{
|
||||||
if (temp_file->fail())
|
if (temp_file->fail())
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,6 @@
|
|||||||
#include "DynamicGraph.h"
|
#include "DynamicGraph.h"
|
||||||
#include "ImportEdge.h"
|
#include "ImportEdge.h"
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
#include <boost/make_shared.hpp>
|
|
||||||
|
|
||||||
struct NodeBasedEdgeData {
|
struct NodeBasedEdgeData {
|
||||||
NodeBasedEdgeData() : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), nameID(std::numeric_limits<unsigned>::max()),
|
NodeBasedEdgeData() : distance(INVALID_EDGE_WEIGHT), edgeBasedNodeID(SPECIAL_NODEID), nameID(std::numeric_limits<unsigned>::max()),
|
||||||
type(std::numeric_limits<short>::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false),
|
type(std::numeric_limits<short>::max()), isAccessRestricted(false), shortcut(false), forward(false), backward(false),
|
||||||
@ -43,7 +40,7 @@ struct NodeBasedEdgeData {
|
|||||||
typedef DynamicGraph<NodeBasedEdgeData> NodeBasedDynamicGraph;
|
typedef DynamicGraph<NodeBasedEdgeData> NodeBasedDynamicGraph;
|
||||||
|
|
||||||
// Factory method to create NodeBasedDynamicGraph from ImportEdges
|
// Factory method to create NodeBasedDynamicGraph from ImportEdges
|
||||||
inline boost::shared_ptr<NodeBasedDynamicGraph> NodeBasedDynamicGraphFromImportEdges(
|
inline std::shared_ptr<NodeBasedDynamicGraph> NodeBasedDynamicGraphFromImportEdges(
|
||||||
int number_of_nodes,
|
int number_of_nodes,
|
||||||
std::vector<ImportEdge>& input_edge_list
|
std::vector<ImportEdge>& input_edge_list
|
||||||
) {
|
) {
|
||||||
@ -92,7 +89,7 @@ inline boost::shared_ptr<NodeBasedDynamicGraph> NodeBasedDynamicGraphFromImportE
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::sort( edges_list.begin(), edges_list.end() );
|
std::sort( edges_list.begin(), edges_list.end() );
|
||||||
auto graph = boost::make_shared<NodeBasedDynamicGraph>(
|
auto graph = std::make_shared<NodeBasedDynamicGraph>(
|
||||||
number_of_nodes,
|
number_of_nodes,
|
||||||
edges_list
|
edges_list
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "RestrictionMap.h"
|
#include "RestrictionMap.h"
|
||||||
#include "NodeBasedGraph.h"
|
#include "NodeBasedGraph.h"
|
||||||
|
|
||||||
RestrictionMap::RestrictionMap(const boost::shared_ptr<NodeBasedDynamicGraph>& graph, const std::vector<TurnRestriction> & input_restrictions_list)
|
RestrictionMap::RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph>& graph, const std::vector<TurnRestriction> & input_restrictions_list)
|
||||||
: m_count(0)
|
: m_count(0)
|
||||||
, m_graph(graph)
|
, m_graph(graph)
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef __RESTRICTION_MAP_H__
|
#ifndef __RESTRICTION_MAP_H__
|
||||||
#define __RESTRICTION_MAP_H__
|
#define __RESTRICTION_MAP_H__
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "../typedefs.h"
|
#include "../typedefs.h"
|
||||||
#include "DynamicGraph.h"
|
#include "DynamicGraph.h"
|
||||||
#include "Restriction.h"
|
#include "Restriction.h"
|
||||||
@ -42,7 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
class RestrictionMap
|
class RestrictionMap
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RestrictionMap(const boost::shared_ptr<NodeBasedDynamicGraph>& graph,
|
RestrictionMap(const std::shared_ptr<NodeBasedDynamicGraph>& graph,
|
||||||
const std::vector<TurnRestriction> & input_restrictions_list);
|
const std::vector<TurnRestriction> & input_restrictions_list);
|
||||||
|
|
||||||
void FixupArrivingTurnRestriction(const NodeID u, const NodeID v, const NodeID w);
|
void FixupArrivingTurnRestriction(const NodeID u, const NodeID v, const NodeID w);
|
||||||
@ -59,7 +61,7 @@ private:
|
|||||||
typedef NodeBasedDynamicGraph::EdgeData EdgeData;
|
typedef NodeBasedDynamicGraph::EdgeData EdgeData;
|
||||||
|
|
||||||
unsigned m_count;
|
unsigned m_count;
|
||||||
boost::shared_ptr<NodeBasedDynamicGraph> m_graph;
|
std::shared_ptr<NodeBasedDynamicGraph> m_graph;
|
||||||
//! index -> list of (target, isOnly)
|
//! index -> list of (target, isOnly)
|
||||||
std::vector<EmanatingRestrictionsVector> m_restriction_bucket_list;
|
std::vector<EmanatingRestrictionsVector> m_restriction_bucket_list;
|
||||||
//! maps (start, via) -> bucket index
|
//! maps (start, via) -> bucket index
|
||||||
|
@ -49,7 +49,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <luabind/luabind.hpp>
|
#include <luabind/luabind.hpp>
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -275,7 +274,7 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SimpleLogger().Write() << "Generating edge-expanded graph representation";
|
SimpleLogger().Write() << "Generating edge-expanded graph representation";
|
||||||
boost::shared_ptr<NodeBasedDynamicGraph> node_based_graph = NodeBasedDynamicGraphFromImportEdges(number_of_node_based_nodes, edge_list);
|
std::shared_ptr<NodeBasedDynamicGraph> node_based_graph = NodeBasedDynamicGraphFromImportEdges(number_of_node_based_nodes, edge_list);
|
||||||
std::unique_ptr<RestrictionMap> restriction_map = std::unique_ptr<RestrictionMap>(new RestrictionMap(node_based_graph, restriction_list));
|
std::unique_ptr<RestrictionMap> restriction_map = std::unique_ptr<RestrictionMap>(new RestrictionMap(node_based_graph, restriction_list));
|
||||||
EdgeBasedGraphFactory * edge_based_graph_factor =
|
EdgeBasedGraphFactory * edge_based_graph_factor =
|
||||||
new EdgeBasedGraphFactory(node_based_graph,
|
new EdgeBasedGraphFactory(node_based_graph,
|
||||||
|
Loading…
Reference in New Issue
Block a user