Essentia  2.1-beta5-dev
iotypewrappers.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_IOTYPEWRAPPERS_H
21 #define ESSENTIA_IOTYPEWRAPPERS_H
22 
23 #include <string>
24 #include "types.h"
25 #include "streaming/sourcebase.h"
26 #include "streaming/sinkbase.h"
27 
28 namespace essentia {
29 namespace standard {
30 
31 
32 class Algorithm;
33 
34 
35 class ESSENTIA_API InputBase : public TypeProxy {
36 
37  protected:
39  friend class Algorithm;
40 
41  public:
42  InputBase() : _parent(0), _data(0) {}
43 
44  std::string fullName() const;
45 
46  // implementation in iotypewrappers_impl.h
47  template <typename Type>
48  void set(const Type& data);
49 
51  checkSameTypeAs(sink);
52  _data = sink.getFirstToken();
53  }
54 
56  checkVectorSameTypeAs(sink);
57  _data = sink.getTokens();
58  }
59 
60  protected:
61  const void* _data;
62 
63 };
64 
65 
66 class ESSENTIA_API OutputBase : public TypeProxy {
67 
68  protected:
70  friend class Algorithm;
71 
72  public:
73  OutputBase() : _parent(0), _data(0) {}
74 
75  std::string fullName() const;
76 
77  // implementation in iotypewrappers_impl.h
78  template <typename Type>
79  void set(Type& data);
80 
82  checkSameTypeAs(source);
83  _data = source.getFirstToken();
84  }
85 
87  checkVectorSameTypeAs(source);
88  _data = source.getTokens();
89  }
90 
91  protected:
92  void* _data;
93 
94 };
95 
96 
97 } // namespace standard
98 } // namespace essentia
99 
100 #endif // ESSENTIA_IOTYPEWRAPPERS_H
void setSourceFirstToken(streaming::SourceBase &source)
Definition: iotypewrappers.h:81
virtual void * getFirstToken()=0
Definition: sourcebase.h:52
const void * _data
Definition: iotypewrappers.h:61
virtual const void * getFirstToken() const =0
InputBase()
Definition: iotypewrappers.h:42
Algorithm * _parent
Definition: iotypewrappers.h:38
Definition: sinkbase.h:52
Algorithm * _parent
Definition: iotypewrappers.h:69
virtual void * getTokens()=0
void * _data
Definition: iotypewrappers.h:92
Definition: algorithm.h:28
Definition: iotypewrappers.h:66
void setSourceTokens(streaming::SourceBase &source)
Definition: iotypewrappers.h:86
OutputBase()
Definition: iotypewrappers.h:73
Definition: iotypewrappers.h:35
void setSinkTokens(streaming::SinkBase &sink)
Definition: iotypewrappers.h:55
Definition: types.h:273
virtual const void * getTokens() const =0
Definition: algorithm.h:31
void setSinkFirstToken(streaming::SinkBase &sink)
Definition: iotypewrappers.h:50