Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use C++ template to get the data from postgres #2494

Closed
cvvergara opened this issue Mar 21, 2023 · 0 comments
Closed

Use C++ template to get the data from postgres #2494

cvvergara opened this issue Mar 21, 2023 · 0 comments
Assignees
Labels
Milestone

Comments

@cvvergara
Copy link
Member

cvvergara commented Mar 21, 2023

During these last 10 years, work has been done to standardize the code.
These efforts are now at a point where because of this standarization there is duplicated code:
In particular for this issue:

is code that is very similar (aka standardized).
Imagine:
Instead of defining Column_info_t info[3]; ...etc within the function, is passed as parameter

Then visualize the rest of the code:
the algorithm is the same, things that change is the fetch function that that is called.

More of the imagination:
Instead of defining the fetch function, it is passed as parameter

The result is a C++ template:

template <typename Data_ptr, typename Func>
void get_data(
         char *sql,
        Data_ptr **pgtuples,
        size_t *total_pgtuples,
        bool normal,
        std::vector<Column_info_t> &info,
        Func func)

A call to the function would look like: (after filling up info variable)

pgrouting::get_data(sql, delauny, total_delauny, true, info, &fetch_delauny);
pgrouting::get_data(edges_sql, edges, total_edges, true, info, &fetch_costFlow_edge);

This will:

  • Reduce the code base size
  • have more code compiled with C++ (even when linked as C)

There might be some more places where template can be used, but is not related with this particular issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants