PGROUTING  2.6
trsp_driver.cpp File Reference
#include "drivers/trsp/trsp_driver.h"
#include <utility>
#include <vector>
#include <cstdint>
#include <sstream>
#include <algorithm>
#include "trsp/pgr_trspHandler.h"
#include "trsp/rule.h"
#include "cpp_common/pgr_assert.h"
#include "cpp_common/pgr_alloc.hpp"
Include dependency graph for trsp_driver.cpp:

Go to the source code of this file.

Functions

void do_trsp (pgr_edge_t *edges, size_t total_edges, Restriction_t *restrictions, size_t restrictions_size, int64_t *start_vidsArr, size_t size_start_vidsArr, int64_t *end_vidsArr, size_t size_end_vidsArr, bool directed, General_path_element_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

void do_trsp ( pgr_edge_t edges,
size_t  total_edges,
Restriction_t restrictions,
size_t  restrictions_size,
int64_t *  start_vidsArr,
size_t  size_start_vidsArr,
int64_t *  end_vidsArr,
size_t  size_end_vidsArr,
bool  directed,
General_path_element_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 41 of file trsp_driver.cpp.

References collapse_paths(), count_tuples(), pgassert, pgr_alloc(), pgr_free(), pgr_msg(), pgrouting::trsp::Pgr_trspHandler::process(), and AssertFailedException::what().

Referenced by compute_trsp().

60  {
61  std::ostringstream log;
62  std::ostringstream err;
63  std::ostringstream notice;
64  try {
65  pgassert(*return_tuples == NULL);
66  pgassert(*return_count == 0);
67  pgassert(*log_msg == NULL);
68  pgassert(*notice_msg == NULL);
69  pgassert(*err_msg == NULL);
70 
71 
72  std::vector<pgrouting::trsp::Rule> ruleList;
73  for (size_t i = 0; i < restrictions_size; ++i) {
74  ruleList.push_back(pgrouting::trsp::Rule(*(restrictions + i)));
75  }
76 
77  /*
78  * Inserting vertices into a c++ vector structure
79  */
80  std::vector<int64_t>
81  sources(start_vidsArr, start_vidsArr + size_start_vidsArr);
82  std::vector< int64_t >
83  targets(end_vidsArr, end_vidsArr + size_end_vidsArr);
84 
85  /*
86  * ordering and removing duplicates
87  */
88  std::sort(sources.begin(), sources.end());
89  sources.erase(
90  std::unique(sources.begin(), sources.end()),
91  sources.end());
92 
93  std::sort(targets.begin(), targets.end());
94  targets.erase(
95  std::unique(targets.begin(), targets.end()),
96  targets.end());
97 
98 
99 
101  edges,
102  total_edges,
103  directed,
104  ruleList);
105 
106  auto paths = gdef.process(
107  sources,
108  targets);
109 
110 
111  size_t count(0);
112  count = count_tuples(paths);
113 
114  if (count == 0) {
115  (*return_tuples) = NULL;
116  (*return_count) = 0;
117  return;
118  }
119 
120  (*return_tuples) = pgr_alloc(count, (*return_tuples));
121  (*return_count) = collapse_paths(return_tuples, paths);
122 
123 
124  return;
125  } catch (AssertFailedException &except) {
126  (*return_tuples) = pgr_free(*return_tuples);
127  (*return_count) = 0;
128  err << except.what();
129  *err_msg = pgr_msg(err.str().c_str());
130  *log_msg = pgr_msg(log.str().c_str());
131  } catch (std::exception &except) {
132  (*return_tuples) = pgr_free(*return_tuples);
133  (*return_count) = 0;
134  err << except.what();
135  *err_msg = pgr_msg(err.str().c_str());
136  *log_msg = pgr_msg(log.str().c_str());
137  } catch(...) {
138  (*return_tuples) = pgr_free(*return_tuples);
139  (*return_count) = 0;
140  err << "Caught unknown exception!";
141  *err_msg = pgr_msg(err.str().c_str());
142  *log_msg = pgr_msg(log.str().c_str());
143  }
144 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
size_t collapse_paths(General_path_element_t **ret_path, const std::deque< Path > &paths)
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
size_t count_tuples(const std::deque< Path > &paths)
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
virtual const char * what() const
Definition: pgr_assert.cpp:53

Here is the call graph for this function:

Here is the caller graph for this function: