Generate an accompaniement for a given melody
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Database.hpp
1 #ifndef DATABASE_HPP_INCLUDED
2 #define DATABASE_HPP_INCLUDED
3 #include "Music.hpp"
4 #include "Utilities.hpp"
5 #include <string>
6 #include <fstream>
7 #include <sstream>
8 #include <algorithm>
9 #include <memory>
10 #include "boost/filesystem.hpp"
11 #include <boost/filesystem/fstream.hpp>
12 
13 
14 extern int verbose_flag;
23 class Data {
24 public:
30  Data(std::string name,ChordProgression c,Melody m);
31 
40  Data(std::string name,std::string fileMelody , std::string fileChords);
41  // Data();
42  //Getteur
47  std::string getName() const __attribute__((pure));
52  ChordProgression getChords() const __attribute__((pure));
57  Melody getMelody() const __attribute__((pure));
58 
59  //Setteur
63  void setName(std::string d);
71  void setMelody(Melody m);
72 
73 private:
74  std::string m_Name;
75  ChordProgression m_Chords;
76  Melody m_melody;
77 };
78 
79 
80 
88 std::ostream& operator <<(std::ostream& o, Data d);
89 
98 //std::istream& operator >>(std::istream& i, Data d);
99 
100 
101 class Database
102 {
103 public:
104 
105  class Style
106  {
107  friend class Database;
108  public:
109  ~Style();
110  Style(Style&& o) = default;
111  Style();
112  Style& operator=(Database::Style&& o) = default;
118  Style(const boost::filesystem::path& p, const std::string& name);
119 
123  void setContent(const std::string& str);
124  private:
125 
126  Style(const Style&) = delete;
127  Style& operator=(const Database::Style&) = delete;
128 
129  std::ifstream& file() __attribute__((pure));
130 
131  std::string m_name;
132  std::unique_ptr<std::fstream> m_inFile;
133  boost::filesystem::path m_path;
134  };
135 
140  Database();
141 
149  void addEntry(const std::string& style,const Data& e);
150 
158  void addEntry(std::string style, std::string fileMelody , std::string fileChords , std::string name);
159 
160 
161 
167  std::vector<std::string> listEntries(const std::string& style);
168 
169 
175  Data getEntry(const std::string& name,const std::string& style)const;
176 
177 
178 
183  std::vector<Data> readAllEntries(const std::string& style);
184 
188  std::vector<std::string> getAvailableStyles() const;
189 
196  void deleteEntry(std::string style,std::string name);
197 
198 protected:
199 
200 
201 private:
202 
203  std::map<std::string,Style> m_styles;
204 };
205 
206 
207 #endif
void setName(std::string d)
Sets the name of the data.
Definition: Database.hpp:23
std::string getName() const __attribute__((pure))
void addEntry(const std::string &style, const Data &e)
Add given entry to the given style.
std::vector< Data > readAllEntries(const std::string &style)
This file defines all the data structures related to music objects.
std::vector< std::string > listEntries(const std::string &style)
get the name of the entries stored under the given style
ChordProgression getChords() const __attribute__((pure))
void setChords(ChordProgression c)
Sets the chords.
void deleteEntry(std::string style, std::string name)
delete an entry in the given style
Describes a melody.
Definition: Music.hpp:629
Melody getMelody() const __attribute__((pure))
Data(std::string name, ChordProgression c, Melody m)
constructor for Data
Data getEntry(const std::string &name, const std::string &style) const
void setContent(const std::string &str)
std::vector< Chord > ChordProgression
ChordProgression is the class used to give the set of chords used.
Definition: Music.hpp:592
void setMelody(Melody m)
Sets the melody.
Definition: Database.hpp:105
input operator for NoteName The format is capital or small letters for the NoteName ...
Definition: Database.hpp:101
std::ostream & operator<<(std::ostream &o, NoteName n)
output operator for NoteName The format is capital letters for the NoteName
std::vector< std::string > getAvailableStyles() const
returns the name of the known styles
Database()
Constructor of a db It scans the directory looking for available styles.