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
calculationmanager.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 // Calculation manager
22 //=============================================================================
23 
24 #ifndef CALCULATIONMANAGER_H
25 #define CALCULATIONMANAGER_H
26 
27 #include <memory>
28 
29 #include "../system/simplethreadhandler.h"
30 #include "../piano/piano.h"
31 #include "algorithm.h"
32 #include "algorithminformation.h"
33 
34 
37 class Algorithm;
38 
51 
53 {
54 private:
55  CalculationManager(); // Constructor
56 
57 public:
58  virtual ~CalculationManager(); // Destructor
59 
61 
62  void start(const std::string &algorithmName, const Piano &piano);
63  void stop();
64 
65  void registerFactory(const std::string &name, AlgorithmFactoryBase* factory);
66 
67  const std::map<std::string, AlgorithmFactoryBase*> &getAlgorithms() const {return mAlgorithms;}
68  AlgorithmFactoryDescription &getAlgorithmDescription(const std::string &algorithmName) const;
69  std::shared_ptr<const AlgorithmInformation> loadAlgorithmInformation(const std::string &algorithmName) const;
70  bool hasAlgorithm(const std::string &id) const;
71  std::string getDefaultAlgorithmId() const;
72 
73 private:
74  std::map<std::string, AlgorithmFactoryBase*> mAlgorithms;
75  std::unique_ptr<Algorithm> mCurrentAlgorithm;
76 };
77 
78 #endif // CALCULATIONMANAGER_H
static CalculationManager & getSingleton()
Calculation-Manager.
Definition: piano.h:40
The AlgorithmFactoryBase class create the desired Algorithm.
std::map< std::string, AlgorithmFactoryBase * > mAlgorithms
void start(const std::string &algorithmName, const Piano &piano)
Start the calculation thread. By calling this function, the current piano is passed by reference and ...
CalculationManager()
Constructor, resets member variables.
bool hasAlgorithm(const std::string &id) const
void stop()
Stop the calculation thread.
void registerFactory(const std::string &name, AlgorithmFactoryBase *factory)
The Algorithm class is a basic abstract class for any algorithm.
Definition: algorithm.h:38
std::shared_ptr< const AlgorithmInformation > loadAlgorithmInformation(const std::string &algorithmName) const
AlgorithmFactoryDescription & getAlgorithmDescription(const std::string &algorithmName) const
std::unique_ptr< Algorithm > mCurrentAlgorithm
std::string getDefaultAlgorithmId() const
const std::map< std::string, AlgorithmFactoryBase * > & getAlgorithms() const