Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pianofile.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #ifndef PIANOFILE_H
21 #define PIANOFILE_H
22 
23 #include <fstream>
24 #include "../../thirdparty/tinyxml2/tinyxml2.h"
25 #include "piano.h"
26 
27 
28 class PianoFile
29 {
30 public:
31  using FileVersionType = int;
32  static const std::string FILE_TYPE_NAME;
36 public:
37  PianoFile();
38  ~PianoFile();
39 
40  bool read(const std::string &absolutePath, Piano &piano);
41  bool write(const std::string &absolutePath, const Piano &piano, piano::FileType fileType) const;
42 
43  void readXmlFile(const std::string &absolutePath, Piano &piano);
44  void writeXmlFile(const std::string &absolutePath, const Piano &piano) const;
45 
46  void writeCsvFile(const std::string &absolutePath, const Piano &piano) const;
47 
48 protected:
49  std::string getText(const tinyxml2::XMLElement *element);
50  void createTextXMLElement(tinyxml2::XMLElement *parent, const char *label, const char *text) const;
51 
52  // Piano data
53  void read(const tinyxml2::XMLElement *e, Piano &piano);
54  void write(tinyxml2::XMLElement *e, const Piano &piano) const;
55 
56 
57  // Key data
58  void read(const tinyxml2::XMLElement *e, Keyboard &keyboard);
59  void write(tinyxml2::XMLElement *e, const Keyboard &keyboard) const;
60 
61 private:
64 };
65 
66 #endif // PIANOFILE_H
FileVersionType mFileVersion
file version as integer
Definition: pianofile.h:63
static const FileVersionType UNSET_FILE_VERSION
Definition: pianofile.h:33
std::string getText(const tinyxml2::XMLElement *element)
Definition: pianofile.cpp:164
int FileVersionType
Definition: pianofile.h:31
Class describing the piano keyboard, holding a collection of keys.
Definition: keyboard.h:39
static const std::string FILE_TYPE_NAME
Definition: pianofile.h:32
FileType
supported piano file types
Definition: pianodefines.h:59
void readXmlFile(const std::string &absolutePath, Piano &piano)
Definition: pianofile.cpp:83
Definition: piano.h:40
bool write(const std::string &absolutePath, const Piano &piano, piano::FileType fileType) const
Definition: pianofile.cpp:62
void writeXmlFile(const std::string &absolutePath, const Piano &piano) const
Definition: pianofile.cpp:138
bool read(const std::string &absolutePath, Piano &piano)
Definition: pianofile.cpp:47
void createTextXMLElement(tinyxml2::XMLElement *parent, const char *label, const char *text) const
Definition: pianofile.cpp:172
static const FileVersionType CURRENT_FILE_VERSION
Definition: pianofile.h:34
static const FileVersionType MIN_SUPPORTED_FILE_VERSION
Definition: pianofile.h:35
void writeCsvFile(const std::string &absolutePath, const Piano &piano) const
Definition: pianofile.cpp:345