91ccd16b33
This makes the initialization sequence much cleaner and conceptually well encapsulated. We also now dynamically allocate the Mind objects. They're allocated dynamically by Mrntt inside of initializeReq. This means that we no longer have to worry about jolting and cleaning up the running threads of global mind object even when we never explicitly called Mind.initializeReq. Along with other conceptual improvements to our abstractions, this patch also gets us to a real "end of program initialization" point for the first time.
49 lines
975 B
C++
49 lines
975 B
C++
#ifndef _SMO_MIND_MANAGER_H
|
|
#define _SMO_MIND_MANAGER_H
|
|
|
|
#include <config.h>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include <mind.h>
|
|
|
|
namespace smo {
|
|
namespace mind {
|
|
|
|
/** EXPLANATION:
|
|
* MindManager is responsible for managing the lifecycle of all minds.
|
|
* It is responsible for creating, destroying, and managing the minds.
|
|
*
|
|
* For now it does nothing since we haven't yet added support for multiple
|
|
* minds.
|
|
*/
|
|
class MindManager
|
|
{
|
|
public:
|
|
MindManager(void) = default;
|
|
~MindManager(void) = default;
|
|
|
|
static MindManager& getInstance()
|
|
{
|
|
static MindManager instance;
|
|
return instance;
|
|
}
|
|
|
|
public:
|
|
void initialize(void) {};
|
|
void finalize(void) {};
|
|
|
|
std::shared_ptr<Mind> getMind(void) const;
|
|
void addMind(const std::shared_ptr<Mind>& mind);
|
|
void removeMind(const std::shared_ptr<Mind>& mind);
|
|
|
|
public:
|
|
std::vector<std::shared_ptr<Mind>> minds;
|
|
};
|
|
|
|
extern std::shared_ptr<Mind> globalMind;
|
|
|
|
} // namespace mind
|
|
} // namespace smo
|
|
|
|
#endif // _SMO_MIND_MANAGER_H
|