Commit c07486fe authored by Pipelier Quentin's avatar Pipelier Quentin
Browse files

Merge branch 'Release' into 'master'

Release

See merge request sio/ppe3/objectif100/clap-play!39
parents 2b44ba07 28d03b2f
Pipeline #197692 passed with stages
in 15 minutes and 13 seconds
......@@ -6,7 +6,7 @@ stages:
- test
before_script:
- apt update && apt install wget liblog4cxx-dev libjsoncpp-dev libexpat-dev liburiparser-dev autotools-dev autoconf automake build-essential libtool libpq-dev doxygen doxygen-gui doxygen-doc pkgconf libgflags-dev -y -qq
- apt update && apt install wget liblog4cxx-dev libjsoncpp-dev libexpat-dev liburiparser-dev autotools-dev autoconf automake build-essential libtool libpq-dev doxygen doxygen-gui doxygen-doc doxygen-latex pkgconf libgflags-dev -y -qq
- wget https://netcologne.dl.sourceforge.net/project/cpptest/cpptest/cpptest-2.0.0/cpptest-2.0.0.tar.gz
- tar xf cpptest-2.0.0.tar.gz
- cd cpptest-2.0.0
......@@ -30,10 +30,22 @@ construction:
documentation:
stage: documentation
only :
- Develop
- tags
script:
- make doc
- cd doc/latex
- make pdf
- mv refman.pdf technical_documentation.pdf
- cd ../..
artifacts:
name: "technical_documentation"
paths:
- "doc/latex/technical_documentation.pdf"
test:
stage: test
script:
- make
- ./src/clap_play --title="a" --duration=500 --polyphony=2 --playlist="test_playlist"
\ No newline at end of file
- ./src/clap_play --title="a" --duration=500 --polyphony=2 --playlist="test_playlist"
......@@ -36,6 +36,8 @@ Filtering by format musical
Filtering by polyphony musical
.IP --artist
Filtering by artist musical
.IP --export-file
Choose the directory to export file
.SH BUGS
No know bugs
.SH AUTHOR
......
......@@ -2,56 +2,167 @@
class Playlist {
-id: int
-name: std::string
-duration: unsigned int
+writeM3U()
+writeXSPF()
-connection: PGconn*
-export_option: std::string
__
+Playlist(int, std::string, unsigned int, PGconn*)
+~Playlist()
__
+writeM3U(std::string, std::string, std::string, unsigned int, std::string): void
+writeXSPF(std::string, std::string, std::string, unsigned int, std::string): void
+getId(): int
+getDuration(): unsigned int
+setId(int): void
+setDuration(unsigned int): void
}
class Track {
-id: int
-duration: unsigned int
-name: std::string
-path: std::string
-playlist: Xspf::XspfWriter *const
-connexion: PGconn*
__
+Track(int, Xspf::XspfWriter *const, PGconn*)
+~Track()
__
+searchTrack(unsigned int, std::string, std::string, std::string, unsigned int, std::string): std::vector<unsigned int>
+addTrack(int): void
}
class Format {
-id: int
-id: unsigned int
-titled: std::string
__
+Format(unsigned int, PGconn*)
__
+getId(): unsigned int
+getTitled(): std::string
}
class Artist {
-id: int
-id: unsigned int
-name: std::string
__
+Artist(unsigned int, PGconn*)
__
+getId(): unsigned int
+getName(): std::string
}
class FileConfiguration {
-config_db_host: std::string
-config_db_user: std::string
-config_db_name: std::string
-config_db_schema: std::string
-config_db_password: std::string
-config_duration: unsigned int
-config_loaded: bool
-config_title: std::string
-config_m3u: bool
-config_xspf: bool
-config_genre: std::string
__
+FileConfiguration()
__
+load(std::string): void
+getDbHost(): std::string
+getDbUser(): std::string
+getDbName(): std::string
+getDbSchema(): std::string
+getDbPassword(): std::string
+getDuration(): unsigned int
+getConfigLoaded(): bool
+getTitle(): std::string
+getM3u(): bool
+getXspf(): bool
+getGenre(): std::string
+getNamePlaylist(): std::string
}
class Album {
-id: int
-date
-id: unsigned int
-date: time_t
-name: std::string
__
+Album(unsigned int, PGconn*)
+~Album()
__
+getId(): unsigned int
+getDate(): time_t
+getName(): std::string
}
class Genre {
-id: int
-id: unsigned int
-type: std::string
__
+Genre(unsigned int, PGconn*)
+~Genre()
__
+getId(): unsigned int
+getType(): std::string
}
class Subgenre {
-id: int
-id: unsigned int
-subgenre: std::string
__
+Subgenre(unsigned int, PGconn*)
+~Subgenre()
__
+getId(): unsigned int
+getSubgenre(): std::string
}
class Polyphony {
-id: int
-number: int
-id: unsigned int
-number: unsigned int
__
+Polyphony(unsigned int, PGconn*)
+~Polyphony()
__
+getId(): unsigned int
+getNumber(): unsigned int
}
class M3U {
-id: unsigned int
-name: std::string
-duration: unsigned int
-connexion: PGconn*
__
+M3U(unsigned int, std::string, unsigned int, PGconn*)
+~M3U()
__
+getDuration(): unsigned int
+addTrack(unsigned int): void
..
-createFile(): void
-addToFile(std::string, std::string, std::string, unsigned int )
}
class Log {
-logger: log4cxx::LoggerPtr
-file: std::string
__
+Log(bool, std::string)
+~Log()
__
+log_info(std::string): void
+log_debug(std::string): void
+log_warn(std::string): void
+log_error(std::string): void
+log_trace(std::string): void
+log_fatal(std::string): void
}
Playlist "1" o-- "1..*" Track
Track "1..*" -- "1..*" Album
Track "1..*" -- "1..*" Artist
Track "1" -- "1..*" Format
Track "1..*" -- "1" Subgenre
Track "1..*" -- "1" Genre
Track "1..*" -- "1" Polyphony
'Playlist "1" o-- "1..*" Track
Track "1..*" -- "1" Album
'Track "1..*" -- "1..*" Artist
'Track "1" -- "1..*" Format
'Track "1..*" -- "1" Subgenre
'Track "1..*" -- "1" Genre
'Track "1..*" -- "1" Polyphony
@enduml
\ No newline at end of file
doc/uml/UML.png

