Documentation for module 'NDK'
Former-commit-id: 63e1cac538c577a1f1aafa71fa7eef69a6d4daab [formerly b2d8769fd02a0e7d9c476d4ad7be1988a1fd6789] [formerly 636b5cb79bcb8da44d9aa45ba1023565bcf29f0d [formerly a2361ec2b8679d4d4ba096e543b5d4b91825dd62]] Former-commit-id: d402d35477f9db0135c553d55c401939426bf62d [formerly 607336ea0f42731e4604f3a8c2df06f3aecfc401] Former-commit-id: 69e23cd6c06723486de5e4641ce810012dac66da
This commit is contained in:
@@ -7,34 +7,60 @@
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a BaseComponent object with an index
|
||||
*
|
||||
* \param index Index of the component
|
||||
*/
|
||||
|
||||
inline BaseComponent::BaseComponent(ComponentIndex index) :
|
||||
m_componentIndex(index),
|
||||
m_entity(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the index of the component
|
||||
* \return Index of the component
|
||||
*/
|
||||
|
||||
inline ComponentIndex BaseComponent::GetIndex() const
|
||||
{
|
||||
return m_componentIndex;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Gets the maximal index of the components
|
||||
* \return Index of the maximal component
|
||||
*/
|
||||
|
||||
inline ComponentIndex BaseComponent::GetMaxComponentIndex()
|
||||
{
|
||||
return static_cast<ComponentIndex>(s_entries.size());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Registers a component
|
||||
* \return Index of the registered component
|
||||
*
|
||||
* \param id Index of the component
|
||||
* \param factory Factory to create the component
|
||||
*
|
||||
* \remark Produces a NazaraAssert if the identifier is already in use
|
||||
*/
|
||||
|
||||
inline ComponentIndex BaseComponent::RegisterComponent(ComponentId id, Factory factoryFunc)
|
||||
{
|
||||
// Nous allons rajouter notre composant à la fin
|
||||
// We add our component to the end
|
||||
ComponentIndex index = static_cast<ComponentIndex>(s_entries.size());
|
||||
s_entries.resize(index + 1);
|
||||
|
||||
// On récupère et on affecte
|
||||
// We retrieve it and affect it
|
||||
ComponentEntry& entry = s_entries.back();
|
||||
entry.factory = factoryFunc;
|
||||
entry.id = id;
|
||||
|
||||
// Une petite assertion pour s'assurer que l'identifiant n'est pas déjà utilisé
|
||||
// We ensure that id is not already in use
|
||||
NazaraAssert(s_idToIndex.find(id) == s_idToIndex.end(), "This id is already in use");
|
||||
|
||||
s_idToIndex[id] = index;
|
||||
@@ -42,6 +68,10 @@ namespace Ndk
|
||||
return index;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets the entity on which the component operates
|
||||
*/
|
||||
|
||||
inline void BaseComponent::SetEntity(Entity* entity)
|
||||
{
|
||||
if (m_entity != entity)
|
||||
@@ -55,12 +85,21 @@ namespace Ndk
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Initializes the BaseComponent
|
||||
* \return true
|
||||
*/
|
||||
|
||||
inline bool BaseComponent::Initialize()
|
||||
{
|
||||
// Rien à faire
|
||||
// Nothing to do
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Uninitializes the BaseComponent
|
||||
*/
|
||||
|
||||
inline void BaseComponent::Uninitialize()
|
||||
{
|
||||
s_entries.clear();
|
||||
|
||||
Reference in New Issue
Block a user