2024-09-04 14:08:50 +10:00
|
|
|
#ifndef _MIND_H
|
|
|
|
|
#define _MIND_H
|
|
|
|
|
|
2025-01-04 07:33:15 -04:00
|
|
|
#include <config.h>
|
2025-08-10 13:12:17 -04:00
|
|
|
#include <functional>
|
2025-09-03 14:43:00 -04:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
2025-12-26 01:18:39 -04:00
|
|
|
#include <spinscale/callback.h>
|
2024-09-08 01:04:41 +10:00
|
|
|
|
2025-12-26 01:18:39 -04:00
|
|
|
#include <spinscale/component.h>
|
2025-12-27 14:01:15 -04:00
|
|
|
#include <spinscale/puppetApplication.h>
|
2025-09-14 22:17:19 -04:00
|
|
|
#include <componentThread.h>
|
2025-12-26 01:18:39 -04:00
|
|
|
#include <mindThread.h>
|
2025-01-04 07:33:15 -04:00
|
|
|
#include <director/director.h>
|
|
|
|
|
#include <simulator/simulator.h>
|
2025-09-14 22:17:19 -04:00
|
|
|
#include <body/body.h>
|
2024-09-04 14:08:50 +10:00
|
|
|
|
2025-07-22 06:48:04 -04:00
|
|
|
namespace smo {
|
2025-01-04 11:32:37 -04:00
|
|
|
|
2025-12-27 14:01:15 -04:00
|
|
|
class Mind
|
|
|
|
|
: public PuppetApplication
|
2024-09-04 14:08:50 +10:00
|
|
|
{
|
2025-01-04 13:21:33 -04:00
|
|
|
public:
|
2025-09-03 14:43:00 -04:00
|
|
|
Mind(void);
|
|
|
|
|
~Mind(void) = default;
|
2025-08-10 13:12:17 -04:00
|
|
|
|
2025-09-11 20:11:10 -04:00
|
|
|
typedef std::function<void(bool)> mindLifetimeMgmtOpCbFn;
|
2025-09-27 18:30:09 -04:00
|
|
|
void initializeReq(Callback<mindLifetimeMgmtOpCbFn> callback);
|
|
|
|
|
void finalizeReq(Callback<mindLifetimeMgmtOpCbFn> callback);
|
2025-01-04 13:21:33 -04:00
|
|
|
|
2025-09-03 14:43:00 -04:00
|
|
|
// ComponentThread access methods
|
2025-12-26 01:18:39 -04:00
|
|
|
std::shared_ptr<MindThread> getComponentThread(ThreadId id) const;
|
2025-09-14 11:07:05 -04:00
|
|
|
std::shared_ptr<MindThread> getComponentThread(
|
2025-09-03 14:43:00 -04:00
|
|
|
const std::string& name) const;
|
|
|
|
|
// Get all this Mind's component threads.
|
2025-09-14 11:07:05 -04:00
|
|
|
std::vector<std::shared_ptr<MindThread>> getMindThreads() const;
|
2025-09-03 14:43:00 -04:00
|
|
|
|
|
|
|
|
// CPU distribution method
|
|
|
|
|
void distributeAndPinThreadsAcrossCpus();
|
|
|
|
|
|
2025-09-14 22:17:19 -04:00
|
|
|
public:
|
|
|
|
|
director::Director director;
|
|
|
|
|
simulator::Simulator canvas;
|
2025-12-27 13:29:49 -04:00
|
|
|
PuppetComponent subconscious;
|
2025-09-14 22:17:19 -04:00
|
|
|
body::Body body;
|
2025-12-27 13:29:49 -04:00
|
|
|
PuppetComponent world;
|
2025-09-03 14:43:00 -04:00
|
|
|
|
|
|
|
|
private:
|
2025-09-14 22:17:19 -04:00
|
|
|
friend class body::Body;
|
2025-12-27 14:01:15 -04:00
|
|
|
bool bodyComponentInitialized = false;
|
2025-09-11 20:11:10 -04:00
|
|
|
|
2025-09-14 22:17:19 -04:00
|
|
|
private:
|
2025-09-11 20:11:10 -04:00
|
|
|
class MindLifetimeMgmtOp;
|
2024-09-04 14:08:50 +10:00
|
|
|
};
|
|
|
|
|
|
2025-09-15 12:47:09 -04:00
|
|
|
namespace mind {
|
2025-09-03 14:43:00 -04:00
|
|
|
// Global Mind instance will be defined in marionette.cpp
|
|
|
|
|
extern std::shared_ptr<Mind> globalMind;
|
2025-09-15 12:47:09 -04:00
|
|
|
} // namespace mind
|
2025-08-10 13:12:17 -04:00
|
|
|
|
2025-07-22 06:48:04 -04:00
|
|
|
} // namespace smo
|
2025-01-04 11:32:37 -04:00
|
|
|
|
2024-09-04 14:08:50 +10:00
|
|
|
#endif
|