24 KB | W: | H:

doc/uml/UML.png

116 KB | W: | H:

doc/uml/UML.png
doc/uml/UML.png
doc/uml/UML.png
doc/uml/UML.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -15,8 +15,9 @@ private:
unsigned int id;
std::string name;
unsigned int duration;
std::string export_option;
PGconn *connexion;
void createFile();
void addToFile(std::string, std::string, std::string, unsigned int);
......@@ -33,7 +34,7 @@ public:
*
* \param PGconn * - connexion : handler for the database connexion
*/
M3U(unsigned int, std::string, unsigned int, PGconn *);
M3U(unsigned int, std::string, unsigned int, std::string, PGconn *);
/**
* Destructor
......
......@@ -2,12 +2,13 @@
#include <gflags/gflags.h>
#include <gflags/gflags_declare.h>
/** \brief TEST
/**
* \file manage_cli.h
* \brief File used to manage the CLI
*
* Message
*
*\param db_name \c test
*/
* Declare all the parameter of the command line
*/
DECLARE_string(db_name);
DECLARE_string(db_host);
DECLARE_string(db_password);
......@@ -23,6 +24,7 @@ DECLARE_string(format);
DECLARE_uint64(polyphony);
DECLARE_string(playlist);
DECLARE_string(config_file);
DECLARE_string(export_file);
std::string config_db_host;
......
......@@ -5,24 +5,95 @@
#include <vector>
#include <libpq-fe.h>
#include "track.h"
/**
* \class Playlist
*
* \brief Class used for the creation of the playlist files (M3U or XSPF)
*/
class Playlist {
private:
int id;
std::string name;
unsigned int duration;
std::string export_option;
PGconn *connection;
public:
Playlist(int id, std::string name, unsigned int duration, PGconn *);
/**
* \brief Unique Constructor which initialize the attributes with the values of the parameters
*
* \param integer - id : Id of the playlist (might be useful in case of a evolution of the database)
*
* \param std::string - name : name of the playlist file
*
* \param unsigned integer - duration : duration of the playlist
*
* \param Pgconn * - connexion : handler for the database connexion
*/
Playlist(int id, std::string name, unsigned int duration, std::string export_option, PGconn *);
/**
* \brief Destructor
*/
~Playlist();
/**
* \brief Create a M3U playlist using an instance of the M3U class
*
* \param std::string - title : title search criteria
*
* \param std::string - genre : gender search criteria
*
* \param std::string - format : format search criteria
*
* \param unsigned integer - polyphony : polyphony research criteria
*
* \param std::string - artist : artist research criteria
*/
void writeM3U(std::string, std::string, std::string, unsigned int, std::string);
/**
* \brief Create a XSPF playlist
*
* \param std::string - title : title search criteria
*
* \param std::string - genre : gender search criteria
*
* \param std::string - format : format search criteria
*
* \param unsigned integer - polyphony : polyphony research criteria
*
* \param std::string - artist : artist research criteria
*/
void writeXSPF(std::string, std::string, std::string, unsigned int, std::string);
/**
* \brief Get the id of the Playlist
*
* \return id : the id of the playlist as a integer
*/
int getId();
/**
* \brief Get the duration of the Playlist
*
* \return duration : the duration of the playlist as an unsigned integer
*/
unsigned int getDuration();
/**
* \brief Mutate the id attribute with the value of the parameter
*
* \param integer - id : the new id of the playlist
*/
void setId(int id);
/**
* \brief Mutate the duration attribute with the value of the parameter
*
* \param unsigned integer - duration : the new duration of the playlist
*/
void setDuration(unsigned int duration);
};
#endif
......@@ -14,6 +14,12 @@
#include <string>
#include <vector>
/**
* \class Track
*
*\brief A class made to search and add new track
*
*/
class Track{
private:
......@@ -22,10 +28,40 @@ private:
PGconn *connexion;
Album *album;
public:
/**
* \brief Constructor
*
* \param int - id : id of the playlist
*/
Track(int, Xspf::XspfWriter *const, PGconn *);
/**
* \brief Destructor
*
*/
~Track();
/**
* \brief Search track by criterias, return vector with all id's of tracks
*
* \param uint_64 - duration_max : Duration max of the playlist
* \param std::string - title : Title criteria
* \param std::string - genre : Genre criteria
* \param std::string - artist : Artist criteria
* \param uint_64 - polyphony : Polyphony criteria
* \param std::string - format : Format criteria
*
* \return vector<uint_64>
*
*/
std::vector<unsigned int> searchTrack(unsigned int, std::string, std::string, std::string, unsigned int, std::string);
/**
* \brief Add track according to id
*
* \param int - id : Id of the track
*
*/
void addTrack(int id);
};
......
......@@ -5,10 +5,11 @@
std::ofstream file;
M3U::M3U(unsigned int id, std::string name, unsigned int duration, PGconn *connexion):
M3U::M3U(unsigned int id, std::string name, unsigned int duration, std::string export_option, PGconn *connexion):
id(id),
name(name),
duration(duration),
export_option(export_option),
connexion(connexion)
{
createFile();
......@@ -22,7 +23,9 @@ unsigned int M3U::getDuration(){
void M3U::createFile(){
std::string file_name = name + ".m3u";
file.open(file_name, std::ios::out);
std::string prepare_path = export_option + file_name;
const char *path = prepare_path.c_str();
file.open(path);
Log logger(true, "M3U.cc");
if(file.is_open()){
logger.log_info("File " + file_name + " has been created");
......
lib_LTLIBRARIES = libgen_playlist.la
libgen_playlist_la_SOURCES = manage_cli.cc ../header/manage_cli.h playlist.cc ../header/playlist.h ../header/track.h track.cc ../header/M3U.h M3U.cc album.cc ../header/album.h genre.cc ../header/genre.h subgenre.cc ../header/subgenre.h polyphony.cc ../header/polyphony.h format.cc ../header/format.h artist.cc ../header/artist.h ../header/file_configuration.h file_configuration.cc ../header/log.h log.cc
libgen_playlist_la_SOURCES = clap_play.cc ../header/clap_play.h playlist.cc ../header/playlist.h ../header/track.h track.cc ../header/M3U.h M3U.cc album.cc ../header/album.h genre.cc ../header/genre.h subgenre.cc ../header/subgenre.h polyphony.cc ../header/polyphony.h format.cc ../header/format.h artist.cc ../header/artist.h ../header/file_configuration.h file_configuration.cc ../header/log.h log.cc
libgen_playlist_la_CPPFLAGS = -Werror -Wall -Wextra
libgen_playlist_la_CXXFLAGS = -fPIC $(LIBPQ_CFLAGS) $(GFLAGS_CFLAGS) $(XSPF_CFLAGS) $(LOG4CXX_CFLAGS) $(JSONCPP_CFLAGS)
libgen_playlist_la_LDFLAGS = $(LIBPQ_LIBS) $(GFLAGS_LIBS) $(XSPF_LIBS) $(LOG4CXX_LIBS) $(JSONCPP_LIBS)
......
#include <iostream>
#include <fstream>
#include "json/json.h"
#include "../header/manage_cli.h"
#include "../header/clap_play.h"
#include "../header/file_configuration.h"
DEFINE_string(db_host, "postgresql.bts-malraux72.net", "Hostname database");
......@@ -19,6 +19,7 @@ DEFINE_string(config_file, "config.json", "Configuration file path and name");
DEFINE_string(artist, "", "Filtering by musical artist");
DEFINE_string(format, "", "Filtering by musical format");
DEFINE_uint64(polyphony, 2, "Filtering by musical polyphony");
DEFINE_string(export_file, "./", "Choose your repository export");
void configure(){
gflags::SetVersionString("1.0.0");
......
......@@ -4,7 +4,7 @@
#include <string>
#include <gflags/gflags.h>
#include "../header/playlist.h"
#include "../header/manage_cli.h"
#include "../header/clap_play.h"
#include "../header/album.h"
#include "../header/file_configuration.h"
#include "../header/log.h"
......@@ -30,7 +30,8 @@ int main(int nombre_de_parametres, char *tableau_des_parametres[])
unsigned int polyphony = FLAGS_polyphony;
std::string format = FLAGS_format;
std::string artist = FLAGS_artist;
std::string export_file = FLAGS_export_file;
if(config_file->getConfigLoaded())
{
db_host = config_file->getDbHost();
......@@ -57,18 +58,18 @@ int main(int nombre_de_parametres, char *tableau_des_parametres[])
if(xspf && m3u)
{
Playlist *playlist = new Playlist(3, name_playlist, duration, retour_connexion);
Playlist *playlist = new Playlist(3, name_playlist, duration, export_file, retour_connexion);
playlist->writeXSPF(title, genre, format, polyphony, artist);
playlist->writeM3U(title, genre, format, polyphony, artist);
}
else if(xspf)
{
Playlist *playlist = new Playlist(1, name_playlist, duration, retour_connexion);
Playlist *playlist = new Playlist(1, name_playlist, duration, export_file, retour_connexion);
playlist->writeXSPF(title, genre, format, polyphony, artist);
}
else
{
Playlist *playlist = new Playlist(2, name_playlist, duration, retour_connexion);
Playlist *playlist = new Playlist(2, name_playlist, duration, export_file, retour_connexion);
playlist->writeM3U(title, genre, format, polyphony, artist);
}
}
......
......@@ -12,10 +12,11 @@
using namespace Xspf;
using namespace Xspf::Toolbox;
Playlist::Playlist(int id, std::string name, unsigned int duration, PGconn *connection) :
Playlist::Playlist(int id, std::string name, unsigned int duration, std::string export_option, PGconn *connection) :
id(id),
name(name),
duration(duration),
export_option(export_option),
connection(connection)
{}
......@@ -23,7 +24,7 @@ Playlist::~Playlist() {}
void Playlist::writeM3U(std::string title, std::string genre, std::string format, unsigned int polyphony, std::string artist){
M3U *m3u = new M3U(1, name, duration, connection);
M3U *m3u = new M3U(1, name, duration, export_option, connection);
Track *all_tracks = new Track(1, NULL, connection);
std::vector<unsigned int> id_tracks_filtre;
......@@ -62,8 +63,10 @@ void Playlist::writeXSPF(std::string title, std::string genre, std::string form
for(unsigned int parcours = 0; parcours < id_tracks_filtre.size(); parcours++){
all_tracks->addTrack(id_tracks_filtre[parcours]);
}
std::string path = export_option + name;
playlist->writeFile((name + ".xspf").c_str());
playlist->writeFile((path + ".xspf").c_str());
std::ifstream file (name + ".xspf");
Log logger(true, "playlist.cc");
......
......@@ -53,15 +53,15 @@ std::vector< unsigned int> Track::searchTrack(unsigned int duration_max, std::st
unsigned int duration = 0;
unsigned int nbRows = PQntuples(result_filtre);
std::cout << nbRows;
for (unsigned int i = 0; i < nbRows; i++){
duration += atoi(PQgetvalue(result_filtre,i ,1));
if (duration >= duration_max){
break;
}else{
tracks.push_back(atoi(PQgetvalue(result_filtre, i,0)));
duration += atoi(PQgetvalue(result_filtre, i ,1));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment