Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/raoulkdev/MiniECS/llms.txt

Use this file to discover all available pages before exploring further.

MiniECS::ModuleType is a scoped enum (enum class) that identifies module types throughout the framework. It is used by Unit::addModule() and Unit::removeModule() to specify which Module to create or destroy, and internally by Module::getType() for duplicate prevention and type-based lookup. Because it is a scoped enum, all values must be fully qualified with the enum name.
#include "modules/module_base/Module.h"

Enum Definition

enum class ModuleType
{
    ModuleBase = 0,
    Transform  = 1,
    Renderer   = 2
};

Values

ValueIntegerConcrete ClassDescription
ModuleType::ModuleBase0ModuleBase type. Not normally used directly as a component; serves as the identity for the abstract base class.
ModuleType::Transform1TransformModule2D position, rotation, and scale. Requires GLM.
ModuleType::Renderer2RendererModuleRendering lifecycle hook; prints a start message each frame.

Usage

Qualified enum values are passed to Unit::addModule() and Unit::removeModule():
MiniECS::World world("Scene");
world.createUnit("Sprite");

auto& sprite = world.getUnitByName("Sprite");

// Add modules using qualified enum values
sprite->addModule(MiniECS::ModuleType::Transform);
sprite->addModule(MiniECS::ModuleType::Renderer);

// Remove a module
sprite->removeModule(MiniECS::ModuleType::Renderer);
The Module constructor uses ModuleType to resolve the human-readable name returned by getTypeName(), and the enum value itself is accessible at any time via getType():
auto* t = sprite->getModule<MiniECS::TransformModule>();
if (t && t->getType() == MiniECS::ModuleType::Transform)
{
    t->position = glm::vec2(0.0f, 0.0f);
}
Because ModuleType is an enum class, values are not implicitly convertible to or from integers. You must always use the fully qualified form MiniECS::ModuleType::Transform, not a bare 1.

Adding a Custom Module Type

To extend the framework with a new Module type, follow these steps: 1. Add a value to the enum in Module.h:
enum class ModuleType
{
    ModuleBase = 0,
    Transform  = 1,
    Renderer   = 2,
    Physics    = 3  // new entry
};
2. Create a subclass of Module:
// PhysicsModule.h
#include "modules/module_base/Module.h"

namespace MiniECS
{
    class PhysicsModule : public Module
    {
    public:
        using Module::Module;
        void start() override;
    };
}
3. Register the new type in Unit::addModule()’s switch statement in Unit.cpp:
case ModuleType::Physics:
    modules.push_back(std::make_unique<PhysicsModule>(ModuleType::Physics));
    break;
4. Optionally add a name mapping in the Module constructor’s switch statement in Module.cpp:
case ModuleType::Physics:
    moduleTypeName = "Physics";
    break;
For a full walkthrough, see the Custom Module guide.
Assign integer values explicitly when adding new enum entries. This keeps the mapping between enum values and concrete classes stable if you ever serialise module types to disk or transmit them over a network.

Build docs developers (and LLMs) love