Skip to content
New issue

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

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

Already on GitHub? # to your account

Documentation of functions added #11

Merged
merged 1 commit into from
May 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/h/base_DB.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,49 @@
#include <libpq-fe.h>
#include <cstring>


/*!
* \brief Establishes a connection to the database.
* \param user : The username for the databse.
* \param password : The password for the database.
*
* \return A pointer to the connection object.
*/
PGconn* DB_connection(const char* user, const char* password);

/*!
* \brief Checks if a drone exists in the database.
* \param conn : The database connection.
* \param dic : The drone identifier code.
*
* \return True if the drone exists, false otherwise.
*/
bool checkDic(PGconn* conn, const char* dic);

/*!
* \brief Inserts a new route into the database.
* \param conn : The database connection.
* \param dic : The drone identification code.
* \param auth_code : The authentication code for the drone.
* \param route : The route to insert. The route should be a string with the format: "[[x0,y0],[x1,y1],...]".
*/
void insertRoute(PGconn* conn, const char* dic, const char* auth_code, const char* route);

/*!
* \brief Cheks if the authorization code for a drone is valid.
* \param dic : The drone identifier code.
* \param authCode : The authentication code to check.
*
* \return True if the authentication code is correct, false otherwise.
*/
bool checkAuthCode(PGconn* conn, const char* dic, const char* authCode);

/*!
* \brief Checks for collisions on a given route.
* \param dic : The drone identifier code.
* \param route : The route to check for collisions. The route should be a string with the format: "[[x0,y0],[x1,y1],...]".
*
* \return The number of potential collisions on the route
*/
int checkColissions(PGconn* conn, const char* dic, const char* route);

#endif
Loading