From f12f0c1231d3171d6b27ffcf82ffb4d3111cfac3 Mon Sep 17 00:00:00 2001 From: Peter Gentium Date: Fri, 22 Nov 2024 13:11:33 +1100 Subject: [PATCH] Refactor body-related classes and add new interoceptor functionality --- .vscode/c_cpp_properties.json | 25 ++++++++ .vscode/settings.json | 5 ++ core/Makefile.in | 44 +++++++++++++- core/include/attentionGrabber.h | 11 ++-- core/include/body/bodyMap.h | 17 ++++++ core/include/body/bodyMessage.h | 64 ++++++++++++++++++++ core/include/body/bodyPart.h | 42 +++++++++++++ core/include/body/limb.h | 28 +++++++++ core/include/bodyCoords.h | 12 ---- core/include/sensors/interoceptor.h | 92 +++++++++++++++++++++++++++++ core/include/stupefier.h | 30 ++++++++++ 11 files changed, 350 insertions(+), 20 deletions(-) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/settings.json create mode 100644 core/include/body/bodyMap.h create mode 100644 core/include/body/bodyMessage.h create mode 100644 core/include/body/bodyPart.h create mode 100644 core/include/body/limb.h delete mode 100644 core/include/bodyCoords.h create mode 100644 core/include/sensors/interoceptor.h create mode 100644 core/include/stupefier.h diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..5896992 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,25 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/core/include", + "/usr/include", + "/usr/local/include" + ], + "defines": [], + "compilerPath": "/usr/bin/g++", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "linux-gcc-x64", + "browse": { + "path": [ + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true + } + } + ], + "version": 4 +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..af13e3a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "cstdint": "cpp" + } +} \ No newline at end of file diff --git a/core/Makefile.in b/core/Makefile.in index bd38b45..907ea3b 100644 --- a/core/Makefile.in +++ b/core/Makefile.in @@ -99,7 +99,8 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) -am_harikoff_OBJECTS = harikoff-main.$(OBJEXT) +am_harikoff_OBJECTS = harikoff-main.$(OBJEXT) \ + harikoff-painfulQuale.$(OBJEXT) harikoff-mind.$(OBJEXT) harikoff_OBJECTS = $(am_harikoff_OBJECTS) harikoff_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) @@ -117,7 +118,9 @@ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/harikoff-main.Po +am__depfiles_remade = ./$(DEPDIR)/harikoff-main.Po \ + ./$(DEPDIR)/harikoff-mind.Po \ + ./$(DEPDIR)/harikoff-painfulQuale.Po am__mv = mv -f AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -241,6 +244,7 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ +num_sensors = @num_sensors@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ @@ -255,7 +259,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -harikoff_SOURCES = main.cpp +harikoff_SOURCES = main.cpp painfulQuale.cpp mind.cpp harikoff_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/core/include all: all-am @@ -344,6 +348,8 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harikoff-main.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harikoff-mind.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/harikoff-painfulQuale.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -379,6 +385,34 @@ harikoff-main.obj: main.cpp @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o harikoff-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi` +harikoff-painfulQuale.o: painfulQuale.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT harikoff-painfulQuale.o -MD -MP -MF $(DEPDIR)/harikoff-painfulQuale.Tpo -c -o harikoff-painfulQuale.o `test -f 'painfulQuale.cpp' || echo '$(srcdir)/'`painfulQuale.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/harikoff-painfulQuale.Tpo $(DEPDIR)/harikoff-painfulQuale.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='painfulQuale.cpp' object='harikoff-painfulQuale.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o harikoff-painfulQuale.o `test -f 'painfulQuale.cpp' || echo '$(srcdir)/'`painfulQuale.cpp + +harikoff-painfulQuale.obj: painfulQuale.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT harikoff-painfulQuale.obj -MD -MP -MF $(DEPDIR)/harikoff-painfulQuale.Tpo -c -o harikoff-painfulQuale.obj `if test -f 'painfulQuale.cpp'; then $(CYGPATH_W) 'painfulQuale.cpp'; else $(CYGPATH_W) '$(srcdir)/painfulQuale.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/harikoff-painfulQuale.Tpo $(DEPDIR)/harikoff-painfulQuale.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='painfulQuale.cpp' object='harikoff-painfulQuale.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o harikoff-painfulQuale.obj `if test -f 'painfulQuale.cpp'; then $(CYGPATH_W) 'painfulQuale.cpp'; else $(CYGPATH_W) '$(srcdir)/painfulQuale.cpp'; fi` + +harikoff-mind.o: mind.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT harikoff-mind.o -MD -MP -MF $(DEPDIR)/harikoff-mind.Tpo -c -o harikoff-mind.o `test -f 'mind.cpp' || echo '$(srcdir)/'`mind.cpp +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/harikoff-mind.Tpo $(DEPDIR)/harikoff-mind.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='mind.cpp' object='harikoff-mind.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o harikoff-mind.o `test -f 'mind.cpp' || echo '$(srcdir)/'`mind.cpp + +harikoff-mind.obj: mind.cpp +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT harikoff-mind.obj -MD -MP -MF $(DEPDIR)/harikoff-mind.Tpo -c -o harikoff-mind.obj `if test -f 'mind.cpp'; then $(CYGPATH_W) 'mind.cpp'; else $(CYGPATH_W) '$(srcdir)/mind.cpp'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/harikoff-mind.Tpo $(DEPDIR)/harikoff-mind.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='mind.cpp' object='harikoff-mind.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(harikoff_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o harikoff-mind.obj `if test -f 'mind.cpp'; then $(CYGPATH_W) 'mind.cpp'; else $(CYGPATH_W) '$(srcdir)/mind.cpp'; fi` + ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am @@ -506,6 +540,8 @@ clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -f ./$(DEPDIR)/harikoff-main.Po + -rm -f ./$(DEPDIR)/harikoff-mind.Po + -rm -f ./$(DEPDIR)/harikoff-painfulQuale.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -552,6 +588,8 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/harikoff-main.Po + -rm -f ./$(DEPDIR)/harikoff-mind.Po + -rm -f ./$(DEPDIR)/harikoff-painfulQuale.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/core/include/attentionGrabber.h b/core/include/attentionGrabber.h index bc3ccad..4044fc7 100644 --- a/core/include/attentionGrabber.h +++ b/core/include/attentionGrabber.h @@ -9,16 +9,17 @@ class AttentionGrabber { public: AttentionGrabber(AttentionTrigger cause, Chronomenon chron) - : isNull(false) - {} + : isNull(false) + { + } void setNull(void) { isNull = true; } int operator!(void) { return isNull; } public: - AttentionTrigger cause; - Chronomenon chron; - bool isNull; + AttentionTrigger cause; + Chronomenon chron; + bool isNull; }; #endif diff --git a/core/include/body/bodyMap.h b/core/include/body/bodyMap.h new file mode 100644 index 0000000..a969488 --- /dev/null +++ b/core/include/body/bodyMap.h @@ -0,0 +1,17 @@ +#ifndef _BODY_MAP_H +#define _BODY_MAP_H + +#include +#include + +#include + +class BodyMap { +public: + BodyMap() = default; + ~BodyMap() = default; + + std::set limbs; +}; + +#endif // _BODY_MAP_H diff --git a/core/include/body/bodyMessage.h b/core/include/body/bodyMessage.h new file mode 100644 index 0000000..d78afd7 --- /dev/null +++ b/core/include/body/bodyMessage.h @@ -0,0 +1,64 @@ +#ifndef BODY_MESSAGE_H +#define BODY_MESSAGE_H + +#include +#include + +#include +#include + +class BodyMessage +{ +public: + BodyMessage() = default; + ~BodyMessage() = default; +}; + +class BodySpotImpactEntry +{ +public: + enum class ReportType + { + PRESSURE, + PAIN, + PLEASURE, + HEAT, + COLD + }; + + BodySpotImpactEntry(uint32_t _spot, ReportType _type, uint32_t _value) + : spot(_spot), type(_type), value(_value) + {} + ~BodySpotImpactEntry() = default; + +public: + uint32_t spot; + ReportType type; + uint32_t value; +}; + +class BodySpotImpactInd +: public BodyMessage +{ +public: + BodySpotImpactInd(BodyPart &_part) : part(_part) {} + ~BodySpotImpactInd() = default; + +public: + BodyPart ∂ + std::vector entries; +}; + +class BodyPartMsg +: public BodyMessage +{ +public: + BodyPartMsg(const BodyPart& _part) + :part(_part) + {} + +public: + const BodyPart& part; +}; + +#endif // BODY_MESSAGE_H \ No newline at end of file diff --git a/core/include/body/bodyPart.h b/core/include/body/bodyPart.h new file mode 100644 index 0000000..3b01c83 --- /dev/null +++ b/core/include/body/bodyPart.h @@ -0,0 +1,42 @@ +#ifndef BODYPART_H +#define BODYPART_H + +#include +#include +#include + +#include + +class BodySpot +{ +public: + BodySpot(uint32_t _id, std::string _description) + : id(_id), description(_description) + {} + + ~BodySpot() = default; + +public: + uint32_t id; + std::string description; + std::set interoceptors; +}; + +class BodyPart +{ +public: + BodyPart(uint32_t _partId, std::string _partName, + std::string _partDesc, std::string _partLoc) + : id(_partId), name(_partName), + description(_partDesc), location(_partLoc) + {} + + ~BodyPart() = default; + +public: + const uint32_t id; + std::string name, description, location; + std::set spots; +}; + +#endif // BODYPART_H diff --git a/core/include/body/limb.h b/core/include/body/limb.h new file mode 100644 index 0000000..adb5b79 --- /dev/null +++ b/core/include/body/limb.h @@ -0,0 +1,28 @@ +#ifndef BODY_LIMB_H +#define BODY_LIMB_H + +#include +#include +#include + +#include + +class BodyLimb +{ +public: + BodyLimb(uint32_t _id) : id(_id) {} + BodyLimb(uint32_t _id, + const std::string& _name, const std::string& _desc, + const std::string& _loc) + : id(_id), name(_name), description(_desc), location(_loc) + {} + + ~BodyLimb() = default; + +public: + uint32_t id; + std::string name, description, location; + std::set parts; +}; + +#endif // BODY_LIMB_H diff --git a/core/include/bodyCoords.h b/core/include/bodyCoords.h deleted file mode 100644 index b7c73cc..0000000 --- a/core/include/bodyCoords.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _BODY_LOCUS_H -#define _BODY_LOCUS_H - -#include - -class BodyCoords -{ - uint32_t segment; - uint32_t coord; -}; - -#endif diff --git a/core/include/sensors/interoceptor.h b/core/include/sensors/interoceptor.h new file mode 100644 index 0000000..be1db6e --- /dev/null +++ b/core/include/sensors/interoceptor.h @@ -0,0 +1,92 @@ +#ifndef _INTEROCEPTOR_H +#define _INTEROCEPTOR_H + +#include + +class Interoceptor { +public: + Interoceptor(uint32_t _id, uint32_t _value = 0) + : id(_id), value(_value) + {} + ~Interoceptor() = default; + +public: + uint32_t id, value; +}; + +class NeutralInteroceptor +: public Interoceptor { +public: + NeutralInteroceptor(uint32_t _id, uint32_t _value = 0) + : Interoceptor(_id, _value) + {} +}; + +class IntrinInteroceptor +: public Interoceptor { +public: + static constexpr uint32_t DEFAULT_INDICATION_THRESHOLD = 1; + static constexpr uint32_t DEFAULT_ALERT_THRESHOLD = 5; + static constexpr uint32_t DEFAULT_OVERLOAD_THRESHOLD = 9; + + IntrinInteroceptor( + uint32_t _id, + uint32_t _value = 0, + uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD, + uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD, + uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD) + : Interoceptor(_id, _value), + indicationThreshold(_indicationThreshold), + alertThreshold(_alertThreshold), + overloadThreshold(_overloadThreshold) + {} + + ~IntrinInteroceptor() = default; + +public: + uint32_t indicationThreshold; + uint32_t alertThreshold; + uint32_t overloadThreshold; +}; + +/** + * Pain and pleasure interoceptors are specialized intrinsic interoceptors that, unlike + * neutral interoceptors, have activation thresholds for different response levels + * (indication, alert, and overload). These thresholds allow them to trigger graduated + * responses based on stimulus intensity. + * + * While neutral interoceptors simply record a binary state or basic value, pain and + * pleasure interoceptors can model complex sensory responses with multiple activation + * levels, similar to biological pain/pleasure responses. Each threshold represents a + * different level of urgency or intensity in the sensory input. + * + * @see IntrinInteroceptor for the threshold values and implementation details + *****************************************************************************************/ + +class PainInteroceptor +: public IntrinInteroceptor { +public: + PainInteroceptor( + uint32_t _id, + uint32_t _value = 0, + uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD, + uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD, + uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD) + : IntrinInteroceptor(_id, _value, _indicationThreshold, _alertThreshold, _overloadThreshold) + {} +}; + +class PleasureInteroceptor +: public IntrinInteroceptor { +public: + PleasureInteroceptor( + uint32_t _id, + uint32_t _value = 0, + uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD, + uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD, + uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD) + : IntrinInteroceptor(_id, _value, _indicationThreshold, _alertThreshold, _overloadThreshold) + {} +}; + +#endif // _INTEROCEPTOR_H diff --git a/core/include/stupefier.h b/core/include/stupefier.h new file mode 100644 index 0000000..3e08b4c --- /dev/null +++ b/core/include/stupefier.h @@ -0,0 +1,30 @@ +#ifndef STUPEFIER_H +#define STUPEFIER_H + +#include + +class Stupefier { +public: + Stupefier(); + ~Stupefier(); + + void up(uint32_t); + void down(uint32_t); + +public: + uint32_t focus; +}; + +class SoftStupefier : public Stupefier { +public: + SoftStupefier(); + ~SoftStupefier(); +}; + +class HardStupefier : public Stupefier { +public: + HardStupefier(); + ~HardStupefier(); +}; + +#endif // STUPEFIER_H \ No newline at end of file