Skip to content

Commit

Permalink
Documentation for module 'NDK'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gawaboumga committed Aug 21, 2016
1 parent 02ad889 commit 4f50141
Show file tree
Hide file tree
Showing 75 changed files with 3,369 additions and 107 deletions.
50 changes: 49 additions & 1 deletion SDK/include/NDK/Algorithm.inl
Expand Up @@ -6,7 +6,15 @@

namespace Ndk
{
///TODO: constexpr avec le C++14
/*!
* \ingroup NDK
* \brief Builds a component id based on a name
* \return Identifier for the component
*
* \param name Name to generate id from
*/

///TODO: constexpr with the C++14
template<unsigned int N>
ComponentId BuildComponentId(const char (&name)[N])
{
Expand All @@ -19,38 +27,78 @@ namespace Ndk
return componentId;
}

/*!
* \ingroup NDK
* \brief Gets the component id of a component
* \return Identifier for the component
*/

template<typename ComponentType>
ComponentIndex GetComponentIndex()
{
return ComponentType::componentIndex;
}

/*!
* \ingroup NDK
* \brief Gets the system id of a system
* \return Identifier for the system
*/

template<typename SystemType>
SystemIndex GetSystemIndex()
{
return SystemType::systemIndex;
}

/*!
* \ingroup NDK
* \brief Initializes the a component
* \return Identifier for the component
*
* \param name Name to generate id from
*/

template<typename ComponentType, unsigned int N>
ComponentIndex InitializeComponent(const char (&name)[N])
{
ComponentType::componentIndex = ComponentType::RegisterComponent(name);
return ComponentType::componentIndex;
}

/*!
* \ingroup NDK
* \brief Initializes the a system
* \return Identifier for the system
*/

template<typename SystemType>
SystemIndex InitializeSystem()
{
SystemType::systemIndex = SystemType::RegisterSystem();
return SystemType::systemIndex;
}

/*!
* \brief Checks whether the parameter is a component
* \return true If it is the case
*
* \param component Component to check
*/

template<typename ComponentType, typename C>
bool IsComponent(C& component)
{
return component.GetIndex() == GetComponentIndex<ComponentType>();
}

/*!
* \brief Checks whether the parameter is a system
* \return true If it is the case
*
* \param system System to check
*/

template<typename SystemType, typename S>
bool IsSystem(S& system)
{
Expand Down
48 changes: 46 additions & 2 deletions SDK/include/NDK/Application.inl
Expand Up @@ -8,6 +8,12 @@

namespace Ndk
{
/*!
* \brief Constructs an Application object by default
*
* \remark Produces a NazaraAssert if there's more than one application instance currently running
*/

inline Application::Application() :
#ifndef NDK_SERVER
m_exitOnClosedWindows(true),
Expand All @@ -24,20 +30,31 @@ namespace Ndk
Sdk::Initialize();
}

/*!
* \brief Destructs the object
*/

inline Application::~Application()
{
m_worlds.clear();
#ifndef NDK_SERVER
m_windows.clear();
#endif

// Libération du SDK
// Free of SDK
Sdk::Uninitialize();

// Libération automatique des modules
// Automatic free of modules
s_application = nullptr;
}

/*!
* \brief Adds a window to the application
* \return A reference to the newly created windows
*
* \param args Arguments used to create the window
*/

#ifndef NDK_SERVER
template<typename T, typename... Args>
T& Application::AddWindow(Args&&... args)
Expand All @@ -49,30 +66,57 @@ namespace Ndk
}
#endif

/*!
* \brief Adds a world to the application
* \return A reference to the newly created world
*
* \param args Arguments used to create the world
*/

template<typename... Args>
World& Application::AddWorld(Args&&... args)
{
m_worlds.emplace_back(std::forward<Args>(args)...);
return m_worlds.back();
}

/*!
* \brief Gets the update time of the application
* \return Update rate
*/

inline float Application::GetUpdateTime() const
{
return m_updateTime;
}

/*!
* \brief Makes the application exit when there's no more open window
*
* \param exitOnClosedWindows Should exit be called when no more window is open
*/

#ifndef NDK_SERVER
inline void Application::MakeExitOnLastWindowClosed(bool exitOnClosedWindows)
{
m_exitOnClosedWindows = exitOnClosedWindows;
}
#endif

/*!
* \brief Quits the application
*/

inline void Application::Quit()
{
m_shouldQuit = true;
}

/*!
* \brief Gets the singleton instance of the application
* \return Singleton application
*/

inline Application* Application::Instance()
{
return s_application;
Expand Down
2 changes: 1 addition & 1 deletion SDK/include/NDK/BaseComponent.hpp
Expand Up @@ -27,7 +27,7 @@ namespace Ndk
BaseComponent(BaseComponent&&) = default;
virtual ~BaseComponent();

virtual BaseComponent* Clone() const = 0;
virtual std::unique_ptr<BaseComponent> Clone() const = 0;

ComponentIndex GetIndex() const;

Expand Down
47 changes: 43 additions & 4 deletions SDK/include/NDK/BaseComponent.inl
Expand Up @@ -7,41 +7,71 @@

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;

return index;
}

/*!
* \brief Sets the entity on which the component operates
*/

inline void BaseComponent::SetEntity(Entity* entity)
{
if (m_entity != entity)
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion SDK/include/NDK/BaseSystem.hpp
Expand Up @@ -29,7 +29,7 @@ namespace Ndk

inline void Enable(bool enable = true);

virtual BaseSystem* Clone() const = 0;
virtual std::unique_ptr<BaseSystem> Clone() const = 0;

bool Filters(const Entity* entity) const;

Expand Down

0 comments on commit 4f50141

Please sign in to comment.