Tidied up code, going to put up the coding convention later on

This commit is contained in:
amazing-username
2019-09-04 15:41:43 +00:00
parent dd995269df
commit d4e9b8c71f
73 changed files with 1334 additions and 1368 deletions
+34
View File
@@ -0,0 +1,34 @@
#ifndef ALBUMREPOSITORY_H_
#define ALBUMREPOSITORY_H_
#include <vector>
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/AlbumFilter.h"
namespace database
{
class AlbumRepository : public BaseRepository
{
public:
AlbumRepository(const model::BinaryPath&);
std::vector<model::Album> retrieveRecords();
model::Album retrieveRecord(model::Album&, type::AlbumFilter);
bool doesAlbumExists(const model::Album&, type::AlbumFilter);
void saveAlbum(const model::Album&);
private:
std::vector<model::Album> parseRecords(MYSQL_RES*);
// TODO: after parseRecord(MYSQL_STMT*) is implemented remove
// parseRecord(MYSQL_RES*)
model::Album parseRecord(MYSQL_RES*);
model::Album parseRecord(MYSQL_STMT*);
};
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef ARTISTREPOSITORY_H_
#define ARTISTREPOSITORY_H_
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/ArtistFilter.h"
namespace database
{
class ArtistRepository : public BaseRepository
{
public:
ArtistRepository(const model::BinaryPath&);
model::Artist retrieveRecord(model::Artist&, type::ArtistFilter);
bool doesArtistExist(const model::Artist&, type::ArtistFilter);
void saveRecord(const model::Artist&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Artist parseRecord(MYSQL_RES*);
model::Artist parseRecord(MYSQL_STMT*);
};
}
#endif
+34
View File
@@ -0,0 +1,34 @@
#ifndef BASE_REPOSITORY_H_
#define BASE_REPOSITORY_H_
#include <string>
#include <mysql/mysql.h>
#include "model/Models.h"
namespace database
{
class BaseRepository
{
public:
BaseRepository();
BaseRepository(const std::string&);
BaseRepository(const model::BinaryPath&);
protected:
MYSQL* setupMysqlConnection();
MYSQL* setupMysqlConnection(model::DatabaseConnection);
MYSQL_RES* performMysqlQuery(MYSQL*, const std::string&);
model::DatabaseConnection details;
private:
void intitalizeDetails();
void initializeDetails(const model::BinaryPath&);
std::string path;
model::BinaryPath m_binConf;
};
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#ifndef COVERARTREPOSITORY_H_
#define COVERARTREPOSITORY_H_
#include <mysql/mysql.h>
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/CoverFilter.h"
namespace database
{
class CoverArtRepository : public BaseRepository
{
public:
CoverArtRepository(const std::string&);
CoverArtRepository(const model::BinaryPath&);
model::Cover retrieveRecord(model::Cover&, type::CoverFilter);
bool doesCoverArtExist(const model::Cover&, type::CoverFilter);
void deleteRecord(const model::Cover&);
void saveRecord(const model::Cover&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Cover parseRecord(MYSQL_RES*);
model::Cover parseRecord(MYSQL_STMT*);
};
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef GENREREPOSITORY_H_
#define GENREREPOSITORY_H_
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/GenreFilter.h"
namespace database
{
class GenreRepository : public BaseRepository
{
public:
GenreRepository(const model::BinaryPath&);
model::Genre retrieveRecord(model::Genre&, type::GenreFilter);
bool doesGenreExist(const model::Genre&, type::GenreFilter);
void saveRecord(const model::Genre&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Genre parseRecord(MYSQL_RES*);
model::Genre parseRecord(MYSQL_STMT*);
};
}
#endif
+38
View File
@@ -0,0 +1,38 @@
#ifndef SONGREPOSITORY_H_
#define SONGREPOSITORY_H_
#include <memory>
#include <vector>
#include <mysql/mysql.h>
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/SongFilter.h"
namespace database
{
class SongRepository : public BaseRepository
{
public:
SongRepository(const std::string&);
SongRepository(const model::BinaryPath&);
std::vector<model::Song> retrieveRecords();
bool doesSongExist(const model::Song&, type::SongFilter);
model::Song retrieveRecord(model::Song&, type::SongFilter);
void deleteRecord(const model::Song&);
void saveRecord(const model::Song&);
private:
std::vector<model::Song> parseRecords(MYSQL_RES*); // TODO: to be removed
std::vector<model::Song> parseRecords(MYSQL_STMT*);
model::Song parseRecord(MYSQL_RES*); // TODO: to be removed
model::Song parseRecord(MYSQL_STMT*);
};
}
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef YEARREPOSITORY_H_
#define YEARREPOSITORY_H_
#include "database/BaseRepository.h"
#include "model/Models.h"
#include "type/YearFilter.h"
namespace database
{
class YearRepository : public BaseRepository
{
public:
YearRepository(const model::BinaryPath&);
model::Year retrieveRecord(model::Year&, type::YearFilter);
bool doesYearExist(const model::Year&, type::YearFilter);
void saveRecord(const model::Year&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
model::Year parseRecord(MYSQL_RES*);
model::Year parseRecord(MYSQL_STMT*);
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef ALBUMREPOSITORY_H_
#define ALBUMREPOSITORY_H_
#include <vector>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/albumFilter.h"
namespace Database
{
class albumRepository : public base_repository
{
public:
albumRepository(const Model::BinaryPath&);
std::vector<Model::Album> retrieveRecords();
Model::Album retrieveRecord(Model::Album&, Type::albumFilter);
bool doesAlbumExists(const Model::Album&, Type::albumFilter);
void saveAlbum(const Model::Album&);
private:
std::vector<Model::Album> parseRecords(MYSQL_RES*);
// TODO: after parseRecord(MYSQL_STMT*) is implemented remove
// parseRecord(MYSQL_RES*)
Model::Album parseRecord(MYSQL_RES*);
Model::Album parseRecord(MYSQL_STMT*);
};
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef ARTISTREPOSITORY_H_
#define ARTISTREPOSITORY_H_
#include "database/base_repository.h"
#include "models/models.h"
#include "types/artistFilter.h"
namespace Database
{
class artistRepository : public base_repository
{
public:
artistRepository(const Model::BinaryPath&);
Model::Artist retrieveRecord(Model::Artist&, Type::artistFilter);
bool doesArtistExist(const Model::Artist&, Type::artistFilter);
void saveRecord(const Model::Artist&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Artist parseRecord(MYSQL_RES*);
Model::Artist parseRecord(MYSQL_STMT*);
};
}
#endif
-34
View File
@@ -1,34 +0,0 @@
#ifndef BASE_REPOSITORY_H_
#define BASE_REPOSITORY_H_
#include <string>
#include <mysql/mysql.h>
#include "models/models.h"
namespace Database
{
class base_repository
{
public:
base_repository();
base_repository(const std::string&);
base_repository(const Model::BinaryPath&);
protected:
MYSQL* setup_mysql_connection();
MYSQL* setup_mysql_connection(Model::database_connection);
MYSQL_RES* perform_mysql_query(MYSQL*, const std::string&);
Model::database_connection details;
private:
void intitalizeDetails();
void initializeDetails(const Model::BinaryPath&);
std::string path;
Model::BinaryPath m_binConf;
};
}
#endif
-32
View File
@@ -1,32 +0,0 @@
#ifndef COVERARTREPOSITORY_H_
#define COVERARTREPOSITORY_H_
#include <mysql/mysql.h>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/coverFilter.h"
namespace Database
{
class coverArtRepository : public base_repository
{
public:
coverArtRepository(const std::string&);
coverArtRepository(const Model::BinaryPath&);
Model::Cover retrieveRecord(Model::Cover&, Type::coverFilter);
bool doesCoverArtExist(const Model::Cover&, Type::coverFilter);
void deleteRecord(const Model::Cover&);
void saveRecord(const Model::Cover&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Cover parseRecord(MYSQL_RES*);
Model::Cover parseRecord(MYSQL_STMT*);
};
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef GENREREPOSITORY_H_
#define GENREREPOSITORY_H_
#include "database/base_repository.h"
#include "models/models.h"
#include "types/genreFilter.h"
namespace Database
{
class genreRepository : public base_repository
{
public:
genreRepository(const Model::BinaryPath&);
Model::Genre retrieveRecord(Model::Genre&, Type::genreFilter);
bool doesGenreExist(const Model::Genre&, Type::genreFilter);
void saveRecord(const Model::Genre&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Genre parseRecord(MYSQL_RES*);
Model::Genre parseRecord(MYSQL_STMT*);
};
}
#endif
-38
View File
@@ -1,38 +0,0 @@
#ifndef SONGREPOSITORY_H_
#define SONGREPOSITORY_H_
#include <memory>
#include <vector>
#include <mysql/mysql.h>
#include "database/base_repository.h"
#include "models/models.h"
#include "types/songFilter.h"
namespace Database
{
class songRepository : public base_repository
{
public:
songRepository(const std::string&);
songRepository(const Model::BinaryPath&);
std::vector<Model::Song> retrieveRecords();
bool doesSongExist(const Model::Song&, Type::songFilter);
Model::Song retrieveRecord(Model::Song&, Type::songFilter);
void deleteRecord(const Model::Song&);
void saveRecord(const Model::Song&);
private:
std::vector<Model::Song> parseRecords(MYSQL_RES*); // TODO: to be removed
std::vector<Model::Song> parseRecords(MYSQL_STMT*);
Model::Song parseRecord(MYSQL_RES*); // TODO: to be removed
Model::Song parseRecord(MYSQL_STMT*);
};
}
#endif
-28
View File
@@ -1,28 +0,0 @@
#ifndef YEARREPOSITORY_H_
#define YEARREPOSITORY_H_
#include "database/base_repository.h"
#include "models/models.h"
#include "types/yearFilter.h"
namespace Database
{
class yearRepository : public base_repository
{
public:
yearRepository(const Model::BinaryPath&);
Model::Year retrieveRecord(Model::Year&, Type::yearFilter);
bool doesYearExist(const Model::Year&, Type::yearFilter);
void saveRecord(const Model::Year&);
private:
// TODO: After parseRecord(MYSQL_STMT*) is implemented
// remove parseRecord(MYSQL_RES*)
Model::Year parseRecord(MYSQL_RES*);
Model::Year parseRecord(MYSQL_STMT*);
};
}
#endif