Essentia  2.1-beta5-dev
algorithm.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2016 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Essentia
5  *
6  * Essentia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 #ifndef ESSENTIA_ALGORITHM_H
21 #define ESSENTIA_ALGORITHM_H
22 
23 #include "types.h"
24 #include "configurable.h"
25 #include "iotypewrappers.h"
26 
27 
28 namespace essentia {
29 namespace standard {
30 
31 class ESSENTIA_API Algorithm : public Configurable {
32 
33  public:
34  static const std::string processingMode;
35 
38 
41 
42 
43  public:
47  virtual ~Algorithm() {}
48 
49  const InputMap& inputs() const { return _inputs; }
50  const OutputMap& outputs() const { return _outputs; }
51 
55  InputBase& input(const std::string& name);
56 
60  OutputBase& output(const std::string& name);
61 
65  std::vector<std::string> inputNames() const { return _inputs.keys(); }
66 
70  std::vector<std::string> outputNames() const { return _outputs.keys(); }
71 
80  virtual void compute() = 0;
81 
88  virtual void reset() {}
89 
90 
91  // methods for having access to the types of the inputs/outputs
92  std::vector<const std::type_info*> inputTypes() const;
93  std::vector<const std::type_info*> outputTypes() const;
94 
95 
96  protected:
97 
98  void declareInput(InputBase& input, const std::string& name, const std::string& desc);
99  void declareOutput(OutputBase& output, const std::string& name, const std::string& desc);
100 
101  InputMap _inputs;
102  OutputMap _outputs;
103 
104 };
105 
106 } // namespace standard
107 } // namespace essentia
108 
109 #include "iotypewrappers_impl.h"
110 
111 #endif // ESSENTIA_ALGORITHM_H
std::vector< std::string > inputNames() const
Definition: algorithm.h:65
InputMap _inputs
Definition: algorithm.h:101
DescriptionMap inputDescription
Definition: algorithm.h:39
Definition: configurable.h:38
const OutputMap & outputs() const
Definition: algorithm.h:50
std::vector< std::string > outputNames() const
Definition: algorithm.h:70
const InputMap & inputs() const
Definition: algorithm.h:49
OrderedMap< OutputBase > OutputMap
Definition: algorithm.h:37
DescriptionMap outputDescription
Definition: algorithm.h:40
virtual void reset()
Definition: algorithm.h:88
virtual ~Algorithm()
Definition: algorithm.h:47
OutputMap _outputs
Definition: algorithm.h:102
static const std::string processingMode
Definition: algorithm.h:34
Definition: algorithm.h:28
Definition: iotypewrappers.h:66
Definition: iotypewrappers.h:35
OrderedMap< InputBase > InputMap
Definition: algorithm.h:36
Definition: algorithm.h:31