context in core

This commit is contained in:
AndreaRigoni
2026-03-21 16:30:56 +00:00
parent cd95f16221
commit 0bff36f8ba
6 changed files with 163 additions and 26 deletions

59
src/Core/ObjectsContext.h Normal file
View File

@@ -0,0 +1,59 @@
#ifndef U_CORE_OBJECTS_CONTEXT_H
#define U_CORE_OBJECTS_CONTEXT_H
#include "Core/Object.h"
#include <vector>
namespace uLib {
/**
* @brief ObjectsContext represents a collection of Object instances.
*/
class ObjectsContext : public Object {
public:
ObjectsContext();
virtual ~ObjectsContext();
/**
* @brief Adds an object to the context.
* @param obj Pointer to the object to add.
*/
void AddObject(Object* obj);
/**
* @brief Removes an object from the context.
* @param obj Pointer to the object to remove.
*/
void RemoveObject(Object* obj);
/**
* @brief Clears all objects from the context.
*/
void Clear();
/**
* @brief Returns the collection of objects.
* @return Const reference to the vector of object pointers.
*/
const std::vector<Object*>& GetObjects() const;
/**
* @brief Returns the number of objects in the context.
* @return Size of the collection.
*/
size_t GetCount() const;
/**
* @brief Returns an object by index.
* @param index The index of the object.
* @return Pointer to the object or nullptr if index is out of bounds.
*/
Object* GetObject(size_t index) const;
private:
std::vector<Object*> m_objects;
};
} // namespace uLib
#endif // U_CORE_OBJECTS_CONTEXT_H