From ab399cafeb62f7302462081d113bbc1b67b4e15f Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Wed, 18 Feb 2026 02:05:44 -0400 Subject: [PATCH] Improve CONFIG_WORLD_USE_BODY_THREAD handling We no longer need to do ugly ifdefs in the constructor for Mind::Mind because we preprocess the handling for BODY and WORLD in SmoThreadIds. --- smocore/include/componentThread.h | 12 +++++++++--- smocore/mind.cpp | 20 ++++++++------------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/smocore/include/componentThread.h b/smocore/include/componentThread.h index c6d167a..632a537 100644 --- a/smocore/include/componentThread.h +++ b/smocore/include/componentThread.h @@ -1,14 +1,16 @@ #ifndef SMO_COMPONENT_THREAD_H #define SMO_COMPONENT_THREAD_H +#include #include // Include the spinscale componentThread.h which provides ComponentThread, PuppetThread, etc. #include namespace smo { -// Application-specific thread ID enum -// Using regular enum (not enum class) to allow implicit conversion to ThreadId +/* Application-specific thread ID enum + * Using regular enum (not enum class) to allow implicit conversion to ThreadId + */ enum SmoThreadId : sscl::ThreadId { MRNTT = 0, @@ -16,7 +18,11 @@ enum SmoThreadId : sscl::ThreadId SIMULATOR, SUBCONSCIOUS, BODY, - WORLD, + WORLD +#ifdef CONFIG_WORLD_USE_BODY_THREAD + = BODY +#endif + , N_ITEMS }; diff --git a/smocore/mind.cpp b/smocore/mind.cpp index 6ba9946..4e3c54f 100644 --- a/smocore/mind.cpp +++ b/smocore/mind.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -23,18 +24,13 @@ Mind::Mind(void) #ifndef CONFIG_WORLD_USE_BODY_THREAD , std::make_shared(SmoThreadId::WORLD, *this) #endif - }), - director(*this, std::static_pointer_cast(componentThreads[0])), - canvas(*this, std::static_pointer_cast(componentThreads[1])), - subconscious(*this, std::static_pointer_cast(componentThreads[2])), - body(*this, std::static_pointer_cast(componentThreads[3])), - world(*this, -#ifndef CONFIG_WORLD_USE_BODY_THREAD - std::static_pointer_cast(componentThreads[4]) -#else - std::static_pointer_cast(componentThreads[3]) -#endif - ) + } + ), +director(*this, componentThreads[SmoThreadId::DIRECTOR - 1]), +canvas(*this, componentThreads[SmoThreadId::SIMULATOR - 1]), +subconscious(*this, componentThreads[SmoThreadId::SUBCONSCIOUS - 1]), +body(*this, componentThreads[SmoThreadId::BODY - 1]), +world(*this, componentThreads[SmoThreadId::WORLD - 1]) { }