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
projectmanageradapter.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 //=============================================================================
21 // Adapter for project management
22 //=============================================================================
23 
24 
25 #ifndef PROJECTMANAGERADAPTER_H
26 #define PROJECTMANAGERADAPTER_H
27 
28 #include <string>
29 #include "../piano/pianofile.h"
30 #include "../messages/messagelistener.h"
31 
32 class Core;
33 class Piano;
34 
35 
39 
41 {
42 public:
43  virtual void changesInFileUpdated(bool changes) = 0;
44 };
45 
46 
54 
56 {
57 public:
59  enum Results
60  {
65  };
66 
67 
68 
70  FileDialogResult(const std::string path = "");
71 
72  const std::string path;
74 
75  bool isValid() {return path.size() != 0 && fileType != piano::FT_NONE;}
76  };
77 
78 public:
80  virtual ~ProjectManagerAdapter() {}
81 
82  void init(Core *core); // Initialize the adapter
83  void setCallback(FileChangesCallback *cb); // Set callback function
84 
85  bool hasChangesInFile() const {return mChangesInFile;}
86 
87  const std::string &getCurrentFilePath() const {return mCurrentFilePath;}
88 
89 
90  // signals to be called from the gui
95  bool onQuit();
97  Results onShare();
98  Results onExport();
99 
100 
101  // open or save file
102  Results saveFile(const std::string &path, piano::FileType type);
103  Results openFile(const std::string &path, bool cached = false);
104 
105 protected:
106  // signals to be reimplemented by the gui
107 
110  virtual Results editFile() = 0;
111 
114  virtual Results askForSaving() = 0;
115 
118  virtual FileDialogResult getSavePath(int fileType) = 0;
119 
122  virtual FileDialogResult getOpenPath(int fileType) = 0;
123 
126  virtual Results share() = 0;
127 
129  virtual void fillNew(Piano &piano) = 0;
130 
132  virtual void showOpenError() = 0;
133 
135  virtual void showSaveError() = 0;
136 
138  virtual void handleMessage(MessagePtr m) override;
139 
141  void setChangesInFile(bool b);
142 private:
144 
145 protected:
148 
151 
152 private:
155 
158 
160  std::string mCurrentFilePath;
161 };
162 
163 #endif // PROJECTMANAGERADAPTER_H
std::shared_ptr< Message > MessagePtr
Global type of a shared message pointer.
Definition: message.h:98
virtual void showOpenError()=0
Show a message box that an error occurred during the open process.
virtual void fillNew(Piano &piano)=0
function to fill the piano data with the current new settings
void setCallback(FileChangesCallback *cb)
Set a callback function for file changes.
void setChangesInFile(bool b)
change the state of mChangesInFile and notify the listener
FileType
supported piano file types
Definition: pianodefines.h:59
Definition: piano.h:40
std::string mCurrentFilePath
current file path
PianoFile mPianoFile
the piano file
Results
Enumeration of the possible outcomes of a typical mouse button.
Results openFile(const std::string &path, bool cached=false)
The ProjectManagerChangesInFileUpdatedCallback class.
Results onNewFile()
New-file menu response.
virtual FileDialogResult getSavePath(int fileType)=0
get a path were to save the file
void init(Core *core)
Initialize the project management adapter.
virtual void showSaveError()=0
Show a message box that an error occurred during the save process.
virtual Results share()=0
shares the current file with the actual device
CORE : Class managing the core.
Definition: core.h:45
virtual void handleMessage(MessagePtr m) override
message listener callback
ProjectManagerAdapter()
Constructor.
bool mChangesInFile
stores whether there are unsaved changes in the current file
virtual void changesInFileUpdated(bool changes)=0
virtual FileDialogResult getOpenPath(int fileType)=0
get a path to a file to open
virtual ~ProjectManagerAdapter()
Empty destructor.
const std::string & getCurrentFilePath() const
Results saveFile(const std::string &path, piano::FileType type)
virtual Results askForSaving()=0
asks the user whether to save the current project file
FileChangesCallback * mCallback
callback if mChangesInFileChanged
Project manager adapter class.
virtual Results editFile()=0
edit a project file