@@ -17,7 +17,11 @@ class context {
|
|||||||
public:
|
public:
|
||||||
friend class executor;
|
friend class executor;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Constructs a context.
|
||||||
|
*/
|
||||||
context();
|
context();
|
||||||
|
|
||||||
~context() = default;
|
~context() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,44 +37,90 @@ public:
|
|||||||
context(const context&) = delete;
|
context(const context&) = delete;
|
||||||
context& operator=(const context&) = delete;
|
context& operator=(const context&) = delete;
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Emplaces a module in the context.
|
||||||
|
*
|
||||||
|
* @param args Arguments forwarded to the module constructor.
|
||||||
|
* @return The emplaced module.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto emplace_module(Args&&... args) {
|
auto emplace_module(Args&&... args) {
|
||||||
return m_modules.emplace(std::forward<Args>(args)...);
|
return m_modules.emplace(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a module from the context.
|
||||||
|
*
|
||||||
|
* @param args Module's id.
|
||||||
|
* @return A handle to the module.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto module_at(Args&&... args) {
|
auto module_at(Args&&... args) {
|
||||||
return m_modules.at(std::forward<Args>(args)...);
|
return m_modules.at(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a module from the context.
|
||||||
|
*
|
||||||
|
* @param args Module's id.
|
||||||
|
* @return A handle to the module.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto module_at(Args&&... args) const {
|
auto module_at(Args&&... args) const {
|
||||||
return m_modules.at(std::forward<Args>(args)...);
|
return m_modules.at(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erases a module from the context.
|
||||||
|
*
|
||||||
|
* @param args Module's id.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto erase_module(Args&&... args) {
|
void erase_module(Args&&... args) {
|
||||||
return m_modules.erase(std::forward<Args>(args)...);
|
m_modules.erase(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Emplaces an executor in the context.
|
||||||
|
*
|
||||||
|
* @param args Arguments forwarded to executor's constructor.
|
||||||
|
* @return A handle to the emplaced executor.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto emplace_executor(Args&&... args) {
|
auto emplace_executor(Args&&... args) {
|
||||||
return m_executors.emplace_back(std::forward<Args>(args)...);
|
return m_executors.emplace_back(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns an executor from the context.
|
||||||
|
*
|
||||||
|
* @param args Id of the executor.
|
||||||
|
* @return A handle to the executor.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto executor_at(Args&&... args) {
|
auto executor_at(Args&&... args) {
|
||||||
return m_executors.at(std::forward<Args>(args)...);
|
return m_executors.at(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns an executor from the context.
|
||||||
|
*
|
||||||
|
* @param args Id of the executor.
|
||||||
|
* @return A handle to the executor.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto executor_at(Args&&... args) const {
|
auto executor_at(Args&&... args) const {
|
||||||
return m_executors.at(std::forward<Args>(args)...);
|
return m_executors.at(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erases an executor from the context.
|
||||||
|
*
|
||||||
|
* @param args Id of the executor.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto erase_executor(Args&&... args) {
|
void erase_executor(Args&&... args) {
|
||||||
return m_executors.erase(std::forward<Args>(args)...);
|
m_executors.erase(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
@@ -78,21 +128,43 @@ public:
|
|||||||
return m_things.emplace_back(std::forward<Args>(args)...);
|
return m_things.emplace_back(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a thing from the context.
|
||||||
|
*
|
||||||
|
* @param args Id of the thing.
|
||||||
|
* @return A handle to the thing.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto thing_at(Args&&... args) {
|
auto thing_at(Args&&... args) {
|
||||||
return m_things.at(std::forward<Args>(args)...);
|
return m_things.at(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns a thing from the context.
|
||||||
|
*
|
||||||
|
* @param args Id of the thing.
|
||||||
|
* @return A handle to the thing.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto thing_at(Args&&... args) const {
|
auto thing_at(Args&&... args) const {
|
||||||
return m_things.at(std::forward<Args>(args)...);
|
return m_things.at(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erases a thing from the context.
|
||||||
|
*
|
||||||
|
* @param args Id of the thing.
|
||||||
|
*/
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto erase_thing(Args&&... args) {
|
void erase_thing(Args&&... args) {
|
||||||
return m_things.erase(std::forward<Args>(args)...);
|
m_things.erase(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns context's thing allocator.
|
||||||
|
*
|
||||||
|
* @return The thing allocator.
|
||||||
|
*/
|
||||||
thing_allocator<std::byte> thing_alloc() const { return m_thingAllocator; }
|
thing_allocator<std::byte> thing_alloc() const { return m_thingAllocator; }
|
||||||
private:
|
private:
|
||||||
handle_container<mod_h> m_modules;
|
handle_container<mod_h> m_modules;
|
||||||
|
|||||||
Reference in New Issue
Block a user