summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/interface/DataType.hpp29
-rw-r--r--src/libs/engine/Buffer.hpp10
-rw-r--r--src/libs/engine/BufferFactory.cpp6
3 files changed, 26 insertions, 19 deletions
diff --git a/src/common/interface/DataType.hpp b/src/common/interface/DataType.hpp
index a2e3ce5a..1eef3171 100644
--- a/src/common/interface/DataType.hpp
+++ b/src/common/interface/DataType.hpp
@@ -18,8 +18,8 @@
#ifndef DATATYPE_H
#define DATATYPE_H
-namespace Ingen
-{
+namespace Ingen {
+namespace Shared {
/** A data type that can be stored in a Port.
@@ -30,7 +30,7 @@ namespace Ingen
*/
class DataType {
public:
-
+
enum Symbol {
UNKNOWN = 0,
AUDIO = 1,
@@ -38,9 +38,9 @@ public:
MIDI = 3,
OSC = 4
};
-
+
DataType(const std::string& uri)
- : _symbol(UNKNOWN)
+ : _symbol(UNKNOWN)
{
if (uri == type_uri(AUDIO)) {
_symbol = AUDIO;
@@ -54,20 +54,23 @@ public:
}
DataType(Symbol symbol)
- : _symbol(symbol)
+ : _symbol(symbol)
{}
- const char* uri() const { return type_uri(_symbol); }
- const Symbol& symbol() const { return _symbol; }
+ inline const char* uri() const { return type_uri(_symbol); }
inline bool operator==(const Symbol& symbol) const { return (_symbol == symbol); }
inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); }
inline bool operator==(const DataType& type) const { return (_symbol == type._symbol); }
inline bool operator!=(const DataType& type) const { return (_symbol != type._symbol); }
-private:
- Symbol _symbol;
+ inline bool is_audio() { return _symbol == AUDIO; }
+ inline bool is_control() { return _symbol == CONTROL; }
+ inline bool is_midi() { return _symbol == MIDI; }
+ inline bool is_osc() { return _symbol == OSC; }
+private:
+
static inline const char* type_uri(unsigned symbol_num) {
switch (symbol_num) {
case 1: return "ingen:AudioPort";
@@ -77,10 +80,14 @@ private:
default: return "";
}
}
-};
+ Symbol _symbol;
+};
+} // namespace Shared
} // namespace Ingen
+using Ingen::Shared::DataType;
+
#endif // DATATYPE_H
diff --git a/src/libs/engine/Buffer.hpp b/src/libs/engine/Buffer.hpp
index cb8f09d4..d18270f5 100644
--- a/src/libs/engine/Buffer.hpp
+++ b/src/libs/engine/Buffer.hpp
@@ -31,7 +31,7 @@ namespace Ingen {
class Buffer : public boost::noncopyable, public Raul::Deletable
{
public:
- Buffer(DataType type, size_t size)
+ Buffer(Shared::DataType type, size_t size)
: _type(type)
, _size(size)
{}
@@ -55,12 +55,12 @@ public:
virtual void resize(size_t size) { _size = size; }
- DataType type() const { return _type; }
- size_t size() const { return _size; }
+ Shared::DataType type() const { return _type; }
+ size_t size() const { return _size; }
protected:
- DataType _type;
- size_t _size;
+ Shared::DataType _type;
+ size_t _size;
};
diff --git a/src/libs/engine/BufferFactory.cpp b/src/libs/engine/BufferFactory.cpp
index 882e1805..84ff721b 100644
--- a/src/libs/engine/BufferFactory.cpp
+++ b/src/libs/engine/BufferFactory.cpp
@@ -27,11 +27,11 @@ namespace BufferFactory {
Buffer*
create(DataType type, size_t size)
{
- if (type == DataType::CONTROL || type == DataType::AUDIO)
+ if (type.is_control() || type.is_audio())
return new AudioBuffer(size);
- else if (type == DataType::MIDI)
+ else if (type.is_midi())
return new MidiBuffer(size);
- else if (type == DataType::OSC)
+ else if (type.is_osc())
return new OSCBuffer(size);
else
return NULL;