2016-05-02 18:16:26 -07:00
|
|
|
#ifndef __AMUSE_ENTITY_HPP__
|
|
|
|
#define __AMUSE_ENTITY_HPP__
|
|
|
|
|
2016-05-05 22:19:19 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <functional>
|
2016-05-06 14:22:39 -07:00
|
|
|
#include <assert.h>
|
2016-05-05 22:19:19 -07:00
|
|
|
|
2016-05-02 18:16:26 -07:00
|
|
|
namespace amuse
|
|
|
|
{
|
|
|
|
class Engine;
|
2016-05-05 22:19:19 -07:00
|
|
|
class AudioGroup;
|
|
|
|
|
|
|
|
/** Common ID structure statically tagging
|
|
|
|
* SoundMacros, Tables, Keymaps, Layers */
|
2016-05-10 21:48:08 -07:00
|
|
|
using ObjectId = uint16_t;
|
2016-05-02 18:16:26 -07:00
|
|
|
|
|
|
|
/** Common 'engine child' class */
|
|
|
|
class Entity
|
|
|
|
{
|
2016-05-13 21:46:39 -07:00
|
|
|
/* Only the Engine will manage Entity lifetimes,
|
|
|
|
* but shared_ptrs are issued to the client so it can safely track state */
|
2016-05-06 14:22:39 -07:00
|
|
|
friend class Engine;
|
|
|
|
friend class SoundMacroState;
|
2016-05-02 18:16:26 -07:00
|
|
|
protected:
|
2016-05-16 15:13:24 -07:00
|
|
|
bool m_destroyed = false;
|
2016-05-13 23:33:21 -07:00
|
|
|
void _destroy()
|
|
|
|
{
|
|
|
|
#ifndef NDEBUG
|
|
|
|
assert(!m_destroyed);
|
|
|
|
#endif
|
|
|
|
m_destroyed = true;
|
|
|
|
}
|
2016-05-02 18:16:26 -07:00
|
|
|
Engine& m_engine;
|
2016-05-05 22:19:19 -07:00
|
|
|
const AudioGroup& m_audioGroup;
|
2016-05-15 14:56:23 -07:00
|
|
|
int m_groupId;
|
2016-05-14 15:38:37 -07:00
|
|
|
ObjectId m_objectId = 0xffff; /* if applicable */
|
2016-05-02 18:16:26 -07:00
|
|
|
public:
|
2016-05-15 14:56:23 -07:00
|
|
|
Entity(Engine& engine, const AudioGroup& group, int groupId, ObjectId oid=ObjectId())
|
|
|
|
: m_engine(engine), m_audioGroup(group), m_groupId(groupId), m_objectId(oid) {}
|
2016-05-06 14:22:39 -07:00
|
|
|
~Entity()
|
|
|
|
{
|
|
|
|
#ifndef NDEBUG
|
|
|
|
/* Ensure proper destruction procedure followed */
|
|
|
|
assert(m_destroyed);
|
|
|
|
#endif
|
|
|
|
}
|
2016-05-02 18:16:26 -07:00
|
|
|
|
|
|
|
Engine& getEngine() {return m_engine;}
|
2016-05-05 22:19:19 -07:00
|
|
|
const AudioGroup& getAudioGroup() const {return m_audioGroup;}
|
2016-05-15 14:56:23 -07:00
|
|
|
int getGroupId() const {return m_groupId;}
|
2016-05-05 22:19:19 -07:00
|
|
|
ObjectId getObjectId() const {return m_objectId;}
|
2016-05-02 18:16:26 -07:00
|
|
|
};
|
|
|
|
|
2016-05-05 22:19:19 -07:00
|
|
|
/** Curves for mapping velocity to volume and other functional mappings
|
|
|
|
* (defined here for visibility)*/
|
|
|
|
using Curve = uint8_t[128];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-02 18:16:26 -07:00
|
|
|
#endif // __AMUSE_ENTITY_HPP__
|