# Amuse: include/amuse/Entity.hpp Source File

Entity.hpp
#ifndef __AMUSE_ENTITY_HPP__
#define __AMUSE_ENTITY_HPP__
#include <stdint.h>
#include <functional>
#include <assert.h>
namespace amuse
{
class Engine;
class AudioGroup;
using ObjectId = uint16_t;
class Entity
{
/* Only the Engine will manage Entity lifetimes,
* but shared_ptrs are issued to the client so it can safely track state */
friend class Engine;
friend class SoundMacroState;
protected:
bool m_destroyed = false;
void _destroy()
{
#ifndef NDEBUG
assert(!m_destroyed);
#endif
m_destroyed = true;
}
Engine& m_engine;
const AudioGroup& m_audioGroup;
int m_groupId;
ObjectId m_objectId = 0xffff; /* if applicable */
public:
Entity(Engine& engine, const AudioGroup& group, int groupId, ObjectId oid=ObjectId())
: m_engine(engine), m_audioGroup(group), m_groupId(groupId), m_objectId(oid) {}
~Entity()
{
#ifndef NDEBUG
/* Ensure proper destruction procedure followed */
assert(m_destroyed);
#endif
}
Engine& getEngine() {return m_engine;}
const AudioGroup& getAudioGroup() const {return m_audioGroup;}
int getGroupId() const {return m_groupId;}
ObjectId getObjectId() const {return m_objectId;}
};
using Curve = uint8_t[128];
}
#endif // __AMUSE_ENTITY_HPP__
amuse::AudioGroup
Definition: AudioGroup.hpp:16
amuse
Definition: AudioGroup.hpp:8
amuse::Engine
Definition: Engine.hpp:23
amuse::SoundMacroState
Definition: SoundMacroState.hpp:14
amuse::Entity
Definition: Entity.hpp:18