Essentia  2.1-beta6-dev
essentia.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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_ESSENTIA_H
21 #define ESSENTIA_ESSENTIA_H
22 
23 #include "config.h"
24 #include "types.h"
25 
26 // the following are not necessary but are here for commodity purposes,
27 // ie: so people can just include "essentia.h" for the basic types and operations
28 // and then do not need stringutil.h and streamutil.h, etc... which they might
29 // forget otherwise or not even be aware of
30 #include "essentiautil.h"
31 #include "stringutil.h"
32 #include "streamutil.h"
33 
34 
35 namespace essentia {
36 
37 extern const char* version;
38 extern const char* version_git_sha;
39 
46 void init();
47 
49 
50 void shutdown();
51 
52 namespace standard {
58  void ESSENTIA_API registerAlgorithm();
59 }
60 
61 namespace streaming {
67  void ESSENTIA_API registerAlgorithm();
68 }
69 
70 class TypeMap {
71  public:
72 
74  if (!_typeMap) {
75  throw EssentiaException("Essentia TypeMap not initialised!");
76  }
77  return *_typeMap;
78  }
79 
80  static void init() {
81  if (_typeMap) return;
82 
84 
85 #define registerEssentiaType(type) TypeMap::_typeMap->insert(typeid(type).name(), #type)
86 
87  registerEssentiaType(std::string);
93  registerEssentiaType(std::vector<std::string>);
94  registerEssentiaType(std::vector<Real>);
95  registerEssentiaType(std::vector<StereoSample>);
96 
97 #undef registerEssentiaType
98  }
99 
100  static void shutdown() {
101  delete _typeMap;
102  _typeMap = 0;
103  }
104 
105 protected:
106  TypeMap() {}
108 };
109 
110 } // namespace essentia
111 
112 #endif // ESSENTIA_ESSENTIA_H
Definition: types.h:77
Definition: essentia.h:70
static void shutdown()
Definition: essentia.h:100
static EssentiaMap< std::string, std::string > & instance()
Definition: essentia.h:73
static EssentiaMap< std::string, std::string > * _typeMap
Definition: essentia.h:107
static void init()
Definition: essentia.h:80
TypeMap()
Definition: essentia.h:106
#define registerEssentiaType(type)
void ESSENTIA_API registerAlgorithm()
void ESSENTIA_API registerAlgorithm()
Definition: algorithm.h:28
void shutdown()
const char * version_git_sha
void init()
const char * version
float Real
Definition: types.h:69
bool isInitialized()
unsigned int uint
Definition: types.h:49