From bf5ea8d20816fb6f4438c85cd9482119036412db Mon Sep 17 00:00:00 2001 From: Trent Houliston Date: Wed, 3 Jun 2026 15:46:13 +1000 Subject: [PATCH 1/9] Remove old nuclear subtree before NUClearNet 2 import Co-authored-by: Cursor --- src/nuclear/.clang-format | 86 -- src/nuclear/.clang-tidy | 72 -- src/nuclear/.cmake-format.py | 215 ---- src/nuclear/.github/dependabot.yaml | 9 - src/nuclear/.github/workflows/gcc.yaml | 105 -- src/nuclear/.github/workflows/linting.yaml | 99 -- src/nuclear/.github/workflows/macos.yaml | 73 -- src/nuclear/.github/workflows/sonarcloud.yaml | 90 -- src/nuclear/.github/workflows/windows.yaml | 94 -- src/nuclear/.gitignore | 29 - src/nuclear/.readthedocs.yaml | 22 - src/nuclear/.vscode/settings.json | 19 - src/nuclear/CMakeLists.txt | 98 -- src/nuclear/LICENSE | 7 - src/nuclear/NUClear.sublime-project | 15 - src/nuclear/README.md | 31 - src/nuclear/cmake/ClangTidy.cmake | 22 - src/nuclear/cmake/CompilerOptions.cmake | 7 - src/nuclear/cmake/Modules/FindSphinx.cmake | 24 - .../Modules/ToolchainLibraryFinder.cmake | 144 --- src/nuclear/cmake/NUClearConfig.cmake.in | 9 - src/nuclear/cmake/Sanitizers.cmake | 47 - src/nuclear/docs/.special.rst | 40 - src/nuclear/docs/CMakeLists.txt | 37 - src/nuclear/docs/Doxyfile | 12 - src/nuclear/docs/_static/colours.css | 33 - src/nuclear/docs/components.rst | 66 - src/nuclear/docs/conf.py | 358 ------ src/nuclear/docs/definitions.rst | 67 - src/nuclear/docs/dsl.rst | 224 ---- src/nuclear/docs/extension.rst | 220 ---- src/nuclear/docs/images/blackboard.svg | 244 ---- .../docs/images/blackboard_architecture.svg | 656 ---------- .../blackboard_architecture_coupled.svg | 826 ------------ src/nuclear/docs/images/co-message.svg | 364 ------ .../docs/images/message_passing_system.svg | 430 ------- src/nuclear/docs/images/on_statement.svg | 111 -- src/nuclear/docs/images/power_plant.svg | 721 ----------- src/nuclear/docs/images/reactors.svg | 491 -------- src/nuclear/docs/index.rst | 25 - src/nuclear/docs/managing_reactions.rst | 29 - src/nuclear/docs/networking.rst | 50 - src/nuclear/docs/overview.rst | 11 - src/nuclear/docs/quick_start.rst | 14 - src/nuclear/docs/requirements.txt | 4 - src/nuclear/docs/startup.rst | 196 --- src/nuclear/sonar-project.properties | 9 - src/nuclear/src/CMakeLists.txt | 88 -- src/nuclear/src/Configuration.hpp | 42 - src/nuclear/src/Environment.hpp | 59 - src/nuclear/src/LogLevel.cpp | 56 - src/nuclear/src/LogLevel.hpp | 131 -- src/nuclear/src/PowerPlant.cpp | 130 -- src/nuclear/src/PowerPlant.hpp | 358 ------ src/nuclear/src/Reactor.hpp | 497 -------- src/nuclear/src/clock.cpp | 85 -- src/nuclear/src/clock.hpp | 102 -- src/nuclear/src/dsl/Fusion.hpp | 58 - src/nuclear/src/dsl/Parse.hpp | 95 -- src/nuclear/src/dsl/fusion/BindFusion.hpp | 125 -- src/nuclear/src/dsl/fusion/FindWords.hpp | 50 - src/nuclear/src/dsl/fusion/GetFusion.hpp | 84 -- src/nuclear/src/dsl/fusion/GroupFusion.hpp | 80 -- src/nuclear/src/dsl/fusion/InlineFusion.hpp | 82 -- src/nuclear/src/dsl/fusion/NoOp.hpp | 130 -- src/nuclear/src/dsl/fusion/PoolFusion.hpp | 74 -- src/nuclear/src/dsl/fusion/PostRunFusion.hpp | 76 -- src/nuclear/src/dsl/fusion/PreRunFusion.hpp | 76 -- .../src/dsl/fusion/PreconditionFusion.hpp | 74 -- src/nuclear/src/dsl/fusion/PriorityFusion.hpp | 74 -- src/nuclear/src/dsl/fusion/ScopeFusion.hpp | 84 -- .../src/dsl/fusion/has_nuclear_dsl_method.hpp | 60 - src/nuclear/src/dsl/operation/CacheGet.hpp | 58 - src/nuclear/src/dsl/operation/ChronoTask.hpp | 110 -- src/nuclear/src/dsl/operation/DSLProxy.hpp | 46 - src/nuclear/src/dsl/operation/TypeBind.hpp | 91 -- src/nuclear/src/dsl/operation/Unbind.hpp | 53 - src/nuclear/src/dsl/store/DataStore.hpp | 51 - src/nuclear/src/dsl/store/ThreadStore.hpp | 60 - .../src/dsl/store/TypeCallbackStore.hpp | 53 - src/nuclear/src/dsl/trait/is_transient.hpp | 50 - src/nuclear/src/dsl/validation/Validation.hpp | 57 - src/nuclear/src/dsl/word/Always.hpp | 153 --- src/nuclear/src/dsl/word/Buffer.hpp | 60 - src/nuclear/src/dsl/word/Every.hpp | 119 -- src/nuclear/src/dsl/word/Group.hpp | 104 -- src/nuclear/src/dsl/word/IO.hpp | 172 --- src/nuclear/src/dsl/word/Idle.hpp | 91 -- src/nuclear/src/dsl/word/Inline.hpp | 72 -- src/nuclear/src/dsl/word/Last.hpp | 218 ---- src/nuclear/src/dsl/word/MainThread.hpp | 55 - src/nuclear/src/dsl/word/Network.hpp | 123 -- src/nuclear/src/dsl/word/Once.hpp | 54 - src/nuclear/src/dsl/word/Optional.hpp | 96 -- src/nuclear/src/dsl/word/Pool.hpp | 134 -- src/nuclear/src/dsl/word/Priority.hpp | 127 -- src/nuclear/src/dsl/word/Shutdown.hpp | 63 - src/nuclear/src/dsl/word/Single.hpp | 48 - src/nuclear/src/dsl/word/Startup.hpp | 48 - src/nuclear/src/dsl/word/Sync.hpp | 77 -- src/nuclear/src/dsl/word/TCP.hpp | 211 ---- src/nuclear/src/dsl/word/TaskScope.hpp | 108 -- src/nuclear/src/dsl/word/Trigger.hpp | 54 - src/nuclear/src/dsl/word/UDP.hpp | 554 -------- src/nuclear/src/dsl/word/Watchdog.hpp | 291 ----- src/nuclear/src/dsl/word/With.hpp | 65 - src/nuclear/src/dsl/word/emit/Delay.hpp | 95 -- src/nuclear/src/dsl/word/emit/Initialise.hpp | 82 -- src/nuclear/src/dsl/word/emit/Inline.hpp | 80 -- src/nuclear/src/dsl/word/emit/Local.hpp | 76 -- src/nuclear/src/dsl/word/emit/Network.hpp | 106 -- src/nuclear/src/dsl/word/emit/UDP.hpp | 179 --- src/nuclear/src/dsl/word/emit/Watchdog.hpp | 172 --- .../src/extension/ChronoController.cpp | 201 --- .../src/extension/ChronoController.hpp | 58 - src/nuclear/src/extension/IOController.cpp | 27 - src/nuclear/src/extension/IOController.hpp | 145 --- .../src/extension/IOController_Posix.ipp | 289 ----- .../src/extension/IOController_Windows.ipp | 263 ---- .../src/extension/NetworkController.cpp | 155 --- .../src/extension/NetworkController.hpp | 62 - src/nuclear/src/extension/TraceController.cpp | 306 ----- src/nuclear/src/extension/TraceController.hpp | 113 -- .../src/extension/network/NUClearNetwork.cpp | 1121 ----------------- .../src/extension/network/NUClearNetwork.hpp | 357 ------ .../src/extension/network/wire_protocol.hpp | 119 -- .../src/extension/trace/StringInterner.hpp | 111 -- src/nuclear/src/extension/trace/protobuf.cpp | 143 --- src/nuclear/src/extension/trace/protobuf.hpp | 133 -- src/nuclear/src/id.hpp | 41 - .../src/message/CommandLineArguments.hpp | 40 - src/nuclear/src/message/LogMessage.hpp | 72 -- .../src/message/NetworkConfiguration.hpp | 61 - src/nuclear/src/message/NetworkEvent.hpp | 44 - .../src/message/ReactionStatistics.cpp | 57 - .../src/message/ReactionStatistics.hpp | 122 -- src/nuclear/src/message/TimeTravel.hpp | 63 - src/nuclear/src/message/Trace.hpp | 49 - src/nuclear/src/nuclear.in | 45 - src/nuclear/src/threading/Reaction.cpp | 70 - src/nuclear/src/threading/Reaction.hpp | 139 -- src/nuclear/src/threading/ReactionHandle.cpp | 77 -- src/nuclear/src/threading/ReactionHandle.hpp | 103 -- .../src/threading/ReactionIdentifiers.hpp | 60 - src/nuclear/src/threading/ReactionTask.cpp | 100 -- src/nuclear/src/threading/ReactionTask.hpp | 187 --- .../src/threading/scheduler/CombinedLock.cpp | 52 - .../src/threading/scheduler/CombinedLock.hpp | 72 -- .../src/threading/scheduler/CountingLock.cpp | 45 - .../src/threading/scheduler/CountingLock.hpp | 81 -- src/nuclear/src/threading/scheduler/Group.cpp | 137 -- src/nuclear/src/threading/scheduler/Group.hpp | 178 --- src/nuclear/src/threading/scheduler/Lock.cpp | 34 - src/nuclear/src/threading/scheduler/Lock.hpp | 60 - src/nuclear/src/threading/scheduler/Pool.cpp | 281 ----- src/nuclear/src/threading/scheduler/Pool.hpp | 258 ---- .../src/threading/scheduler/Scheduler.cpp | 200 --- .../src/threading/scheduler/Scheduler.hpp | 167 --- src/nuclear/src/util/CallableInfo.hpp | 179 --- src/nuclear/src/util/CallbackGenerator.hpp | 166 --- src/nuclear/src/util/Dereferencer.hpp | 81 -- src/nuclear/src/util/FileDescriptor.cpp | 93 -- src/nuclear/src/util/FileDescriptor.hpp | 112 -- src/nuclear/src/util/FunctionFusion.hpp | 367 ------ src/nuclear/src/util/GroupDescriptor.hpp | 52 - src/nuclear/src/util/Inline.hpp | 49 - src/nuclear/src/util/MergeTransient.hpp | 40 - src/nuclear/src/util/MetaProgramming.hpp | 71 -- src/nuclear/src/util/RelevantArguments.hpp | 69 - src/nuclear/src/util/Sequence.hpp | 80 -- src/nuclear/src/util/ThreadPoolDescriptor.hpp | 62 - .../src/util/TransientDataElements.hpp | 59 - src/nuclear/src/util/TypeList.hpp | 66 - src/nuclear/src/util/TypeMap.hpp | 110 -- src/nuclear/src/util/apply.hpp | 66 - src/nuclear/src/util/demangle.cpp | 139 -- src/nuclear/src/util/demangle.hpp | 36 - src/nuclear/src/util/get_hostname.cpp | 48 - src/nuclear/src/util/get_hostname.hpp | 41 - src/nuclear/src/util/meta/Filter.hpp | 79 -- .../src/util/network/get_interfaces.cpp | 209 --- .../src/util/network/get_interfaces.hpp | 74 -- .../util/network/if_number_from_address.cpp | 70 - .../util/network/if_number_from_address.hpp | 45 - src/nuclear/src/util/network/resolve.cpp | 98 -- src/nuclear/src/util/network/resolve.hpp | 52 - src/nuclear/src/util/network/sock_t.hpp | 73 -- src/nuclear/src/util/platform.cpp | 97 -- src/nuclear/src/util/platform.hpp | 208 --- src/nuclear/src/util/precise_sleep.cpp | 82 -- src/nuclear/src/util/precise_sleep.hpp | 36 - src/nuclear/src/util/serialise/Serialise.hpp | 159 --- src/nuclear/src/util/serialise/xxhash.cpp | 225 ---- src/nuclear/src/util/serialise/xxhash.hpp | 63 - src/nuclear/src/util/tuplify.hpp | 56 - src/nuclear/src/util/unpack.hpp | 60 - .../util/update_current_thread_priority.hpp | 78 -- src/nuclear/src/util/usage_clock.cpp | 44 - src/nuclear/src/util/usage_clock.hpp | 30 - src/nuclear/tests/CMakeLists.txt | 77 -- src/nuclear/tests/networktest.cpp | 143 --- src/nuclear/tests/test_util/TestBase.hpp | 104 -- src/nuclear/tests/test_util/TimeUnit.hpp | 65 - src/nuclear/tests/test_util/common.hpp | 51 - src/nuclear/tests/test_util/diff_string.cpp | 88 -- src/nuclear/tests/test_util/diff_string.hpp | 44 - .../tests/test_util/executable_path.cpp | 78 -- .../tests/test_util/executable_path.hpp | 39 - src/nuclear/tests/test_util/has_ipv6.cpp | 37 - src/nuclear/tests/test_util/has_ipv6.hpp | 32 - src/nuclear/tests/test_util/lcs.hpp | 119 -- .../tests/tests/api/ReactionHandle.cpp | 89 -- .../tests/tests/api/ReactionStatistics.cpp | 125 -- .../tests/api/ReactionStatisticsTiming.cpp | 182 --- src/nuclear/tests/tests/api/ReactorArgs.cpp | 58 - src/nuclear/tests/tests/api/TimeTravel.cpp | 141 --- .../tests/tests/api/TimeTravelFrozen.cpp | 125 -- src/nuclear/tests/tests/dsl/Always.cpp | 87 -- .../tests/tests/dsl/ArgumentFission.cpp | 111 -- src/nuclear/tests/tests/dsl/BlockNoData.cpp | 87 -- src/nuclear/tests/tests/dsl/Buffer.cpp | 176 --- .../tests/tests/dsl/CommandLineArguments.cpp | 68 - src/nuclear/tests/tests/dsl/CustomGet.cpp | 78 -- src/nuclear/tests/tests/dsl/DSLOrdering.cpp | 96 -- src/nuclear/tests/tests/dsl/DSLProxy.cpp | 92 -- src/nuclear/tests/tests/dsl/Every.cpp | 101 -- src/nuclear/tests/tests/dsl/FlagMessage.cpp | 93 -- src/nuclear/tests/tests/dsl/FusionInOrder.cpp | 53 - src/nuclear/tests/tests/dsl/GroupPool.cpp | 117 -- src/nuclear/tests/tests/dsl/IO.cpp | 145 --- src/nuclear/tests/tests/dsl/Idle.cpp | 141 --- src/nuclear/tests/tests/dsl/IdleCrossPool.cpp | 90 -- src/nuclear/tests/tests/dsl/IdleGlobal.cpp | 126 -- src/nuclear/tests/tests/dsl/IdleSingle.cpp | 147 --- .../tests/tests/dsl/IdleSingleGlobal.cpp | 121 -- src/nuclear/tests/tests/dsl/IdleSync.cpp | 91 -- src/nuclear/tests/tests/dsl/Inline.cpp | 140 -- src/nuclear/tests/tests/dsl/Last.cpp | 88 -- src/nuclear/tests/tests/dsl/MainThread.cpp | 92 -- .../tests/tests/dsl/MissingArguments.cpp | 86 -- src/nuclear/tests/tests/dsl/Once.cpp | 95 -- src/nuclear/tests/tests/dsl/Optional.cpp | 93 -- src/nuclear/tests/tests/dsl/Priority.cpp | 126 -- src/nuclear/tests/tests/dsl/Raw.cpp | 82 -- src/nuclear/tests/tests/dsl/RawFunction.cpp | 135 -- src/nuclear/tests/tests/dsl/Shutdown.cpp | 73 -- src/nuclear/tests/tests/dsl/Startup.cpp | 73 -- src/nuclear/tests/tests/dsl/Sync.cpp | 130 -- src/nuclear/tests/tests/dsl/SyncMulti.cpp | 88 -- src/nuclear/tests/tests/dsl/SyncOrder.cpp | 81 -- src/nuclear/tests/tests/dsl/TCP.cpp | 258 ---- src/nuclear/tests/tests/dsl/TaskScope.cpp | 145 --- src/nuclear/tests/tests/dsl/Transient.cpp | 163 --- src/nuclear/tests/tests/dsl/Trigger.cpp | 82 -- src/nuclear/tests/tests/dsl/UDP.cpp | 473 ------- src/nuclear/tests/tests/dsl/Watchdog.cpp | 126 -- src/nuclear/tests/tests/dsl/With.cpp | 109 -- src/nuclear/tests/tests/dsl/emit/Delay.cpp | 126 -- .../tests/tests/dsl/emit/EmitFusion.cpp | 113 -- .../tests/tests/dsl/emit/Initialise.cpp | 84 -- src/nuclear/tests/tests/log/Log.cpp | 226 ---- .../tests/tests/threading/CountingLock.cpp | 76 -- src/nuclear/tests/tests/threading/Group.cpp | 406 ------ src/nuclear/tests/tests/util/demangle.cpp | 124 -- .../tests/tests/util/network/resolve.cpp | 148 --- .../tests/tests/util/serialise/serialise.cpp | 341 ----- .../tests/tests/util/serialise/xxhash.cpp | 185 --- 267 files changed, 32347 deletions(-) delete mode 100644 src/nuclear/.clang-format delete mode 100644 src/nuclear/.clang-tidy delete mode 100644 src/nuclear/.cmake-format.py delete mode 100644 src/nuclear/.github/dependabot.yaml delete mode 100644 src/nuclear/.github/workflows/gcc.yaml delete mode 100644 src/nuclear/.github/workflows/linting.yaml delete mode 100644 src/nuclear/.github/workflows/macos.yaml delete mode 100644 src/nuclear/.github/workflows/sonarcloud.yaml delete mode 100644 src/nuclear/.github/workflows/windows.yaml delete mode 100644 src/nuclear/.gitignore delete mode 100644 src/nuclear/.readthedocs.yaml delete mode 100644 src/nuclear/.vscode/settings.json delete mode 100644 src/nuclear/CMakeLists.txt delete mode 100644 src/nuclear/LICENSE delete mode 100644 src/nuclear/NUClear.sublime-project delete mode 100644 src/nuclear/README.md delete mode 100644 src/nuclear/cmake/ClangTidy.cmake delete mode 100644 src/nuclear/cmake/CompilerOptions.cmake delete mode 100644 src/nuclear/cmake/Modules/FindSphinx.cmake delete mode 100644 src/nuclear/cmake/Modules/ToolchainLibraryFinder.cmake delete mode 100644 src/nuclear/cmake/NUClearConfig.cmake.in delete mode 100644 src/nuclear/cmake/Sanitizers.cmake delete mode 100644 src/nuclear/docs/.special.rst delete mode 100644 src/nuclear/docs/CMakeLists.txt delete mode 100644 src/nuclear/docs/Doxyfile delete mode 100644 src/nuclear/docs/_static/colours.css delete mode 100644 src/nuclear/docs/components.rst delete mode 100644 src/nuclear/docs/conf.py delete mode 100644 src/nuclear/docs/definitions.rst delete mode 100644 src/nuclear/docs/dsl.rst delete mode 100644 src/nuclear/docs/extension.rst delete mode 100644 src/nuclear/docs/images/blackboard.svg delete mode 100644 src/nuclear/docs/images/blackboard_architecture.svg delete mode 100644 src/nuclear/docs/images/blackboard_architecture_coupled.svg delete mode 100644 src/nuclear/docs/images/co-message.svg delete mode 100644 src/nuclear/docs/images/message_passing_system.svg delete mode 100644 src/nuclear/docs/images/on_statement.svg delete mode 100644 src/nuclear/docs/images/power_plant.svg delete mode 100644 src/nuclear/docs/images/reactors.svg delete mode 100644 src/nuclear/docs/index.rst delete mode 100644 src/nuclear/docs/managing_reactions.rst delete mode 100644 src/nuclear/docs/networking.rst delete mode 100644 src/nuclear/docs/overview.rst delete mode 100644 src/nuclear/docs/quick_start.rst delete mode 100644 src/nuclear/docs/requirements.txt delete mode 100644 src/nuclear/docs/startup.rst delete mode 100644 src/nuclear/sonar-project.properties delete mode 100644 src/nuclear/src/CMakeLists.txt delete mode 100644 src/nuclear/src/Configuration.hpp delete mode 100644 src/nuclear/src/Environment.hpp delete mode 100644 src/nuclear/src/LogLevel.cpp delete mode 100644 src/nuclear/src/LogLevel.hpp delete mode 100644 src/nuclear/src/PowerPlant.cpp delete mode 100644 src/nuclear/src/PowerPlant.hpp delete mode 100644 src/nuclear/src/Reactor.hpp delete mode 100644 src/nuclear/src/clock.cpp delete mode 100644 src/nuclear/src/clock.hpp delete mode 100644 src/nuclear/src/dsl/Fusion.hpp delete mode 100644 src/nuclear/src/dsl/Parse.hpp delete mode 100644 src/nuclear/src/dsl/fusion/BindFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/FindWords.hpp delete mode 100644 src/nuclear/src/dsl/fusion/GetFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/GroupFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/InlineFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/NoOp.hpp delete mode 100644 src/nuclear/src/dsl/fusion/PoolFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/PostRunFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/PreRunFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/PreconditionFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/PriorityFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/ScopeFusion.hpp delete mode 100644 src/nuclear/src/dsl/fusion/has_nuclear_dsl_method.hpp delete mode 100644 src/nuclear/src/dsl/operation/CacheGet.hpp delete mode 100644 src/nuclear/src/dsl/operation/ChronoTask.hpp delete mode 100644 src/nuclear/src/dsl/operation/DSLProxy.hpp delete mode 100644 src/nuclear/src/dsl/operation/TypeBind.hpp delete mode 100644 src/nuclear/src/dsl/operation/Unbind.hpp delete mode 100644 src/nuclear/src/dsl/store/DataStore.hpp delete mode 100644 src/nuclear/src/dsl/store/ThreadStore.hpp delete mode 100644 src/nuclear/src/dsl/store/TypeCallbackStore.hpp delete mode 100644 src/nuclear/src/dsl/trait/is_transient.hpp delete mode 100644 src/nuclear/src/dsl/validation/Validation.hpp delete mode 100644 src/nuclear/src/dsl/word/Always.hpp delete mode 100644 src/nuclear/src/dsl/word/Buffer.hpp delete mode 100644 src/nuclear/src/dsl/word/Every.hpp delete mode 100644 src/nuclear/src/dsl/word/Group.hpp delete mode 100644 src/nuclear/src/dsl/word/IO.hpp delete mode 100644 src/nuclear/src/dsl/word/Idle.hpp delete mode 100644 src/nuclear/src/dsl/word/Inline.hpp delete mode 100644 src/nuclear/src/dsl/word/Last.hpp delete mode 100644 src/nuclear/src/dsl/word/MainThread.hpp delete mode 100644 src/nuclear/src/dsl/word/Network.hpp delete mode 100644 src/nuclear/src/dsl/word/Once.hpp delete mode 100644 src/nuclear/src/dsl/word/Optional.hpp delete mode 100644 src/nuclear/src/dsl/word/Pool.hpp delete mode 100644 src/nuclear/src/dsl/word/Priority.hpp delete mode 100644 src/nuclear/src/dsl/word/Shutdown.hpp delete mode 100644 src/nuclear/src/dsl/word/Single.hpp delete mode 100644 src/nuclear/src/dsl/word/Startup.hpp delete mode 100644 src/nuclear/src/dsl/word/Sync.hpp delete mode 100644 src/nuclear/src/dsl/word/TCP.hpp delete mode 100644 src/nuclear/src/dsl/word/TaskScope.hpp delete mode 100644 src/nuclear/src/dsl/word/Trigger.hpp delete mode 100644 src/nuclear/src/dsl/word/UDP.hpp delete mode 100644 src/nuclear/src/dsl/word/Watchdog.hpp delete mode 100644 src/nuclear/src/dsl/word/With.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/Delay.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/Initialise.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/Inline.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/Local.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/Network.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/UDP.hpp delete mode 100644 src/nuclear/src/dsl/word/emit/Watchdog.hpp delete mode 100644 src/nuclear/src/extension/ChronoController.cpp delete mode 100644 src/nuclear/src/extension/ChronoController.hpp delete mode 100644 src/nuclear/src/extension/IOController.cpp delete mode 100644 src/nuclear/src/extension/IOController.hpp delete mode 100644 src/nuclear/src/extension/IOController_Posix.ipp delete mode 100644 src/nuclear/src/extension/IOController_Windows.ipp delete mode 100644 src/nuclear/src/extension/NetworkController.cpp delete mode 100644 src/nuclear/src/extension/NetworkController.hpp delete mode 100644 src/nuclear/src/extension/TraceController.cpp delete mode 100644 src/nuclear/src/extension/TraceController.hpp delete mode 100644 src/nuclear/src/extension/network/NUClearNetwork.cpp delete mode 100644 src/nuclear/src/extension/network/NUClearNetwork.hpp delete mode 100644 src/nuclear/src/extension/network/wire_protocol.hpp delete mode 100644 src/nuclear/src/extension/trace/StringInterner.hpp delete mode 100644 src/nuclear/src/extension/trace/protobuf.cpp delete mode 100644 src/nuclear/src/extension/trace/protobuf.hpp delete mode 100644 src/nuclear/src/id.hpp delete mode 100644 src/nuclear/src/message/CommandLineArguments.hpp delete mode 100644 src/nuclear/src/message/LogMessage.hpp delete mode 100644 src/nuclear/src/message/NetworkConfiguration.hpp delete mode 100644 src/nuclear/src/message/NetworkEvent.hpp delete mode 100644 src/nuclear/src/message/ReactionStatistics.cpp delete mode 100644 src/nuclear/src/message/ReactionStatistics.hpp delete mode 100644 src/nuclear/src/message/TimeTravel.hpp delete mode 100644 src/nuclear/src/message/Trace.hpp delete mode 100644 src/nuclear/src/nuclear.in delete mode 100644 src/nuclear/src/threading/Reaction.cpp delete mode 100644 src/nuclear/src/threading/Reaction.hpp delete mode 100644 src/nuclear/src/threading/ReactionHandle.cpp delete mode 100644 src/nuclear/src/threading/ReactionHandle.hpp delete mode 100644 src/nuclear/src/threading/ReactionIdentifiers.hpp delete mode 100644 src/nuclear/src/threading/ReactionTask.cpp delete mode 100644 src/nuclear/src/threading/ReactionTask.hpp delete mode 100644 src/nuclear/src/threading/scheduler/CombinedLock.cpp delete mode 100644 src/nuclear/src/threading/scheduler/CombinedLock.hpp delete mode 100644 src/nuclear/src/threading/scheduler/CountingLock.cpp delete mode 100644 src/nuclear/src/threading/scheduler/CountingLock.hpp delete mode 100644 src/nuclear/src/threading/scheduler/Group.cpp delete mode 100644 src/nuclear/src/threading/scheduler/Group.hpp delete mode 100644 src/nuclear/src/threading/scheduler/Lock.cpp delete mode 100644 src/nuclear/src/threading/scheduler/Lock.hpp delete mode 100644 src/nuclear/src/threading/scheduler/Pool.cpp delete mode 100644 src/nuclear/src/threading/scheduler/Pool.hpp delete mode 100644 src/nuclear/src/threading/scheduler/Scheduler.cpp delete mode 100644 src/nuclear/src/threading/scheduler/Scheduler.hpp delete mode 100644 src/nuclear/src/util/CallableInfo.hpp delete mode 100644 src/nuclear/src/util/CallbackGenerator.hpp delete mode 100644 src/nuclear/src/util/Dereferencer.hpp delete mode 100644 src/nuclear/src/util/FileDescriptor.cpp delete mode 100644 src/nuclear/src/util/FileDescriptor.hpp delete mode 100644 src/nuclear/src/util/FunctionFusion.hpp delete mode 100644 src/nuclear/src/util/GroupDescriptor.hpp delete mode 100644 src/nuclear/src/util/Inline.hpp delete mode 100644 src/nuclear/src/util/MergeTransient.hpp delete mode 100644 src/nuclear/src/util/MetaProgramming.hpp delete mode 100644 src/nuclear/src/util/RelevantArguments.hpp delete mode 100644 src/nuclear/src/util/Sequence.hpp delete mode 100644 src/nuclear/src/util/ThreadPoolDescriptor.hpp delete mode 100644 src/nuclear/src/util/TransientDataElements.hpp delete mode 100644 src/nuclear/src/util/TypeList.hpp delete mode 100644 src/nuclear/src/util/TypeMap.hpp delete mode 100644 src/nuclear/src/util/apply.hpp delete mode 100644 src/nuclear/src/util/demangle.cpp delete mode 100644 src/nuclear/src/util/demangle.hpp delete mode 100644 src/nuclear/src/util/get_hostname.cpp delete mode 100644 src/nuclear/src/util/get_hostname.hpp delete mode 100644 src/nuclear/src/util/meta/Filter.hpp delete mode 100644 src/nuclear/src/util/network/get_interfaces.cpp delete mode 100644 src/nuclear/src/util/network/get_interfaces.hpp delete mode 100644 src/nuclear/src/util/network/if_number_from_address.cpp delete mode 100644 src/nuclear/src/util/network/if_number_from_address.hpp delete mode 100644 src/nuclear/src/util/network/resolve.cpp delete mode 100644 src/nuclear/src/util/network/resolve.hpp delete mode 100644 src/nuclear/src/util/network/sock_t.hpp delete mode 100644 src/nuclear/src/util/platform.cpp delete mode 100644 src/nuclear/src/util/platform.hpp delete mode 100644 src/nuclear/src/util/precise_sleep.cpp delete mode 100644 src/nuclear/src/util/precise_sleep.hpp delete mode 100644 src/nuclear/src/util/serialise/Serialise.hpp delete mode 100644 src/nuclear/src/util/serialise/xxhash.cpp delete mode 100644 src/nuclear/src/util/serialise/xxhash.hpp delete mode 100644 src/nuclear/src/util/tuplify.hpp delete mode 100644 src/nuclear/src/util/unpack.hpp delete mode 100644 src/nuclear/src/util/update_current_thread_priority.hpp delete mode 100644 src/nuclear/src/util/usage_clock.cpp delete mode 100644 src/nuclear/src/util/usage_clock.hpp delete mode 100644 src/nuclear/tests/CMakeLists.txt delete mode 100644 src/nuclear/tests/networktest.cpp delete mode 100644 src/nuclear/tests/test_util/TestBase.hpp delete mode 100644 src/nuclear/tests/test_util/TimeUnit.hpp delete mode 100644 src/nuclear/tests/test_util/common.hpp delete mode 100644 src/nuclear/tests/test_util/diff_string.cpp delete mode 100644 src/nuclear/tests/test_util/diff_string.hpp delete mode 100644 src/nuclear/tests/test_util/executable_path.cpp delete mode 100644 src/nuclear/tests/test_util/executable_path.hpp delete mode 100644 src/nuclear/tests/test_util/has_ipv6.cpp delete mode 100644 src/nuclear/tests/test_util/has_ipv6.hpp delete mode 100644 src/nuclear/tests/test_util/lcs.hpp delete mode 100644 src/nuclear/tests/tests/api/ReactionHandle.cpp delete mode 100644 src/nuclear/tests/tests/api/ReactionStatistics.cpp delete mode 100644 src/nuclear/tests/tests/api/ReactionStatisticsTiming.cpp delete mode 100644 src/nuclear/tests/tests/api/ReactorArgs.cpp delete mode 100644 src/nuclear/tests/tests/api/TimeTravel.cpp delete mode 100644 src/nuclear/tests/tests/api/TimeTravelFrozen.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Always.cpp delete mode 100644 src/nuclear/tests/tests/dsl/ArgumentFission.cpp delete mode 100644 src/nuclear/tests/tests/dsl/BlockNoData.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Buffer.cpp delete mode 100644 src/nuclear/tests/tests/dsl/CommandLineArguments.cpp delete mode 100644 src/nuclear/tests/tests/dsl/CustomGet.cpp delete mode 100644 src/nuclear/tests/tests/dsl/DSLOrdering.cpp delete mode 100644 src/nuclear/tests/tests/dsl/DSLProxy.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Every.cpp delete mode 100644 src/nuclear/tests/tests/dsl/FlagMessage.cpp delete mode 100644 src/nuclear/tests/tests/dsl/FusionInOrder.cpp delete mode 100644 src/nuclear/tests/tests/dsl/GroupPool.cpp delete mode 100644 src/nuclear/tests/tests/dsl/IO.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Idle.cpp delete mode 100644 src/nuclear/tests/tests/dsl/IdleCrossPool.cpp delete mode 100644 src/nuclear/tests/tests/dsl/IdleGlobal.cpp delete mode 100644 src/nuclear/tests/tests/dsl/IdleSingle.cpp delete mode 100644 src/nuclear/tests/tests/dsl/IdleSingleGlobal.cpp delete mode 100644 src/nuclear/tests/tests/dsl/IdleSync.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Inline.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Last.cpp delete mode 100644 src/nuclear/tests/tests/dsl/MainThread.cpp delete mode 100644 src/nuclear/tests/tests/dsl/MissingArguments.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Once.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Optional.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Priority.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Raw.cpp delete mode 100644 src/nuclear/tests/tests/dsl/RawFunction.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Shutdown.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Startup.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Sync.cpp delete mode 100644 src/nuclear/tests/tests/dsl/SyncMulti.cpp delete mode 100644 src/nuclear/tests/tests/dsl/SyncOrder.cpp delete mode 100644 src/nuclear/tests/tests/dsl/TCP.cpp delete mode 100644 src/nuclear/tests/tests/dsl/TaskScope.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Transient.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Trigger.cpp delete mode 100644 src/nuclear/tests/tests/dsl/UDP.cpp delete mode 100644 src/nuclear/tests/tests/dsl/Watchdog.cpp delete mode 100644 src/nuclear/tests/tests/dsl/With.cpp delete mode 100644 src/nuclear/tests/tests/dsl/emit/Delay.cpp delete mode 100644 src/nuclear/tests/tests/dsl/emit/EmitFusion.cpp delete mode 100644 src/nuclear/tests/tests/dsl/emit/Initialise.cpp delete mode 100644 src/nuclear/tests/tests/log/Log.cpp delete mode 100644 src/nuclear/tests/tests/threading/CountingLock.cpp delete mode 100644 src/nuclear/tests/tests/threading/Group.cpp delete mode 100644 src/nuclear/tests/tests/util/demangle.cpp delete mode 100644 src/nuclear/tests/tests/util/network/resolve.cpp delete mode 100644 src/nuclear/tests/tests/util/serialise/serialise.cpp delete mode 100644 src/nuclear/tests/tests/util/serialise/xxhash.cpp diff --git a/src/nuclear/.clang-format b/src/nuclear/.clang-format deleted file mode 100644 index 6c44c3a8..00000000 --- a/src/nuclear/.clang-format +++ /dev/null @@ -1,86 +0,0 @@ -# C++ files -Language: Cpp -BasedOnStyle: Google -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveMacros: true -AlignConsecutiveAssignments: true -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Left -AlignOperands: true -AlignTrailingComments: true -AllowAllArgumentsOnNextLine: false -AllowAllConstructorInitializersOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: Empty -AllowShortLambdasOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true -AlwaysBreakTemplateDeclarations: Yes -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: false - AfterEnum: false - AfterFunction: false - AfterNamespace: false - AfterStruct: false - AfterUnion: false - AfterExternBlock: false - BeforeCatch: true - BeforeElse: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeBinaryOperators: NonAssignment -BreakBeforeBraces: Custom -BreakInheritanceList: BeforeComma -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeComma -BreakStringLiterals: true -ColumnLimit: 120 -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -FixNamespaceComments: true -IncludeBlocks: Regroup -IndentCaseLabels: true -IndentPPDirectives: BeforeHash -IndentWrappedFunctionNames: true -IndentWidth: 4 -KeepEmptyLinesAtTheStartOfBlocks: true -MaxEmptyLinesToKeep: 2 -NamespaceIndentation: Inner -PointerAlignment: Left -ReflowComments: true -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: true -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never diff --git a/src/nuclear/.clang-tidy b/src/nuclear/.clang-tidy deleted file mode 100644 index 6b4c31f3..00000000 --- a/src/nuclear/.clang-tidy +++ /dev/null @@ -1,72 +0,0 @@ -Checks: > - -*, - bugprone-*, - -bugprone-easily-swappable-parameters, - -bugprone-implicit-widening-of-multiplication-result, - cert-*, - clang-diagnostic-*, - clang-analyzer-*, - cppcoreguidelines-*, - -cppcoreguidelines-avoid-const-or-ref-data-members, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-non-private-member-variables-in-classes, - -cppcoreguidelines-owning-memory, - -cppcoreguidelines-pro-bounds-array-to-pointer-decay, - -cppcoreguidelines-pro-bounds-constant-array-index, - -cppcoreguidelines-pro-bounds-pointer-arithmetic, - -cppcoreguidelines-pro-type-reinterpret-cast, - -cppcoreguidelines-pro-type-union-access, - -cppcoreguidelines-pro-type-vararg, - google-*, - -google-explicit-constructor, - -google-readability-casting, - -google-readability-function-size, - -google-runtime-references, - llvm-namespace-comment, - misc-*, - -misc-non-private-member-variables-in-classes, - -misc-no-recursion, - performance-*, - -performance-avoid-endl, - readability-*, - -readability-avoid-nested-conditional-operator, - -readability-function-cognitive-complexity, - -readability-function-size, - -readability-identifier-length, - -readability-magic-numbers, - -readability-uppercase-literal-suffix, - modernize-*, - -modernize-use-trailing-return-type, - -modernize-use-emplace -WarningsAsErrors: "" -HeaderFilterRegex: ".*" -FormatStyle: file -CheckOptions: - - key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues - value: "0.5;1.0;2.0;3.0;4.0;100.0;" - - key: readability-magic-numbers.IgnoredFloatingPointValues - value: "0.5;1.0;2.0;3.0;4.0;100.0;" - - key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues - value: "1;2;3;4;" - - key: readability-magic-numbers.IgnoredIntegerValues - value: "1;2;3;4;" - - key: llvm-namespace-comment.ShortNamespaceLines - value: "1" - - key: llvm-namespace-comment.SpacesBeforeComments - value: "2" - - key: misc-move-constructor-init.IncludeStyle - value: google - - key: modernize-loop-convert.NamingStyle - value: lower_case - - key: modernize-pass-by-value.IncludeStyle - value: google - - key: modernize-replace-auto-ptr.IncludeStyle - value: google - - key: performance-for-range-copy.WarnOnAllAutoCopies - value: "1" - - key: performance-type-promotion-in-math-fn.IncludeStyle - value: google - - key: performance-unnecessary-value-param.IncludeStyle - value: google - - key: readability-braces-around-statements.ShortStatementLines - value: "1" diff --git a/src/nuclear/.cmake-format.py b/src/nuclear/.cmake-format.py deleted file mode 100644 index 51321b88..00000000 --- a/src/nuclear/.cmake-format.py +++ /dev/null @@ -1,215 +0,0 @@ -# ---------------------------------- -# Options affecting listfile parsing -# ---------------------------------- -with section("parse"): - - # Specify structure for custom cmake functions - additional_commands = {} - - # Specify variable tags. - vartags = [] - - # Specify property tags. - proptags = [] - -# ----------------------------- -# Options affecting formatting. -# ----------------------------- -with section("format"): - - # How wide to allow formatted cmake files - line_width = 120 - - # How many spaces to tab for indent - tab_size = 2 - - # If an argument group contains more than this many sub-groups (parg or kwarg - # groups) then force it to a vertical layout. - max_subgroups_hwrap = 2 - - # If a positional argument group contains more than this many arguments, then - # force it to a vertical layout. - max_pargs_hwrap = 6 - - # If a cmdline positional group consumes more than this many lines without - # nesting, then invalidate the layout (and nest) - max_rows_cmdline = 2 - - # If true, separate flow control names from their parentheses with a space - separate_ctrl_name_with_space = False - - # If true, separate function names from parentheses with a space - separate_fn_name_with_space = False - - # If a statement is wrapped to more than one line, than dangle the closing - # parenthesis on its own line. - dangle_parens = True - - # If the trailing parenthesis must be 'dangled' on its on line, then align it - # to this reference: `prefix`: the start of the statement, `prefix-indent`: - # the start of the statement, plus one indentation level, `child`: align to - # the column of the arguments - dangle_align = "prefix" - - # If the statement spelling length (including space and parenthesis) is - # smaller than this amount, then force reject nested layouts. - min_prefix_chars = 4 - - # If the statement spelling length (including space and parenthesis) is larger - # than the tab width by more than this amount, then force reject un-nested - # layouts. - max_prefix_chars = 10 - - # If a candidate layout is wrapped horizontally but it exceeds this many - # lines, then reject the layout. - max_lines_hwrap = 2 - - # What style line endings to use in the output. - line_ending = "unix" - - # Format command names consistently as 'lower' or 'upper' case - command_case = "canonical" - - # Format keywords consistently as 'lower' or 'upper' case - keyword_case = "upper" - - # If true, the argument lists which are known to be sortable will be sorted - # lexicographicall - enable_sort = True - - # If true, the parsers may infer whether or not an argument list is sortable - # (without annotation). - autosort = True - - # By default, if cmake-format cannot successfully fit everything into the - # desired linewidth it will apply the last, most agressive attempt that it - # made. If this flag is True, however, cmake-format will print error, exit - # with non-zero status code, and write-out nothing - require_valid_layout = False - - # A dictionary mapping layout nodes to a list of wrap decisions. See the - # documentation for more information. - layout_passes = {} - -# ------------------------------------------------ -# Options affecting comment reflow and formatting. -# ------------------------------------------------ -with section("markup"): - - # What character to use for bulleted lists - bullet_char = "*" - - # What character to use as punctuation after numerals in an enumerated list - enum_char = "." - - # If comment markup is enabled, don't reflow the first comment block in each - # listfile. Use this to preserve formatting of your copyright/license - # statements. - first_comment_is_literal = False - - # If comment markup is enabled, don't reflow any comment block which matches - # this (regex) pattern. Default is `None` (disabled). - literal_comment_pattern = None - - # Regular expression to match preformat fences in comments default= - # ``r'^\s*([`~]{3}[`~]*)(.*)$'`` - fence_pattern = "^\\s*([`~]{3}[`~]*)(.*)$" - - # Regular expression to match rulers in comments default= - # ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'`` - ruler_pattern = "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$" - - # If a comment line matches starts with this pattern then it is explicitly a - # trailing comment for the preceeding argument. Default is '#<' - explicit_trailing_pattern = "#<" - - # If a comment line starts with at least this many consecutive hash - # characters, then don't lstrip() them off. This allows for lazy hash rulers - # where the first hash char is not separated by space - hashruler_min_length = 10 - - # If true, then insert a space between the first hash char and remaining hash - # chars in a hash ruler, and normalize its length to fill the column - canonicalize_hashrulers = True - - # enable comment markup parsing and reflow - enable_markup = False - -# ---------------------------- -# Options affecting the linter -# ---------------------------- -with section("lint"): - - # a list of lint codes to disable - disabled_codes = [] - - # regular expression pattern describing valid function names - function_pattern = "[0-9a-z_]+" - - # regular expression pattern describing valid macro names - macro_pattern = "[0-9A-Z_]+" - - # regular expression pattern describing valid names for variables with global - # scope - global_var_pattern = "[0-9A-Z][0-9A-Z_]+" - - # regular expression pattern describing valid names for variables with global - # scope (but internal semantic) - internal_var_pattern = "_[0-9A-Z][0-9A-Z_]+" - - # regular expression pattern describing valid names for variables with local - # scope - local_var_pattern = "[0-9a-z_]+" - - # regular expression pattern describing valid names for privatedirectory - # variables - private_var_pattern = "_[0-9a-z_]+" - - # regular expression pattern describing valid names for publicdirectory - # variables - public_var_pattern = "[0-9A-Z][0-9A-Z_]+" - - # regular expression pattern describing valid names for keywords used in - # functions or macros - keyword_pattern = "[0-9A-Z_]+" - - # In the heuristic for C0201, how many conditionals to match within a loop in - # before considering the loop a parser. - max_conditionals_custom_parser = 2 - - # Require at least this many newlines between statements - min_statement_spacing = 1 - - # Require no more than this many newlines between statements - max_statement_spacing = 1 - max_returns = 6 - max_branches = 12 - max_arguments = 5 - max_localvars = 15 - max_statements = 50 - -# ------------------------------- -# Options affecting file encoding -# ------------------------------- -with section("encode"): - - # If true, emit the unicode byte-order mark (BOM) at the start of the file - emit_byteorder_mark = False - - # Specify the encoding of the input file. Defaults to utf-8 - input_encoding = "utf-8" - - # Specify the encoding of the output file. Defaults to utf-8. Note that cmake - # only claims to support utf-8 so be careful when using anything else - output_encoding = "utf-8" - -# ------------------------------------- -# Miscellaneous configurations options. -# ------------------------------------- -with section("misc"): - - # A dictionary containing any per-command configuration overrides. Currently - # only `command_case` is supported. - per_command = { - "ToolchainLibraryFinder": {"command_case": "unchanged"}, - } diff --git a/src/nuclear/.github/dependabot.yaml b/src/nuclear/.github/dependabot.yaml deleted file mode 100644 index 54779793..00000000 --- a/src/nuclear/.github/dependabot.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# Required fields are `version` and `updates` -version: 2 -updates: - # Required fields are `package-ecosystem`, `directory`, and `schedule.interval` - # Maintain dependencies for GitHub Actions - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "daily" diff --git a/src/nuclear/.github/workflows/gcc.yaml b/src/nuclear/.github/workflows/gcc.yaml deleted file mode 100644 index d1200508..00000000 --- a/src/nuclear/.github/workflows/gcc.yaml +++ /dev/null @@ -1,105 +0,0 @@ -# Continuous Integration tests -name: GCC - -on: - push: - branches: [main] - pull_request: - branches: [main] - -# Ensure that only one instance of the workflow is run at a time for each branch/tag. -# Jobs currently running on the branch/tag will be cancelled when new commits are pushed. -# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency. -concurrency: - # `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier - group: ${{ format('{0}:{1}', github.workflow, github.ref) }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - linux-gcc: - strategy: - matrix: - toolchain: - - container: ubuntu:22.04 - version: "13" - - container: ubuntu:22.04 - version: "12" - - container: ubuntu:22.04 - version: "11" - - container: ubuntu:22.04 - version: "10" - - container: ubuntu:22.04 - version: "9" - - container: ubuntu:20.04 - version: "8" - - container: ubuntu:20.04 - version: "7" - - name: Linux GCC-${{ matrix.toolchain.version }} - runs-on: ubuntu-latest - continue-on-error: true - - # Use the container for this specific version of gcc - container: ${{ matrix.toolchain.container }} - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - # Update for all the actions that need to install stuff - - run: | - apt-get update - apt-get install -y software-properties-common unzip - - - name: Install GCC - run: | - add-apt-repository ppa:ubuntu-toolchain-r/test - apt-get update - apt-get install -y gcc-${{ matrix.toolchain.version }} g++-${{ matrix.toolchain.version }} - - - name: Install CMake - uses: lukka/get-cmake@latest - with: - cmakeVersion: 3.27.1 - ninjaVersion: 1.11.1 - - - name: Setup CCache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }}-gcc-${{ matrix.toolchain.version }} - max-size: 100M - - - name: Configure CMake - run: | - cmake -E make_directory build - cmake -S . -B build \ - -GNinja \ - -DCMAKE_C_COMPILER=/usr/bin/gcc-${{ matrix.toolchain.version }} \ - -DCMAKE_CXX_COMPILER=/usr/bin/g++-${{ matrix.toolchain.version }} \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DBUILD_TESTS=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DCI_BUILD=ON \ - -DENABLE_CLANG_TIDY=OFF - - - name: Build - timeout-minutes: 30 - run: cmake --build build --config Release - - - name: CCache Stats - run: ccache --show-stats - - - name: Test - timeout-minutes: 2 - working-directory: build/tests - run: ctest --output-on-failure -E "dsl/UDP" - - - name: Upload Traces - if: always() - uses: actions/upload-artifact@v4 - with: - name: traces-gcc-${{ matrix.toolchain.version }} - path: build/tests/**/*.trace - retention-days: 1 # This sets the artifact TTL to 1 day (minimum is 1 day) - overwrite: true diff --git a/src/nuclear/.github/workflows/linting.yaml b/src/nuclear/.github/workflows/linting.yaml deleted file mode 100644 index bacca550..00000000 --- a/src/nuclear/.github/workflows/linting.yaml +++ /dev/null @@ -1,99 +0,0 @@ -name: Linting - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [main] - pull_request: - branches: [main] - -# Ensure that only one instance of the workflow is run at a time for each branch/tag. -# Jobs currently running on the branch/tag will be cancelled when new commits are pushed. -# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency. -concurrency: - # `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier - group: ${{ format('{0}:{1}', github.workflow, github.ref) }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - linux-clang-tidy: - name: Linux Clang-Tidy - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Install clang-tidy-15 - run: | - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee /etc/apt/sources.list.d/llvm-15 - echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" | sudo tee -a /etc/apt/sources.list.d/llvm-15 - sudo apt-get update - sudo apt-get install -y clang-tidy-15 - - # Download and install cmake - - name: Install CMake - uses: lukka/get-cmake@latest - with: - cmakeVersion: 3.27.1 - ninjaVersion: 1.11.1 - - # Download and setup ccache - - name: Setup CCache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }} - max-size: 100M - - # Install ctcache - - name: Install ctcache - shell: bash - run: | - CTCACHE_REF=debfea68152c5221d8f409cbef85dc5d0f98071d - curl --location https://raw.githubusercontent.com/matus-chochlik/ctcache/${CTCACHE_REF}/clang-tidy-cache | sudo tee /usr/local/bin/clang-tidy-cache > /dev/null - - echo #!/bin/bash | sudo tee /usr/local/bin/clang-tidy > /dev/null - echo /usr/local/bin/clang-tidy-cache '"${CTCACHE_CLANG_TIDY}"' '"$@"' | sudo tee -a /usr/local/bin/clang-tidy > /dev/null - - sudo chmod +x /usr/local/bin/clang-tidy-cache /usr/local/bin/clang-tidy - - mkdir -p ${{ github.workspace }}/.ctcache - - echo CTCACHE_CLANG_TIDY='/usr/bin/clang-tidy-15' >> "$GITHUB_ENV" - echo CTCACHE_LOCAL=1 >> "$GITHUB_ENV" - echo CTCACHE_SAVE_OUTPUT=1 >> "$GITHUB_ENV" - echo CTCACHE_DIR='${{github.workspace}}/.ctcache' >> "$GITHUB_ENV" - echo "CTCACHE_NOW=$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")" >> $GITHUB_ENV - - - name: Setup caching for ctcache - uses: actions/cache@v4 - with: - key: ctcache-${{ github.workflow }}-${{ github.job }}-${{ env.CTCACHE_NOW }} - path: ${{ env.CTCACHE_DIR }} - restore-keys: ctcache-${{ github.workflow }}-${{ github.job }}- - save-always: true - - - name: Configure CMake - run: | - cmake -E make_directory build - cmake -S . -B build \ - -GNinja \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DBUILD_TESTS=ON \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCI_BUILD=ON \ - -DENABLE_CLANG_TIDY=ON - - - name: Build - timeout-minutes: 30 - run: cmake --build build --config Debug --parallel 2 - - - name: CCache Stats - run: ccache --show-stats - - - name: CTCache Stats - run: clang-tidy-cache --show-stats diff --git a/src/nuclear/.github/workflows/macos.yaml b/src/nuclear/.github/workflows/macos.yaml deleted file mode 100644 index cc949da1..00000000 --- a/src/nuclear/.github/workflows/macos.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# Continuous Integration tests -name: MacOS - -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - branches: [main] - pull_request: - branches: [main] - -# Ensure that only one instance of the workflow is run at a time for each branch/tag. -# Jobs currently running on the branch/tag will be cancelled when new commits are pushed. -# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency. -concurrency: - # `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier - group: ${{ format('{0}:{1}', github.workflow, github.ref) }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - macos-latest: - name: MacOS Latest - runs-on: macos-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup CCache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }} - max-size: 100M - - - name: Install CMake - uses: lukka/get-cmake@latest - with: - cmakeVersion: 3.27.1 - ninjaVersion: 1.11.1 - - - name: Configure CMake - env: - CXXFLAGS: -DNUCLEAR_TEST_TIME_UNIT_DEN=10 - run: | - cmake -E make_directory build - cmake -S . -B build \ - -GNinja \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DBUILD_TESTS=ON \ - -DCMAKE_BUILD_TYPE=Release \ - -DCI_BUILD=ON \ - -DENABLE_CLANG_TIDY=OFF - - - name: Build - timeout-minutes: 30 - run: cmake --build build --config Release - - - name: CCache Stats - run: ccache --show-stats - - - name: Test - timeout-minutes: 5 - working-directory: build/tests - run: ctest --output-on-failure - - - name: Upload Traces - if: always() - uses: actions/upload-artifact@v4 - with: - name: traces-macos - path: build/tests/**/*.trace - retention-days: 1 # This sets the artifact TTL to 1 day (minimum is 1 day) - overwrite: true diff --git a/src/nuclear/.github/workflows/sonarcloud.yaml b/src/nuclear/.github/workflows/sonarcloud.yaml deleted file mode 100644 index 3a02f51e..00000000 --- a/src/nuclear/.github/workflows/sonarcloud.yaml +++ /dev/null @@ -1,90 +0,0 @@ -name: Sonar -on: - push: - branches: - - main - - sonar - pull_request: - types: [opened, synchronize, reopened] - -# Ensure that only one instance of the workflow is run at a time for each branch/tag. -# Jobs currently running on the branch/tag will be cancelled when new commits are pushed. -# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency. -concurrency: - # `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier - group: ${{ format('{0}:{1}', github.workflow, github.ref) }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -jobs: - sonarcloud: - name: SonarCloud - runs-on: ubuntu-latest - env: - BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - - name: Install gcovr - run: pip install gcovr==7.2 - - - name: Install sonar-scanner and build-wrapper - uses: SonarSource/sonarcloud-github-c-cpp@v3 - - - name: Install CMake - uses: lukka/get-cmake@latest - with: - cmakeVersion: 3.27.1 - ninjaVersion: 1.11.1 - - - name: Setup CCache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }} - max-size: 100M - - - name: Configure CMake - run: | - cmake -E make_directory build - cmake -S . -B build \ - -GNinja \ - -DCMAKE_CXX_FLAGS="--coverage" \ - -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ - -DBUILD_TESTS=ON \ - -DCMAKE_BUILD_TYPE=Debug \ - -DCI_BUILD=ON \ - -DENABLE_CLANG_TIDY=OFF - - - name: Build the code in debug mode - timeout-minutes: 30 - run: cmake --build build/ --config Debug - - - name: Run tests to generate coverage statistics - timeout-minutes: 10 - working-directory: build/tests - run: ctest --output-on-failure - - - name: Collect coverage into one XML report - if: always() - run: gcovr --gcov-ignore-parse-errors=negative_hits.warn_once_per_file --exclude-unreachable-branches --exclude-noncode-lines --sonarqube > coverage.xml - - - name: Run sonar-scanner - if: always() - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: | - sonar-scanner \ - --define sonar.cfamily.compile-commands=build/compile_commands.json \ - --define sonar.coverageReportPaths=coverage.xml - - - name: Upload Traces - if: always() - uses: actions/upload-artifact@v4 - with: - name: traces-sonar - path: build/tests/**/*.trace - retention-days: 1 # This sets the artifact TTL to 1 day (minimum is 1 day) - overwrite: true diff --git a/src/nuclear/.github/workflows/windows.yaml b/src/nuclear/.github/workflows/windows.yaml deleted file mode 100644 index 2163cc35..00000000 --- a/src/nuclear/.github/workflows/windows.yaml +++ /dev/null @@ -1,94 +0,0 @@ -# Continuous Integration tests -name: Windows - -on: - push: - branches: [main] - pull_request: - branches: [main] - -# Ensure that only one instance of the workflow is run at a time for each branch/tag. -# Jobs currently running on the branch/tag will be cancelled when new commits are pushed. -# See https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency. -concurrency: - # `github.workflow` is the workflow name, `github.ref` is the current branch/tag identifier - group: ${{ format('{0}:{1}', github.workflow, github.ref) }} - cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - windows-latest: - name: Windows Latest ${{ matrix.toolchain.name }} - - strategy: - matrix: - toolchain: - - name: MSVC - c: cl - cxx: cl - # Code does not compile on GCC on windows - # - name: GCC - # c: gcc - # cxx: g++ - - runs-on: windows-latest - continue-on-error: true - - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - - name: Setup CCache - uses: hendrikmuhs/ccache-action@v1.2 - with: - key: ${{ github.job }}-${{ matrix.toolchain.name }} - max-size: 100M - variant: sccache - - - name: Install CMake - uses: lukka/get-cmake@latest - with: - cmakeVersion: 3.27.1 - ninjaVersion: 1.11.1 - - # This lets ninja find MSVC - - name: Add MSVC to path - uses: ilammy/msvc-dev-cmd@v1 - - - name: Configure CMake - env: - CXXFLAGS: -DNUCLEAR_TEST_TIME_UNIT_DEN=10 - shell: cmd - run: | - cmake -E make_directory build - cmake -S . -B build ^ - -GNinja ^ - -DCMAKE_C_COMPILER=${{ matrix.toolchain.c }} ^ - -DCMAKE_CXX_COMPILER=${{ matrix.toolchain.cxx }} ^ - -DCMAKE_C_COMPILER_LAUNCHER=sccache ^ - -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^ - -DBUILD_TESTS=ON ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DCI_BUILD=ON ^ - -DENABLE_CLANG_TIDY=OFF - - - name: Build - timeout-minutes: 30 - run: cmake --build build --config Release - - - name: SCCache Stats - run: sccache --show-stats - - - name: Test - timeout-minutes: 5 - working-directory: build/tests - run: ctest --output-on-failure - - - name: Upload Traces - if: always() - uses: actions/upload-artifact@v4 - with: - name: traces-windows-${{ matrix.toolchain.name }} - path: build/tests/**/*.trace - retention-days: 1 # This sets the artifact TTL to 1 day (minimum is 1 day) - overwrite: true diff --git a/src/nuclear/.gitignore b/src/nuclear/.gitignore deleted file mode 100644 index 8ae53a55..00000000 --- a/src/nuclear/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -# Compiled Object files -*.slo -*.lo -*.o - -# Compiled Dynamic libraries -*.so -*.dylib - -# Compiled Static libraries -*.lai -*.la -*.a - -# Build & CMake files -build/ -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -install_manifest.txt - -.exe -tags -*.swp -.idea -docs/doxygen -docs/doxygen_sqlite3.db -*.sublime-workspace diff --git a/src/nuclear/.readthedocs.yaml b/src/nuclear/.readthedocs.yaml deleted file mode 100644 index 9712e405..00000000 --- a/src/nuclear/.readthedocs.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# .readthedocs.yaml -# Read the Docs configuration file -# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details - -# Required -version: 2 - -# Set the version of Python and other tools you might need -build: - os: ubuntu-22.04 - tools: - python: "3.11" - -# Build documentation in the docs/ directory with Sphinx -sphinx: - configuration: docs/conf.py - -# We recommend specifying your dependencies to enable reproducible builds: -# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html -python: - install: - - requirements: docs/requirements.txt diff --git a/src/nuclear/.vscode/settings.json b/src/nuclear/.vscode/settings.json deleted file mode 100644 index 42535815..00000000 --- a/src/nuclear/.vscode/settings.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "cmake.generator": "Ninja", - "editor.formatOnSave": true, - "editor.tabSize": 4, - "editor.insertSpaces": true, - "files.insertFinalNewline": true, - "files.trimFinalNewlines": true, - "files.eol": "\n", - "C_Cpp.clang_format_style": "file", - "C_Cpp.default.cppStandard": "c++14", - "C_Cpp.preferredPathSeparator": "Forward Slash", - "editor.rulers": [120], - "cmake.configureOnOpen": true, - "C_Cpp.default.configurationProvider": "vector-of-bool.cmake-tools", - "sonarlint.connectedMode.project": { - "connectionId": "fastcode", - "projectKey": "Fastcode_NUClear" - } -} diff --git a/src/nuclear/CMakeLists.txt b/src/nuclear/CMakeLists.txt deleted file mode 100644 index b5064757..00000000 --- a/src/nuclear/CMakeLists.txt +++ /dev/null @@ -1,98 +0,0 @@ -#[[ -MIT License - -Copyright (c) 2013 NUClear Contributors - -This file is part of the NUClear codebase. -See https://github.com/Fastcode/NUClear for further info. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -cmake_minimum_required(VERSION 3.15.0) - -# Set the project after the build type as the Project command can change the build type -project( - NUClear - VERSION 1.0.0 - LANGUAGES C CXX -) - -# We use additional modules that cmake needs to know about -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" "${CMAKE_SOURCE_DIR}/cmake/Modules/") - -# Output the compilation database -set(CMAKE_EXPORT_COMPILE_COMMANDS - ON - CACHE STRING "Enable/Disable output of compile commands during generation." FORCE -) - -# Set a default build type if none was specified -set(default_build_type "Release") -if(EXISTS "${CMAKE_SOURCE_DIR}/.git") - set(default_build_type "Debug") -endif() - -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to '${default_build_type}' as none was specified.") - set(CMAKE_BUILD_TYPE - ${default_build_type} - CACHE STRING "Choose the type of build." FORCE - ) - # Set the possible values of build type for cmake-gui - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") -endif() - -# NUClear targets c++14 -set(CMAKE_CXX_STANDARD 14) - -# Determine if NUClear is built as a subproject (using add_subdirectory) or if it is the master project. -set(MASTER_PROJECT OFF) -if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(MASTER_PROJECT ON) -endif() - -# If this option is set we are building using continous integration -option(CI_BUILD "Enable build options for building in the CI server" OFF) - -# Include files to set up the compiler options -include(ClangTidy) -include(CompilerOptions) -include(Sanitizers) - -# If we are doing a CI build then we want to enable -Werror when compiling warnings are bad. We will also make it fail -# if clang-tidy has an error -if(CI_BUILD) - if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) - add_compile_options(/WX) - else() - add_compile_options(-Werror) - endif() -endif(CI_BUILD) - -# Add the src directory -add_subdirectory(src) - -# Add the tests directory -option(BUILD_TESTS "Builds all of the NUClear unit tests." ON) -if(BUILD_TESTS) - enable_testing() - add_subdirectory(tests) -endif() - -# Add the documentation subdirectory -option(BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen and Sphinx)" OFF) -if(BUILD_DOCUMENTATION) - add_subdirectory(docs) -endif() diff --git a/src/nuclear/LICENSE b/src/nuclear/LICENSE deleted file mode 100644 index 02cd0a76..00000000 --- a/src/nuclear/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (C) 2013-2023 NUClear Contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/nuclear/NUClear.sublime-project b/src/nuclear/NUClear.sublime-project deleted file mode 100644 index b93aa818..00000000 --- a/src/nuclear/NUClear.sublime-project +++ /dev/null @@ -1,15 +0,0 @@ -{ - "folders": - [ - { - "path": "." - } - ], - "settings": { - "ClangFormat": { - "style": "file", - "format_on_save": true, - "languages": [ "C", "C++", "C++11", "Protobuf" ], - } - } -} diff --git a/src/nuclear/README.md b/src/nuclear/README.md deleted file mode 100644 index 8978133a..00000000 --- a/src/nuclear/README.md +++ /dev/null @@ -1,31 +0,0 @@ -NUClear [![CI](https://github.com/Fastcode/NUClear/actions/workflows/main.yaml/badge.svg)](https://github.com/Fastcode/NUClear/actions/workflows/main.yaml) -======= - -NUClear is a C++ software framework designed to aid in the development of real time modular systems. -It is built from a set of template metapgrograms that control the flow of information through the system. - -It is highly extensible and provides several attachment points to develop new DSL keywords if needed. - -These metaprograms reduce the cost of routing messages between modules resulting in a much faster system. - -For help getting started check the [docs](https://nuclear.readthedocs.io/en/latest/quick_start.html) - -If you're starting a new project using NUClear the [NUClear Roles system](https://github.com/Fastcode/NUClearRoles) is highly recommended - -## Installing -NUClear uses CMake as its build tool. - -For the lazy -```bash -git clone https://github.com/Fastcode/NUClear.git -cd NUClear -mkdir build -cd build -cmake .. -DBUILD_TESTS=OFF -make install -``` - -### Dependencies -* g++ 5.0+, clang (with c++14 support) or Visual Studio 2015 -* cmake 3.1.0 -* [Catch Unit Testing Framework](https://github.com/philsquared/Catch) for building tests diff --git a/src/nuclear/cmake/ClangTidy.cmake b/src/nuclear/cmake/ClangTidy.cmake deleted file mode 100644 index e1d6f051..00000000 --- a/src/nuclear/cmake/ClangTidy.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# Default not to run the clang-tidy checks, default to whatever our CI_BUILD is -option(ENABLE_CLANG_TIDY "Enable building with clang-tidy checks.") -if(ENABLE_CLANG_TIDY) - # Search for clang-tidy-15 first as this is the version installed in CI - find_program(CLANG_TIDY_EXECUTABLE NAMES clang-tidy-15 clang-tidy) - if(NOT CLANG_TIDY_EXECUTABLE) - message(FATAL_ERROR "clang-tidy-15 not found.") - endif() - - # Report clang-tidy executable details - execute_process(COMMAND "${CLANG_TIDY_EXECUTABLE}" "--version" OUTPUT_VARIABLE CLANG_TIDY_VERSION) - string(REGEX REPLACE ".*LLVM version ([0-9.]*).*" "\\1" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}") - message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXECUTABLE} ${CLANG_TIDY_VERSION}") - - # Build clang-tidy command line - set(CLANG_TIDY_ARGS "${CLANG_TIDY_EXECUTABLE}" "--use-color" "--config-file=${PROJECT_SOURCE_DIR}/.clang-tidy") - if(CI_BUILD) - set(CLANG_TIDY_ARGS "${CLANG_TIDY_EXECUTABLE}" "-warnings-as-errors=*") - endif(CI_BUILD) - set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_ARGS}" "--extra-arg=-std=c++14") - set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_ARGS}" "--extra-arg=-std=c99") -endif(ENABLE_CLANG_TIDY) diff --git a/src/nuclear/cmake/CompilerOptions.cmake b/src/nuclear/cmake/CompilerOptions.cmake deleted file mode 100644 index 4f8bcde7..00000000 --- a/src/nuclear/cmake/CompilerOptions.cmake +++ /dev/null @@ -1,7 +0,0 @@ -# Make the compiler display colours always (even when we build with ninja) -if(CMAKE_CXX_COMPILER_ID MATCHES GNU) - add_compile_options(-fdiagnostics-color=always) -endif() -if(CMAKE_CXX_COMPILER_ID MATCHES Clang) - add_compile_options(-fcolor-diagnostics) -endif() diff --git a/src/nuclear/cmake/Modules/FindSphinx.cmake b/src/nuclear/cmake/Modules/FindSphinx.cmake deleted file mode 100644 index e7f3584d..00000000 --- a/src/nuclear/cmake/Modules/FindSphinx.cmake +++ /dev/null @@ -1,24 +0,0 @@ -#[[ -MIT License - -Copyright (c) 2013 NUClear Contributors - -This file is part of the NUClear codebase. -See https://github.com/Fastcode/NUClear for further info. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -include(ToolchainLibraryFinder) -ToolchainLibraryFinder(NAME Sphinx BINARY sphinx-build) diff --git a/src/nuclear/cmake/Modules/ToolchainLibraryFinder.cmake b/src/nuclear/cmake/Modules/ToolchainLibraryFinder.cmake deleted file mode 100644 index 17e7314d..00000000 --- a/src/nuclear/cmake/Modules/ToolchainLibraryFinder.cmake +++ /dev/null @@ -1,144 +0,0 @@ -#[[ -MIT License - -Copyright (c) 2013 NUClear Contributors - -This file is part of the NUClear codebase. -See https://github.com/Fastcode/NUClear for further info. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -include(CMakeParseArguments) -function(ToolchainLibraryFinder) - - # Extract the arguments from our function call - set(options, "") - set(oneValueArgs "NAME") - set(multiValueArgs - "HEADER" - "LIBRARY" - "PATH_SUFFIX" - "BINARY" - "VERSION_FILE" - "VERSION_BINARY_ARGUMENTS" - "VERSION_REGEX" - ) - cmake_parse_arguments(PACKAGE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # Clear our required_vars variable - unset(required_vars) - - # Find our include path from our named headers - if(PACKAGE_HEADER) - - # Find our include path - find_path( - "${PACKAGE_NAME}_INCLUDE_DIR" - NAMES ${PACKAGE_HEADER} - DOC "The ${PACKAGE_NAME} (${PACKAGE_LIBRARY}) include directory" - PATH_SUFFIXES ${PACKAGE_PATH_SUFFIX} - ) - - # Setup and export our variables - set(required_vars ${required_vars} "${PACKAGE_NAME}_INCLUDE_DIR") - set(${PACKAGE_NAME}_INCLUDE_DIRS - ${${PACKAGE_NAME}_INCLUDE_DIR} - PARENT_SCOPE - ) - mark_as_advanced(${PACKAGE_NAME}_INCLUDE_DIR ${PACKAGE_NAME}_INCLUDE_DIRS) - - endif(PACKAGE_HEADER) - - # Find our library from the named library files - if(PACKAGE_LIBRARY) - find_library( - "${PACKAGE_NAME}_LIBRARY" - NAMES ${PACKAGE_LIBRARY} - PATH_SUFFIXES ${PACKAGE_PATH_SUFFIX} - DOC "The ${PACKAGE_NAME} (${PACKAGE_LIBRARY}) library" - ) - - # Setup and export our variables - set(required_vars ${required_vars} "${PACKAGE_NAME}_LIBRARY") - set(${PACKAGE_NAME}_LIBRARIES - ${${PACKAGE_NAME}_LIBRARY} - PARENT_SCOPE - ) - mark_as_advanced(${PACKAGE_NAME}_LIBRARY ${PACKAGE_NAME}_LIBRARIES) - - endif(PACKAGE_LIBRARY) - - # Find our binary from the named binary files - if(PACKAGE_BINARY) - find_program( - "${PACKAGE_NAME}_BINARY" - NAMES ${PACKAGE_BINARY} - PATH_SUFFIXES ${PACKAGE_PATH_SUFFIX} - DOC "The ${PACKAGE_NAME} (${PACKAGE_BINARY}) executable prgram" - ) - - # Setup and export our variables - set(required_vars ${required_vars} "${PACKAGE_NAME}_BINARY") - set(${PACKAGE_NAME}_BINARY - ${${PACKAGE_NAME}_BINARY} - PARENT_SCOPE - ) - mark_as_advanced(${PACKAGE_NAME}_BINARY) - - endif(PACKAGE_BINARY) - - # Find our version if we can - if((PACKAGE_VERSION_FILE AND PACKAGE_HEADER) OR (PACKAGE_VERSION_BINARY_ARGUMENTS AND PACKAGE_BINARY)) - unset(full_version_string) - - # Read our package version file into a variable - if(PACKAGE_VERSION_FILE AND PACKAGE_HEADER) - file(READ "${${PACKAGE_NAME}_INCLUDE_DIR}/${PACKAGE_VERSION_FILE}" full_version_string) - endif(PACKAGE_VERSION_FILE AND PACKAGE_HEADER) - - # Execute our binary to get a version string - if(PACKAGE_VERSION_BINARY_ARGUMENTS AND PACKAGE_BINARY) - exec_program( - ${${PACKAGE_NAME}_BINARY} ARGS - ${PACKAGE_VERSION_BINARY_ARGUMENTS} - OUTPUT_VARIABLE full_version_string - ) - endif(PACKAGE_VERSION_BINARY_ARGUMENTS AND PACKAGE_BINARY) - - # Build up our version string - set(${PACKAGE_NAME}_VERSION "") - foreach(regex ${PACKAGE_VERSION_REGEX}) - string(REGEX REPLACE ".*${regex}.*" "\\1" regex_output ${full_version_string}) - set(${PACKAGE_NAME}_VERSION ${${PACKAGE_NAME}_VERSION} ${regex_output}) - endforeach(regex) - string(REPLACE ";" "." ${PACKAGE_NAME}_VERSION "${${PACKAGE_NAME}_VERSION}") - - endif((PACKAGE_VERSION_FILE AND PACKAGE_HEADER) OR (PACKAGE_VERSION_BINARY_ARGUMENTS AND PACKAGE_BINARY)) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args( - ${PACKAGE_NAME} - FOUND_VAR ${PACKAGE_NAME}_FOUND - REQUIRED_VARS ${required_vars} - VERSION_VAR ${PACKAGE_NAME}_VERSION # VERSION_VAR "${MAJOR}.${MINOR}.${PATCH}") - ) - - # Export our found variable to parent scope - set(${PACKAGE_NAME}_FOUND - ${PACKAGE_NAME}_FOUND - PARENT_SCOPE - ) - -endfunction(ToolchainLibraryFinder) diff --git a/src/nuclear/cmake/NUClearConfig.cmake.in b/src/nuclear/cmake/NUClearConfig.cmake.in deleted file mode 100644 index 0c532c8f..00000000 --- a/src/nuclear/cmake/NUClearConfig.cmake.in +++ /dev/null @@ -1,9 +0,0 @@ -@PACKAGE_INIT@ - -INCLUDE(${CMAKE_CURRENT_LIST_DIR}/nuclear-targets.cmake) - -set_and_check(NUClear_INCLUDE_DIR "@PACKAGE_INSTALL_INCLUDE_DIR@") -set_and_check(NUClear_INCLUDE_DIRS "@PACKAGE_INSTALL_INCLUDE_DIR@") -set(NUClear_LIBRARIES NUClear::nuclear) - -CHECK_REQUIRED_COMPONENTS(NUClear) diff --git a/src/nuclear/cmake/Sanitizers.cmake b/src/nuclear/cmake/Sanitizers.cmake deleted file mode 100644 index 91877a30..00000000 --- a/src/nuclear/cmake/Sanitizers.cmake +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -### Options for enabling different sanitisers. ### -### ### -### User beware: ### -### Not all sanitisers can be enabled at the same time. ### -############################################################################### -option(USE_ASAN "Enable address sanitization" OFF) -if(USE_ASAN) - add_compile_options(-fsanitize=address -fno-omit-frame-pointer -U_FORTIFY_SOURCE -fno-common) - add_link_options(-fsanitize=address) - link_libraries(asan) -endif(USE_ASAN) - -option(USE_LSAN "Enable leak sanitization" OFF) -if(USE_LSAN) - add_compile_options(-fsanitize=leak -fno-omit-frame-pointer -U_FORTIFY_SOURCE -fno-common) - add_link_options(-fsanitize=leak) - link_libraries(lsan) -endif(USE_LSAN) - -option(USE_TSAN "Enable thread sanitization" OFF) -if(USE_TSAN) - add_compile_options(-fsanitize=thread -fno-omit-frame-pointer -U_FORTIFY_SOURCE -fno-common) - add_link_options(-fsanitize=thread) - link_libraries(tsan) -endif(USE_TSAN) - -option(USE_UBSAN "Enable undefined behaviour sanitization" OFF) -if(USE_UBSAN) - add_compile_options(-fsanitize=undefined -fno-omit-frame-pointer -U_FORTIFY_SOURCE -fno-common) - add_link_options(-fsanitize=undefined) - link_libraries(ubsan) -endif(USE_UBSAN) - -# Option for enabling code profiling. Disabled by default -option(ENABLE_PROFILING "Compile with profiling support enabled." OFF) -if(ENABLE_PROFILING) - if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - message( - WARNING - "Profiling is enabled but no debugging symbols will be kept in the compiled binaries. This may cause fine-grained profilling data to be lost." - ) - endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg -fprofile-arcs") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg -fprofile-arcs") - set(CMAKE_LINKER "${CMAKE_LINKER_FLAGS} -pg -fprofile-arcs") -endif(ENABLE_PROFILING) diff --git a/src/nuclear/docs/.special.rst b/src/nuclear/docs/.special.rst deleted file mode 100644 index 98f135db..00000000 --- a/src/nuclear/docs/.special.rst +++ /dev/null @@ -1,40 +0,0 @@ -.. role:: black -.. role:: gray -.. role:: grey -.. role:: silver -.. role:: white -.. role:: maroon -.. role:: red -.. role:: magenta -.. role:: fuchsia -.. role:: pink -.. role:: orange -.. role:: yellow -.. role:: lime -.. role:: green -.. role:: olive -.. role:: teal -.. role:: cyan -.. role:: aqua -.. role:: blue -.. role:: navy -.. role:: purple - -.. role:: under -.. role:: over -.. role:: blink -.. role:: line -.. role:: strike - -.. role:: it -.. role:: ob - -.. role:: small -.. role:: large - -.. role:: center -.. role:: left -.. role:: right - - -.. (c) Lilian Besson, 2011-2016, https://bitbucket.org/lbesson/web-sphinx/ diff --git a/src/nuclear/docs/CMakeLists.txt b/src/nuclear/docs/CMakeLists.txt deleted file mode 100644 index 6e521352..00000000 --- a/src/nuclear/docs/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -#[[ -MIT License - -Copyright (c) 2017 NUClear Contributors - -This file is part of the NUClear codebase. -See https://github.com/Fastcode/NUClear for further info. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -find_package(Doxygen REQUIRED) -find_package(Sphinx REQUIRED) - -add_custom_target( - docs - COMMAND ${Sphinx_BINARY} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating documentation pages using sphinx" -) - -install( - DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DESTINATION share/doc - OPTIONAL -) diff --git a/src/nuclear/docs/Doxyfile b/src/nuclear/docs/Doxyfile deleted file mode 100644 index c3349c8f..00000000 --- a/src/nuclear/docs/Doxyfile +++ /dev/null @@ -1,12 +0,0 @@ -PROJECT_NAME = "NUClear" -XML_OUTPUT = doxygen -CASE_SENSE_NAMES = NO -INPUT = ../src -RECURSIVE = YES -QUIET = YES -JAVADOC_AUTOBRIEF = YES -GENERATE_LATEX = NO -GENERATE_MAN = NO -GENERATE_RTF = NO -GENERATE_HTML = NO -GENERATE_XML = YES diff --git a/src/nuclear/docs/_static/colours.css b/src/nuclear/docs/_static/colours.css deleted file mode 100644 index fd8271ef..00000000 --- a/src/nuclear/docs/_static/colours.css +++ /dev/null @@ -1,33 +0,0 @@ -/* Colors and text decoration. - For example, :black:`text in black` or :blink:`text blinking` in rST. */ -.black { color:black; } -.gray { color:gray; } -.grey { color:gray; } -.silver { color:silver; } -.white { color:white; } -.maroon { color:maroon; } -.red { color:red; } -.magenta { color:magenta; } -.fuchsia { color:fuchsia; } -.pink { color:pink; } -.orange { color:orange; } -.yellow { color:yellow; } -.lime { color:lime; } -.green { color:green; } -.olive { color:olive; } -.teal { color:teal; } -.cyan { color:cyan; } -.aqua { color:aqua; } -.blue { color:blue; } -.navy { color:navy; } -.purple { color:purple; } -.under { text-decoration: underline; } -.over { text-decoration: overline; } -.blink { text-decoration: blink; } -.line { text-decoration: line-through; } -.strike { text-decoration: line-through; } -.it { font-style: italic; } -.ob { font-style: oblique; } -.small { font-size: small; } -.large { font-size: large; } -.smallpar { font-size: small; } diff --git a/src/nuclear/docs/components.rst b/src/nuclear/docs/components.rst deleted file mode 100644 index 5714d7e4..00000000 --- a/src/nuclear/docs/components.rst +++ /dev/null @@ -1,66 +0,0 @@ -========== -Components -========== -The most significant components of a NUClear system are the `PowerPlant`_, `Reactors`_, `Reactions`_ and `Tasks`_. -It is the interaction between these components that ensures data and code are easily accessible throughout the system. - -PowerPlant -********** -The PowerPlant can be thought of as the central message system through which :ref:`Reactors` communicate. - -.. image:: images/power_plant.svg - :width: 500px - :align: center - -Whenever a reactor emits data into the system, the PowerPlant takes ownership of the data and executes any :ref:`Reactions` which are subscribed to the message. - -The PowerPlant is also responsible for assigning the threads on which the :ref:`Tasks` will run. NUClear is a multithreaded environment, with all threading logic centralised and handled by the PowerPlant. The transparent multithreading uses a threadpool with enough threads to saturate every CPU core in the system, allowing :ref:`Tasks` to execute on a different thread. - -By centralising the threading logic, NUClear provides developers the freedom to concentrate on their :ref:`Reactors` instead of threading problems. The NUClear DSL provides :ref:`Execution Modifiers` should developers wish to execute control over how their threads will run. - -Reactors -******** -A reactor can be thought of as a module. In fact, all modules in the NUClear system will be an extension of NUClear::Reactor. - -During the :ref:`Startup Process`, the reactors for the system will be installed into the :ref:`PowerPlant`. - -From that point on, reactors are primarily responsible for two functions; defining the :ref:`Reactions` and conditions under which they will process, and in some cases, emitting data to the :ref:`PowerPlant` as required. - -Reactions -********* -Reactions provide the definitions of the :ref:`Tasks` which need to run when the data and/or conditions required for the reaction become available/true. - -To setup a reaction, a reactor can use the functionality provided by NUClear::Reactor to subscribe to the :ref:`PowerPlant` for any messages or conditions of interest. Under the hood, these functions are bound by NUClear as callbacks, and it is the execution of these callbacks which will assign :ref:`Tasks` to a thread. - -Subscriptions to the :ref:`PowerPlant` are made using DSL :ref:`On Statements`. The conditions for the request are then further defined using the keywords :ref:`Trigger`, :ref:`With`, :ref:`Every` and :ref:`Always`. - -Developers can execute further control over reactions in the system with the tools provided for :ref:`Managing -Reactions`. - -Tasks -***** -A task is the current execution of a defined reaction within the system. For debugging purposes, all tasks will track -the following information: - -identifier - -reaction_id - -task_id - -cause_reaction_id - -cause_task_id - -emitted() - -started() - -finished() - -exception() - - -.. todo:: - - Update the above list so that it is trigged by Doxygen and brings in the comments... diff --git a/src/nuclear/docs/conf.py b/src/nuclear/docs/conf.py deleted file mode 100644 index 65bfc3d4..00000000 --- a/src/nuclear/docs/conf.py +++ /dev/null @@ -1,358 +0,0 @@ -# -*- coding: utf-8 -*- -# -# NUClear documentation build configuration file, created by -# sphinx-quickstart on Thu Aug 25 23:15:37 2016. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys -# sys.path.insert(0, os.path.abspath('.')) - -# Run doxygen for breathe -from subprocess import call -call('doxygen') - -# -- General configuration ------------------------------------------------ - -def setup(app): - app.add_css_file('colours.css') - - - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'breathe', - 'sphinx.ext.githubpages', - 'sphinx.ext.autosectionlabel', - 'sphinx.ext.todo' -] - -breathe_projects = { "NUClear": "doxygen" } -breathe_default_project = "NUClear" - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The encoding of source files. -# -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'NUClear' -copyright = u'2016, Trent Houliston' -author = u'Trent Houliston' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = u'1.0' -# The full version, including alpha/beta/rc tags. -release = u'1.0.0' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# -# today = '' -# -# Else, today_fmt is used as the format for a strftime call. -# -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = [] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -import sphinx_rtd_theme - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'sphinx_rtd_theme' - - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - -# The name for this set of Sphinx documents. -# " v documentation" by default. -# -# html_title = u'NUClear v1.0.0' - -# A shorter title for the navigation bar. Default is the same as html_title. -# -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# -# html_logo = None - -# The name of an image file (relative to this directory) to use as a favicon of -# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# -# html_extra_path = [] - -# If not None, a 'Last updated on:' timestamp is inserted at every page -# bottom, using the given strftime format. -# The empty string is equivalent to '%b %d, %Y'. -# -# html_last_updated_fmt = None - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# -# html_additional_pages = {} - -# If false, no module index is generated. -# -# html_domain_indices = True - -# If false, no index is generated. -# -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' -# -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# 'ja' uses this config value. -# 'zh' user can custom change `jieba` dictionary path. -# -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'NUCleardoc' - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'NUClear.tex', u'NUClear Documentation', - u'Trent Houliston', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# -# latex_use_parts = False - -# If true, show page references after internal links. -# -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# -# latex_appendices = [] - -# It false, will not define \strong, \code, \titleref, \crossref ... but only -# \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added -# packages. -# -# latex_keep_old_macro_names = True - -# If false, no module index is generated. -# -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'nuclear', u'NUClear Documentation', - [author], 1) -] - -# If true, show URL addresses after external links. -# -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'NUClear', u'NUClear Documentation', - author, 'NUClear', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -# -# texinfo_appendices = [] - -# If false, no module index is generated. -# -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# -# texinfo_no_detailmenu = False diff --git a/src/nuclear/docs/definitions.rst b/src/nuclear/docs/definitions.rst deleted file mode 100644 index 2649988a..00000000 --- a/src/nuclear/docs/definitions.rst +++ /dev/null @@ -1,67 +0,0 @@ -=========== -Definitions -=========== - -blackboard systems -****************** -Blackboard systems use a blackboard to store global data. Modules within a blackboard system communicate with each other through the manipulation of the data elements stored on the blackboard. For example, a module for vision may read images from the blackboard. Once the module has analysed the images, it then writes the observed visual features to the blackboard for other modules to reference. - -.. image:: images/blackboard_architecture.svg - :width: 500px - :align: center - -Blackboard systems are considered easy to implement and provide low computational overheads. However, this architecture is only recommended for small systems. When used as the underlying architecture for complex systems, issues with coupling, where modules need to interact and modify each others internal state can become apparent. - -.. image:: images/blackboard_architecture_coupled.svg - :width: 500px - :align: center - -Issues are also apparent when used in a multi-threaded environment. If individual components are not aware when new and relevant data becomes available, modules may miss data updates, read the same data twice, or read a partially written data element. - - -C++ template metapgrograms -************************** -Template metaprogramming is a technique where templates are used by a compiler to generate temporary source code which will be used at the time of compilation. That is, the generated source code is merged by the compiler with the rest of the source code and then compiled. NUClear uses C++ template metaprogramming to establish message routes at compile time. - -co-messaging -************ -NUClear uses co-messages to hybridize the features of :ref:`blackboard systems` and :ref:`message-passing systems`. - -In modular systems, modules typically have a primary information type that they will perform their operations on. However, the module may also require additional supplementary data, provided from other sources/modules. When this occurs, the additional data must be available to the module when performing its operations. Yet the secondary data may be created at a different rate to that of the primary data source. - -In pure :ref:message-passing robot systems, accessing the data at any time is not possible, as data is only available transiently. If a system requires information created by another module, it must subscribe and then store this information itself to ensure it is available. - -In NUClear, modules can subscribe to both primary and secondary data. As primary data is published, the most recent copy of secondary data will be packaged and sent to the subscribing module as a co-message. - -.. image:: images/co-message.svg - :width: 500px - :align: center - - -control elements -***************** -//ToDo -see hayesroth1985.pdf - -domain specific language -************************ -A domain specific language (DSL) is programming language which has been specialised for a particular domain. The NUClear system incorporates an extensible DSL. see: :ref:`NUClear DSL`. - - -faster communication --------------------- -A simple test system was constructed in both NUClear and Robot Operating System (ROS) a message-passing system modular system. The tests timed and transferred an empty message from end to end. An empty message was chosen to eliminate any performance differences caused by serialisation and copying of information. Tests were completed with and without full CPU load. In all cases, NUClear proved faster at routing messages than ROS. - -//check with Trent if he wants me to elaborate, include more info here - - - -message-passing systems -*********************** -Message passing systems treat each module as a producer/consumer. Data produced by a module is sent through a message routing system to modules which subscribe to that type. Conceptually, these systems are a generalization of a pipeline system where the output from one system is used as the input into the next system. - -.. image:: images/message_passing_system.svg - :width: 500px - :align: center - -Generally, message-passing systems will keep data loosly coupled, but there are several disadvantages in these systems which are not present in :ref:`blackboard systems`. For example, a message-passing system must either provide a copy of the data for each subscriber of a message, or make all access read only which results in a performance penalty within the system. Messaging also means that there is no central data store which can be used; if a module requires information from more than one message, it must handle the storage of this data itself to access it, which adds extra load on the modules, making development harder and reducing the systems performance. diff --git a/src/nuclear/docs/dsl.rst b/src/nuclear/docs/dsl.rst deleted file mode 100644 index e186947b..00000000 --- a/src/nuclear/docs/dsl.rst +++ /dev/null @@ -1,224 +0,0 @@ -.. include:: .special.rst - - -NUClear DSL -=========== - -On Statements -************* - -On statements are used by :ref:`Reactors` wishing to make subscriptions to the :ref:`PowerPlant`. Using this statement, -developers can set the conditions under which desired :ref:`Reactions` will run. - -Anatomy of an on statement --------------------------- -The on statement can be seen as containing three main parts. The DSL Request, the Runtime Arguments, and the Callback. - -:blue:`On`\(:red:`Runtime, Args`).then(:green:`CallbackFunction`); - -:blue:`DSL Request` -------------------- -The DSL request can be fused together through any combination of DSL words. The combination of these words will define -the kind of reaction which is being requested (for example, :ref:`Trigger` will define a reaction that should occur when -a required data type is emitted, while :ref:`Every` will define periodic reactions). - -For reactions to occur, at least one Binding DSL word should be present in the DSL Request. From the provided DSL words, -those which are binding are: :ref:`Trigger`, :ref:`With`, :ref:`Every`, :ref:`Always`, :ref:`Startup`, :ref:`Shutdown`, -:ref:`TCP`, :ref:`UDP` and :ref:`Network` - -:red:`Runtime Arguments` ------------------------- -Some DSL words will provide the ability to make changes to the system during runtime. This means that NUClear avoids -the need for a system restart should a configuration, port number, or file need to be changed while the system is -running. - -From the provided DSL words, those which take runtime arguments are: :ref:`IO`, :ref:`TCP`, and :ref:`UDP` - -:green:`Callback` ------------------ -Finally, the developer can define the callback which will execute when the reaction is triggered during runtime. The -callback can be defined using a C++ lambda expression. - -During system runtime, the argument selection for the callback works on the principle of fission, in that the arguments -provided with the callback can be deduced as needed. For example: - -.. code-block:: C++ - - on<, Optional>().then([](const A& a, const B& b) { - - }); - -In the above request, the Trigger on dataType B has been listed as optional, while the Trigger for dataType A is listed -as mandatory. Yet the callback function lists arguments for both dataType A and dataType B. - -Lets say that dataType A is emitted to the PowerPlant, but at this time, dataType B does not have any data associated -with it. - -Since dataType B was listed as optional, the task associated with this reaction can be scheduled. However, when -executing the callback for this reaction, NUClear will identify that dataType B is not present, and will remove -reference to this data type from the callback, so that the task is only run for dataType A. - -Effectively, through the application of fission, the callback is restructured as per the following example. - -.. code-block:: C++ - - .then([](const A& a){ - - }); - -.. todo:: - - explain how fission works for argument selection and how the type of arguments can be deduced as needed (for const - references vs shared_ptrs and udp autodeserialisation) - -DSL WORDS ----------- - -The following words are available in the DSL. Reactors can fuse together their instructions and requests to the -PowerPlant from any combination of these words. Developers wishing to add their own DSL words to the system can do so -at any time. Please see: :ref:`Extension` - -Data Gathering --------------- - -Trigger -``````` -.. doxygenstruct:: NUClear::dsl::word::Trigger - -With -```` -.. doxygenstruct:: NUClear::dsl::word::With - -Data Modifiers --------------- -Last -```` -.. doxygenstruct:: NUClear::dsl::word::Last - -Optional -```````` -.. doxygenstruct:: NUClear::dsl::word::Optional - -Execution Modifiers -------------------- - -Single -`````` -.. doxygenstruct:: NUClear::dsl::word::Single - -Buffer -`````` -.. doxygenstruct:: NUClear::dsl::word::Buffer - -Priority -```````` -.. doxygenstruct:: NUClear::dsl::word::Priority - -Sync -```` -.. doxygenstruct:: NUClear::dsl::word::Sync - -MainThread -`````````` -.. doxygenstruct:: NUClear::dsl::word::MainThread - -Timing Keywords ---------------- - -Every -````` -.. doxygenstruct:: NUClear::dsl::word::Every - -Always -`````` -.. doxygenstruct:: NUClear::dsl::word::Always - -Watchdog -```````` -.. doxygenstruct:: NUClear::dsl::word::Watchdog - - -Event Keywords --------------- - -Startup -``````` -.. doxygenstruct:: NUClear::dsl::word::Startup - -Shutdown -```````` -.. doxygenstruct:: NUClear::dsl::word::Shutdown - -IO Keywords ------------ - -IO -`` -.. doxygenstruct:: NUClear::dsl::word::IO - -TCP -``` -.. doxygenstruct:: NUClear::dsl::word::TCP - -UDP -``` -.. doxygenstruct:: NUClear::dsl::word::UDP - -Network -``````` -.. doxygenstruct:: NUClear::dsl::word::Network - - -Emit Statements -*************** - -Emit statements are used by :ref:`Reactors` wishing to emit data to the :ref:`PowerPlant`. Using this statement, -developers can specify when data will be emitted to the system. - -When using NUClear, data will most likely be emitted during a reaction. However, where necessary, emissions can also -occur during reactor construction (where it is recommended to use :ref:`Scope::Initialise`), or in some cases from -within the PowerPlant itself (for example, when using a third party library which does not have a reactor). - -Any data emitted to the PowerPlant will be sent with a unique pointer. The PowerPlant will take ownership of this -pointer and run any necessary callbacks to trigger reactions (create tasks). - -Note that data can be emitted under varying scopes: - -Local Emitting --------------- - -These emissions send data to the local instance of the NUClear PowerPlant. There are a number of scopes under which -these emissions can take place: - -Scope::LOCAL -```````````` -.. doxygenstruct:: NUClear::dsl::word::emit::Local - -Scope::INLINE -````````````` -.. doxygenstruct:: NUClear::dsl::word::emit::Inline - -Scope::Initialise -`````````````````` -.. doxygenstruct:: NUClear::dsl::word::emit::Initialise - -Scope::DELAY -````````````` -.. doxygenstruct:: NUClear::dsl::word::emit::Delay - -Scope::WATCHDOG -`````````````` -.. doxygenstruct:: NUClear::dsl::word::emit::Watchdog - -Network Emitting ----------------- - -Network emissions can be used to send data through the network on which the current system is running. - -Scope::UDP -`````````` -.. doxygenstruct:: NUClear::dsl::word::emit::UDP - -Scope::Network -`````````````` -.. doxygenstruct:: NUClear::dsl::word::emit::Network diff --git a/src/nuclear/docs/extension.rst b/src/nuclear/docs/extension.rst deleted file mode 100644 index 55ff8d12..00000000 --- a/src/nuclear/docs/extension.rst +++ /dev/null @@ -1,220 +0,0 @@ -========= -Extension -========= - -Fusion Engine -************* - -The fusion engine combines a number of templated types into a single "fused" type. This allows it to be treated as a -single type. The fused type, most importantly, exposes the methods described below which it then calls in an iterative -manner for each individual type fused. - -The parse type is used as the interface into the fusion engine, it handles calling the fused type with the correct -template and filling in undefined methods with no-operations. - -Both the fused type and parsed type only has static methods defined, so it would be pointless to instantiate it. - -This means calling `Parse, Sync, Startup>.bind()` will call `Trigger.bind()`, then a no-operation, -then will call `Startup.bind()`, using `DSL = Parse, Sync, Startup>`. - -Fusions can be nested, this can be useful for creating a DSL word that combines the functionality of multiple other -words. - -Extending the DSL -***************** - -The DSL words are types, adding a word is as simple as declaring a new type with at least one of the following static -template methods defined. Each undefined static template method will automatically behave as a no-operation. - -The template of each of these static methods should be `template `, this will have the parsed DSL words -passed in. It is important to note that the type will only be considered by NUClear in a static context. If any -attributes need to be stored in the DSL word type template it and use static variables, see `Sync`. - -There are DSL words that are not meant to be used directly but as a part of other words, see `CacheGet` and `TypeBind`. -`TypeBind` adds the reaction to the list of reactions to be run when a `Local` or `Inline` emit is called for the data -type. `CacheGet` gets the last value from a thread-local cache (see `ThreadSore` below) this cache is usually populated -in the last a `Local` or `Inline` emit call for the data type. - -If the type you want to become a DSL extension word is not defined within your control specialise `DSLProxy<>` with the -type. Provide the template methods to the specialisation of `DSLProxy<>` as if it were the type. - -Bind ----- - -.. codeblock:: c++ - template - static void bind(const std::shared_ptr& reaction, /*More arguments can be declared*/) - -This function is called when the reaction is bound, it should be thought of as the constructor. It is used to setup -anything that is required by the DSL word. - -A common use for extensions is to setup something that will generate tasks for this reaction. This can be done by -communicating to an extension reactor via a helper type that the extension reactor triggers on. - -An unbinder, if needed, should be passed to the reaction's unbinders callback list from the bind call. This is used as a -destructor. -e.g. for the `IO` word we have -.. codeblock:: c++ - reaction->unbinders.push_back([](const threading::Reaction& r) { - r.reactor.emit(std::make_unique>(r.id)); - }); - -which will tell the extension reactor that this reaction no longer exists. - -The extra arguments are passed in, in order, from the `on` call. - -Get ---- - -.. codeblock:: c++ - template - static T get(threading::ReactionTask& task) - -This is used to get the data for the callback. The returned value is passed to the callback. - -If the return type can be dereferenced, then either the return type or the type returned by the dereference of the -return type can be used in the callback. - -If data needs to be passed to a task when it is submitted to the `Powerplant` use `ThreadStore`. The thread store is -a static variable that can be accessed from within the get method. Make sure to clear the `ThreadStore` after use to -ensure future invocations won't get stale data. - -Precondition ------------- - -.. codeblock:: c++ - template - static bool precondition(threading::ReactionTask& task) - -A precondition is used to test if the reaction should run. On a true return the reaction will run as normal. On a false -return the reaction will be dropped. - -Postcondition -------------- - -.. codeblock:: c++ - template - static void postcondition(threading::ReactionTask& task) - -This will run after the callback for a reaction task has run and finished. - -Reschedule ----------- - -.. codeblock:: c++ - template - static std::unique_ptr reschedule(std::unique_ptr&& task) - -The ownership of the reaction task is passed to the DSL word. The task returned will be run instead of the passed in -reaction task. If the returned task is the one passed in the task will be run normally. - -If a null pointer is returned, no task is run. - -When it is time to schedule the task either return it in another reschedule call or call -`task.parent.reactor.powerplant.submit(std::move(task));`. Both these will pass the ownership of the task on. - -Transient ---------- - -.. codeblock:: c++ - template <> - struct is_transient : std::true_type {}; - -When the data returned from a `get` is falsy and its type is marked transient the latest truthy data from the `get` -return is instead used. If the data is falsy and is either not marked transient or nothing truthy has yet been returned -then the reaction is cancelled. - -Custom Emit Handler -******************* - -.. codeblock:: c++ - template - struct EmitType { - static void emit(PowerPlant& powerplant, ...) - }; - -Emit can be extended by creating a template struct that has at least one method called `emit`. This is then called from -a Reactor with `emit` and the arguments will be passed through. - -.. codeblock:: c++ - static void emit(PowerPlant& powerplant, std::shared_ptr data, ...) - -If the second parameter is a shared pointer to the templated type when calling emit a unique pointer will be -automatically converted to a shared pointer. - -Example Case -************ - -Sync ----- - -Here, we have an ordinary C++ class. In this case we start by defining the attributes we need in a static context. -The template is used to have multiple static contexts. -.. codeblock:: c++ - template - struct Sync { - - using task_ptr = std::unique_ptr; - - /// Our queue which sorts tasks by priority - static std::priority_queue queue; - /// How many tasks are currently running - static volatile bool running; - /// A mutex to ensure data consistency - static std::mutex mutex; - -Now we define the `reschedule` to interrupt any new tasks if we are currently running. Recall that NUClear is -multithreaded so a mutex is needed when accessing the static members. -.. codeblock:: c++ - template - static std::unique_ptr reschedule( - std::unique_ptr&& task) { - - // Lock our mutex - std::lock_guard lock(mutex); - - // If we are already running then queue, otherwise return and set running - if (running) { - queue.push(std::move(task)); - return std::unique_ptr(nullptr); - } - else { - running = true; - return std::move(task); - } - } - -To run any queued tasks after the current one is done we define `postcondition`. When there is a task in the queue we -resubmit it to the PowerPlant to be run. -.. codeblock:: c++ - template - static void postcondition(threading::ReactionTask& task) { - - // Lock our mutex - std::lock_guard lock(mutex); - - // We are finished running - running = false; - - // If we have another task, add it - if (!queue.empty()) { - std::unique_ptr next_task( - std::move(const_cast&>(queue.top()))); - queue.pop(); - - // Resubmit this task to the reaction queue - task.parent.reactor.powerplant.submit(std::move(next_task)); - } - } - -We need to instantiate our static members outside the class definition. -.. codeblock:: c++ - }; - template - std::priority_queue::task_ptr> Sync::queue; - - template - volatile bool Sync::running = false; - - template - std::mutex Sync::mutex; diff --git a/src/nuclear/docs/images/blackboard.svg b/src/nuclear/docs/images/blackboard.svg deleted file mode 100644 index 80d154d6..00000000 --- a/src/nuclear/docs/images/blackboard.svg +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - Blackboard - - - - - Blackboard - - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - diff --git a/src/nuclear/docs/images/blackboard_architecture.svg b/src/nuclear/docs/images/blackboard_architecture.svg deleted file mode 100644 index 16b8d5f3..00000000 --- a/src/nuclear/docs/images/blackboard_architecture.svg +++ /dev/null @@ -1,656 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - - - - - - - - Blackboard - - - - - Blackboard - - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - diff --git a/src/nuclear/docs/images/blackboard_architecture_coupled.svg b/src/nuclear/docs/images/blackboard_architecture_coupled.svg deleted file mode 100644 index e7ebe454..00000000 --- a/src/nuclear/docs/images/blackboard_architecture_coupled.svg +++ /dev/null @@ -1,826 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - - - - - - - - Blackboard - - - - - Blackboard - - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - Data - - - Data - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/nuclear/docs/images/co-message.svg b/src/nuclear/docs/images/co-message.svg deleted file mode 100644 index 3aa3819e..00000000 --- a/src/nuclear/docs/images/co-message.svg +++ /dev/null @@ -1,364 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - Message Router - - - - - NUClear - - - - - - - - - primary data - secondary data - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - Module - - - - - - - - - - Module - - - co-message - - - - - - diff --git a/src/nuclear/docs/images/message_passing_system.svg b/src/nuclear/docs/images/message_passing_system.svg deleted file mode 100644 index 80f8c7fd..00000000 --- a/src/nuclear/docs/images/message_passing_system.svg +++ /dev/null @@ -1,430 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - Module - - - Module - - - - - - - - - Message Router - - - - - Message Router - - - - - - - - - Module - - - Module - - - - - - - - - - - - - message - message - message - message - message - - diff --git a/src/nuclear/docs/images/on_statement.svg b/src/nuclear/docs/images/on_statement.svg deleted file mode 100644 index 7370ce17..00000000 --- a/src/nuclear/docs/images/on_statement.svg +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/src/nuclear/docs/images/power_plant.svg b/src/nuclear/docs/images/power_plant.svg deleted file mode 100644 index 8efe6d3f..00000000 --- a/src/nuclear/docs/images/power_plant.svg +++ /dev/null @@ -1,721 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - PowerPlant - - - - - PowerPlant - - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/nuclear/docs/images/reactors.svg b/src/nuclear/docs/images/reactors.svg deleted file mode 100644 index 587a60fa..00000000 --- a/src/nuclear/docs/images/reactors.svg +++ /dev/null @@ -1,491 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - PowerPlant - - - - - PowerPlant - - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - - - - - - - - Reactor - - - Reactor - - - - diff --git a/src/nuclear/docs/index.rst b/src/nuclear/docs/index.rst deleted file mode 100644 index b812809e..00000000 --- a/src/nuclear/docs/index.rst +++ /dev/null @@ -1,25 +0,0 @@ -=========================================================== -NUClear - Realtime modular framework for high speed systems -=========================================================== - -Contents: - -.. toctree:: - :maxdepth: 2 - - overview - components - quick_start - dsl - managing_reactions - startup - networking - extension - definitions - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/src/nuclear/docs/managing_reactions.rst b/src/nuclear/docs/managing_reactions.rst deleted file mode 100644 index 4633bdf1..00000000 --- a/src/nuclear/docs/managing_reactions.rst +++ /dev/null @@ -1,29 +0,0 @@ -================== -Managing Reactions -================== - -During system runtime, executing reactions can be managed via the reaction handle. A reaction handle is provided for -any binding :ref:`On Statements`. Once an on statement has been bound, the reaction handle will be enabled. -If necessary, reactions can toggle between enabled and disabled during runtime. - -The reaction handle provides the following functions for managing a reaction: - -disable -``````` -.. doxygenfunction:: NUClear::threading::ReactionHandle::disable - -enable -`````` -.. doxygenfunction:: NUClear::threading::ReactionHandle::enable - -enable(bool set) -````````````````` -.. doxygenfunction:: NUClear::threading::ReactionHandle::enable(bool) - -enabled -```````` -.. doxygenfunction:: NUClear::threading::ReactionHandle::enabled - -unbind -`````` -.. doxygenfunction:: NUClear::threading::ReactionHandle::unbind diff --git a/src/nuclear/docs/networking.rst b/src/nuclear/docs/networking.rst deleted file mode 100644 index 05d0c8ed..00000000 --- a/src/nuclear/docs/networking.rst +++ /dev/null @@ -1,50 +0,0 @@ -========== -Networking -========== - -TODO Explain the NUClear network mesh - -Serialisation -************* - -Serialisation is used to convert data to a type that can be written to files or sent over a network connection and be -usable by the receiving device. See `Wikipedia `_ for further information. - -NUClear provides helper functions for dealing with serialisation, from the namespace ``NUClear::util::serialise`` there -are ``Searialise::serialise``, ``Searialise::deserialise`` and ``Searialise::hash`` for serialisation, -deserialisation and hashing the type's name respectively. The functions are used internally by NUClear to try to -serialise/deserialise data sent/received via ``Network`` or ``UDP``. These functions are only defined for specific -types. - -Trivial Data Types ------------------- - -NUClear defines serialisation for `Trivial Types `_ with some -caveats. The serialisation of trivial data is dependant on both the -`endianness `_ and the -`alignment `_ of the data on the computer running the code. - -NUClear also defines serialisation of iterators of trivial data types. - -Google Protobuf Types ---------------------- - -NUClear wraps the serialisation and deserialisation of google -`protobuf `_ types. Use protobuf over trivial data types when -communicating between machines or programs. - -Custom Types ------------- - -To add another type to be able to be serialised add another partial specialisation to ``Serialise`` declaring -the type of ``Check``. The easiest ``Check`` is `is_same `_ as this -checks explicitly for an explicit type. Be careful about multiple declarations. - -For this partial specialisation three static methods need to be defined. - -.. codeblock:: c++ - static std::vector serialise(const T& in) - - static T deserialise(const std::vector& in) - - static uint64_t hash() diff --git a/src/nuclear/docs/overview.rst b/src/nuclear/docs/overview.rst deleted file mode 100644 index abe6d2a7..00000000 --- a/src/nuclear/docs/overview.rst +++ /dev/null @@ -1,11 +0,0 @@ -======== -Overview -======== - -NUClear is a software framework designed to aid in the development of real time modular systems. It is built from a set of :ref:`C++ template metapgrograms` which control the flow of information through the system. These metaprograms reduce the cost of routing messages between modules, resulting in :ref:`faster communication` than other similar systems. - -NUClear utilises a system called :ref:`co-messaging` to allow simple event callback functions through an expressive :ref:`domain specific language` (DSL). The DSL is highly extensible and provides several attachment points to develop new DSL keywords as needed. - -NUClear has been successfully applied in several projects for robotics and virtual reality. - -If you are starting a new project using NUClear the `NUClear Roles system `_ is highly recommended as it wraps much of the complexity of managing modules. diff --git a/src/nuclear/docs/quick_start.rst b/src/nuclear/docs/quick_start.rst deleted file mode 100644 index 34a1182e..00000000 --- a/src/nuclear/docs/quick_start.rst +++ /dev/null @@ -1,14 +0,0 @@ -================= -Quick Start Guide -================= - -Using NUClear Roles -******************* - -**GUIDE TO COME** - -.. TODO:: - create a new repo - subtree the nuclear roles folder into nuclear - create a module - create some messages diff --git a/src/nuclear/docs/requirements.txt b/src/nuclear/docs/requirements.txt deleted file mode 100644 index b04496ee..00000000 --- a/src/nuclear/docs/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -breathe==4.35.0 -jinja2==3.1.4 -Sphinx>=5.0.0 -sphinx_rtd_theme==1.0.0 diff --git a/src/nuclear/docs/startup.rst b/src/nuclear/docs/startup.rst deleted file mode 100644 index 3adc2479..00000000 --- a/src/nuclear/docs/startup.rst +++ /dev/null @@ -1,196 +0,0 @@ -=============== -Startup Process -=============== - -The runtime process for NUClear has 3 main phases; the :ref:`Initialization Phase (single threaded)`, where the -system, reactors, and requests are loaded, the :ref:`Execution Phase (multithreaded)` which can be thought of as the -general runtime of the system, and the :ref:`Shutdown Phase (multithreaded)`, which is the process the system will run -through once the shutdown command is executed. - -Initialization Phase (single threaded) -************************************** -There are three main activities which need to occur during the system initialization. These stages will setup the -system, before any standard runtime execution occurs. It is important to note that the system will be running on a -single thread throughout this phase, and therefore, the order in which the developer lists specific activities is -important. - -Install the PowerPlant ----------------------- -This phase begins with the installation of the PowerPlant. When installing the PowerPlant, it is recommended to use -the `NUClear Roles system `_, as it allows the use of a configuration -file for the process. - -.. code-block:: C++ - - NUClear::Configuration config; - config.default_pool_concurrency = 1; - NUClear::PowerPlant plant(config); - -.. todo:: - - Requires a link to details about the Nuclear Roles config details. - -Install Reactors ----------------- -Once the plant is installed, the reactors can be loaded. - -.. code-block:: C++ - - plant.install(); - -This command will run the reactors constructors, and install them into the PowerPlant. There are two main aspects -developers should consider when designing a reactor's construction. - -On Statements -~~~~~~~~~~~~~ - -Most of the :ref:`On Statements` which run during a reactor's construction will setup the binding requests under which -:ref:`Tasks` will be created. Any tasks created as a result of local data emission for these reactions will be queued, -and will not run until the :ref:`Execution Phase (multithreaded)`. Note that this is the standard behaviour, however -**there are exceptions to this behaviour which developers will find useful.** For example: - -- on: This is part of the `NUClear Roles system `_ and can - be used during a reactors constructor. This request will run immediately, as an in-line binding reaction. -- on: This is part of the `NUClear Roles system `_ and can - be used during a reactors constructor. This request will run immediately, as an in-line binding reaction. - -.. todo:: - - Requires a link to details about the Nuclear Roles on config and on filewatcher stuff. - -Data Emission Statements -~~~~~~~~~~~~~~~~~~~~~~~~ - -As the system is single threaded at this time, the order in which reactors are installed can be significantly important. -This is pertinent when dealing with any data emissions during reactor construction which are NOT emitted under -:ref:`Scope::Initialise`. For example; data emission during the construction of a reactor using :ref:`Scope::INLINE`, -:ref:`Scope::UDP`, or :ref:`Scope::Network` will trigger any necessary activity to run inline. Should any reactions be -defined to run as a result of the emission, the task will be generated and also run inline. It is here where the order -in which reactors are installed becomes important. Suppose Reactor1 were to emit under :ref:`Scope::INLINE`, and -Reactor2 had a reaction defined to run on the associated datatype. In this case, the reaction defined by Reactor2 would -not run, as it was not yet defined at the time of data emission. However, should the roles be reserved, then the -reaction would run. - -**General Rule of Thumb:** If a reactor needs to emit data during this phase, it is recommended to use -:ref:`Scope::Initialise`. This will put a hold on the data emission, until the next step in the process -:ref:`Initialise Scope Tasks`, ensuring that any reactions subscribed to the emission will run. Checkout the -:ref:`Emissions Scope Table` for clarity. - -.. todo:: - - Old text: Keeping it here as it might be useful at some point. - In typical applications, it is normal to define any binding DSL requests within a reactor's constructor. However, - where necessary, a reactor might emit initialization data to the system. *When emitting initialization data to the - system, there are a few points a developer should consider:* - - As the system is single threaded at this time, the order in which reactors are installed is significantly important. - **Any reactors which emit initialization data during construction should be installed AFTER any reactors/reactions - which are triggered by that data.** Issues can occur if data is emitted under a :ref:`Scope::LOCAL` **BEFORE** the - subscribing reactors/reactions have been installed. Consider the case where Reactor1 emits initialization data, for - which Reactor2 has an on request. The trigger cannot be bound for Reactor1's first emission because the - callback associated with task creation did not exist at the time of data emission. As such, an associated task for - Reactor2's on request cannot be made at this point. - - **So is there a better way?** Absolutely! If a reactor needs to emit data during this phase, it is recommended - to use :ref:`Scope::Initialise`. This will put a hold on the data emission, until the next step in the process - :ref:`Initialise Scope Tasks`, ensuring that any reactions subscribed to the emission will run. - - Anything else?** Emissions during the construction of reactors using :ref:`Scope::INLINE`, :ref:`Scope::UDP` and - :ref:`Scope::Network` will trigger any reactions (which have already been defined - before the data emission) and - force any associated tasks to run inline. - - **Feeling confused?** Its actually really simple. Checkout the :ref:`Emissions Scope Table` for clarity. - - -Start the PowerPlant --------------------- -Once the reactors have been installed, and the binding reaction requests have been established, its time to start up -the system. - -.. code-block:: C++ - - plant.start(); - -This command will run two main actions before transitioning to the :ref:`Execution Phase (multithreaded)`. - -Initialise Scope Tasks -~~~~~~~~~~~~~~~~~~~~~~ - -Any data emissions which were emitted under a the :ref:`Scope::Initialise` will run at this time. The system is still -single threaded, so these emissions will run one by one, in the order they were installed. As the emission run, the -associated Tasks will be bound. Tasks generated under these emissions will be queued, but will not start execution -until the :ref:`Execution Phase (multithreaded)`. Tasks will be queued based on their priority level, then their -emission timestamp. - -DSL Startup Requests -~~~~~~~~~~~~~~~~~~~~ - -Any requests using an on definition will be generated and will run now. These requests will run one-by-one, -using the order in which they were installed. Once these tasks have completed processing, the system will transition -to the next phase. - -Execution Phase (multithreaded) -******************************* -This phase is generally referred to as the standard system runtime. During this phase, the threadpool will be started. - -Once started, any reactions requested with an on<:ref:`Always`> definition will start running. - -The system will then process any reactions requested with an on<:ref:`MainThread`> definition. - -From here, any other tasks already queued will be processed and the system will start ticking over as per the setup. - -During this phase, the system will be responsive to any of the :ref:`Managing Reactions` commands, as well as any -changes to the run time arguments for reactions defined with :ref:`IO`, :ref:`TCP`, :ref:`UDP`, or any other applicable -:ref:`Extension` from your system. - -The system will tick along, until the shutdown command is given, pushing it into the next phase: - -.. code-block:: C++ - - powerplant.shutdown(); - -Note that all reactors in the system are given a reference to the powerplant object, so that any reactor/reaction with a -callback access to the powerPlant. Call the shutdown() command under desired conditions. - -.. todo:: - - Trent -in Audio1 at (58:38) you say anyone with the powerplant object can shut it down. Apart from the - reactors, who else has the powerplant object? -- -NUClear Roles// - -Shutdown Phase (multithreaded) -****************************** -Once the shutdown event is executed, any existing tasks which were already queued will run and finish as normal. -Any on<:ref:`Shutdown`>() reaction requests will then be queued (in the order in which they were installed) with -:ref:`Priority`::IDLE. - -Note that during this phase, any other task which would normally be scheduled as a result of a non-direct emission will -be silently dropped, while any tasks which would occur as a result of a :ref:`Scope::INLINE` emission will interrupt the -shutdown process and run as normal. - -.. todo:: - - Trent - did you decide to give on shutdown tasks low priority? i.e; idle - - table below - is not confirming to widths and needs to be updated. Can generate table properly now though. - - -Emissions Scope Table -********************* - -.. table:: - - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | | :ref:`Initialization Phase (single threaded)` | :ref:`Execution Phase (multithreaded)` | :ref:`Shutdown Phase (multithreaded)` | - +==========================+=============================================================================================================================================================================================================================================================================================================================================+======================================================================================================================================================================================================================+=====================================================================================================================================================================================================================+ - | :ref:`Scope::LOCAL` | Schedules any tasks for reactions which are currently loaded and bound to the emission data. Adds to the queue of tasks to start running when the system shifts to the :ref:`Execution Phase (multithreaded)` | Schedules any tasks for reactions which are bound to the emission data. Adds to the queue of tasks based on the desired :ref:`Priority` level | Any emissions under this scope while the system is in the shutdown phase are ignored. | - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`Scope::INLINE` | Schedules any tasks for reactions which are currently loaded and bound to the emission data. Pauses the initialization phase, and runs the task in-line. The initialization phase continues upon task completion. | Schedules any tasks for reactions which are currently loaded and bound to the emission data. Pauses the task currently executing and runs the new task in-line. The execution phase continues upon task completion. | Schedules any tasks for reactions which are currently loaded and bound to the emission data. Pauses the task currently executing and runs the new task in-line. The shutdown phase continues upon task completion. | - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`Scope::Initialise` | Data emitted under this scope during this phase will wait until all reactors have been installed into the powerPlant before triggering any reactions. Any tasks generated as a result of this emission type are the first tasks to run when the powerPlant starts. This is the recommended emission type for this phase of system startup. | Any emissions under this scope while the system is in the execution phase are ignored. | Any emissions under this scope while the system is in the shutdown phase are ignored. | - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`Scope::DELAY` | The delay countdown starts at the time of emission. Once the delay time-frame has passed, any tasks for reactions which are currently loaded and bound to the emission data are scheduled. Adds to the queue of tasks to start running when the system shifts to the :ref:`Execution Phase (multithreaded)` | Waits for the associated delay timeframe, then schedules any tasks for reactions which are bound to the emission data. Adds to the queue of tasks based on the desired :ref:`Priority` level | Any emissions under this scope while the system is in the shutdown phase are ignored. | - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`Scope::UDP` | Emits the data over the UDP network. Should any UDP reaction request be loaded in the system based on this data emission, schedules the task to run in-line. Pauses the initialization phase, and runs the task in-line. The initialization phase continues upon task completion. | Emits the data over the UDP network. Should any UDP reaction request be loaded in the system based on this data emission, schedules the task to run in-line. | Any emissions under this scope while the system is in the shutdown phase are ignored. | - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | :ref:`Scope::Network` | Emits the data over the NUClear network. Should any network reaction request be loaded in the system based on this data emission, schedules the task to run in-line. Pauses the initialization phase, and runs the task in-line. The initialization phase continues upon task completion. | Emits the data over the NUClear network. Should any network reaction request be loaded in the system based on this data emission, schedules the task to run in-line. | Any emissions under this scope while the system is in the shutdown phase are ignored. | - +--------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ diff --git a/src/nuclear/sonar-project.properties b/src/nuclear/sonar-project.properties deleted file mode 100644 index 60dc88e4..00000000 --- a/src/nuclear/sonar-project.properties +++ /dev/null @@ -1,9 +0,0 @@ -sonar.projectName=NUClear -sonar.projectKey=Fastcode_NUClear -sonar.organization=fastcode -sonar.projectVersion=1.0 - -sonar.sources=src -sonar.tests=tests - -sonar.sourceEncoding=UTF-8 diff --git a/src/nuclear/src/CMakeLists.txt b/src/nuclear/src/CMakeLists.txt deleted file mode 100644 index 9ce7a65a..00000000 --- a/src/nuclear/src/CMakeLists.txt +++ /dev/null @@ -1,88 +0,0 @@ -#[[ -MIT License - -Copyright (c) 2013 NUClear Contributors - -This file is part of the NUClear codebase. -See https://github.com/Fastcode/NUClear for further info. - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -documentation files (the "Software"), to deal in the Software without restriction, including without limitation the -rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -]] - -# Configure the two versions of the main header (in source vs nuclear_bits) -set(nuclear_include_base_directory "") -configure_file(nuclear.in ${PROJECT_BINARY_DIR}/include/nuclear) -set(nuclear_include_base_directory "nuclear_bits/") -configure_file(nuclear.in ${PROJECT_BINARY_DIR}/nuclear) - -# Build the library -find_package(Threads REQUIRED) -file(GLOB_RECURSE src "*.c" "*.cpp" "*.hpp" "*.ipp") -add_library(nuclear STATIC ${src}) -add_library(NUClear::nuclear ALIAS nuclear) - -# Set compile options for NUClear -target_link_libraries(nuclear ${CMAKE_THREAD_LIBS_INIT}) -set_target_properties(nuclear PROPERTIES POSITION_INDEPENDENT_CODE ON) -target_compile_features(nuclear PUBLIC cxx_std_14) - -# Enable warnings, and all warnings are errors -if(MSVC) - target_compile_options(nuclear PRIVATE /W4 /WX) -else() - target_compile_options(nuclear PRIVATE -Wall -Wextra -pedantic) -endif(MSVC) - -# Make the NUClearConfig files -include(GNUInstallDirs) -include(CMakePackageConfigHelpers) -set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_FULL_INCLUDEDIR}) -write_basic_package_version_file(${PROJECT_BINARY_DIR}/NUClearConfigVersion.cmake COMPATIBILITY SameMajorVersion) -configure_package_config_file( - ${PROJECT_SOURCE_DIR}/cmake/NUClearConfig.cmake.in ${PROJECT_BINARY_DIR}/NUClearConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NUClear - PATH_VARS INSTALL_INCLUDE_DIR -) - -# Install version, config and target files. -install(FILES ${PROJECT_BINARY_DIR}/NUClearConfigVersion.cmake ${PROJECT_BINARY_DIR}/NUClearConfig.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NUClear -) -install( - EXPORT nuclear-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/NUClear - NAMESPACE NUClear:: -) - -# Install headers and targets -install( - TARGETS nuclear - EXPORT nuclear-targets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -) -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nuclear_bits - FILES_MATCHING - PATTERN "*.hpp" - PATTERN "*.ipp" - PATTERN "*.h" -) -install(FILES ${PROJECT_BINARY_DIR}/nuclear DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -export( - TARGETS nuclear - NAMESPACE NUClear:: - FILE nuclear-targets.cmake -) diff --git a/src/nuclear/src/Configuration.hpp b/src/nuclear/src/Configuration.hpp deleted file mode 100644 index c31ef042..00000000 --- a/src/nuclear/src/Configuration.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2023 NUClear Contributors - * - * This file is part of the NUClear codebase. - * See https://github.com/Fastcode/NUClear for further info. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef NUCLEAR_CONFIGURATION_HPP -#define NUCLEAR_CONFIGURATION_HPP - -#include -#include - -namespace NUClear { - -/** - * This class holds the configuration for a PowerPlant. - */ -struct Configuration { - /// The number of threads the system will use for the default thread pool - int default_pool_concurrency = - std::thread::hardware_concurrency() == 0 ? 2 : int(std::thread::hardware_concurrency()); -}; - -} // namespace NUClear - -#endif // NUCLEAR_CONFIGURATION_HPP diff --git a/src/nuclear/src/Environment.hpp b/src/nuclear/src/Environment.hpp deleted file mode 100644 index 2122fea2..00000000 --- a/src/nuclear/src/Environment.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2013 NUClear Contributors - * - * This file is part of the NUClear codebase. - * See https://github.com/Fastcode/NUClear for further info. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef NUCLEAR_ENVIRONMENT_HPP -#define NUCLEAR_ENVIRONMENT_HPP - -#include - -#include "LogLevel.hpp" - -namespace NUClear { - -// Forward declare reactor and powerplant -class Reactor; -class PowerPlant; - -/** - * Environment defines variables that are passed from the installing PowerPlant context into a Reactor. - * - * The Environment is used to provide information from the PowerPlant to Reactors. - * Each Reactor owns it's own environment and can use it to access useful information. - */ -class Environment { -public: - Environment(PowerPlant& powerplant, std::string reactor_name) - : powerplant(powerplant), reactor_name(std::move(reactor_name)) {} - -private: - friend class PowerPlant; - friend class Reactor; - - /// The PowerPlant to use in this reactor - PowerPlant& powerplant; - /// The name of the reactor - std::string reactor_name; -}; - -} // namespace NUClear - -#endif // NUCLEAR_ENVIRONMENT_HPP diff --git a/src/nuclear/src/LogLevel.cpp b/src/nuclear/src/LogLevel.cpp deleted file mode 100644 index e7dd3813..00000000 --- a/src/nuclear/src/LogLevel.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2013 NUClear Contributors - * - * This file is part of the NUClear codebase. - * See https://github.com/Fastcode/NUClear for further info. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "LogLevel.hpp" - -#include - -namespace NUClear { - -std::string to_string(const LogLevel& level) { - switch (level) { - case LogLevel::TRACE: return "TRACE"; - case LogLevel::DEBUG: return "DEBUG"; - case LogLevel::INFO: return "INFO"; - case LogLevel::WARN: return "WARN"; - case LogLevel::ERROR: return "ERROR"; - case LogLevel::FATAL: return "FATAL"; - default: - case LogLevel::UNKNOWN: return "UNKNOWN"; - } -} - -LogLevel from_string(const std::string& level) { - return level == "TRACE" ? LogLevel::TRACE - : level == "DEBUG" ? LogLevel::DEBUG - : level == "INFO" ? LogLevel::INFO - : level == "WARN" ? LogLevel::WARN - : level == "ERROR" ? LogLevel::ERROR - : level == "FATAL" ? LogLevel::FATAL - : LogLevel::UNKNOWN; -} - -std::ostream& operator<<(std::ostream& os, const LogLevel& level) { - return os << to_string(level); -} - -} // namespace NUClear diff --git a/src/nuclear/src/LogLevel.hpp b/src/nuclear/src/LogLevel.hpp deleted file mode 100644 index 148a4e14..00000000 --- a/src/nuclear/src/LogLevel.hpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2013 NUClear Contributors - * - * This file is part of the NUClear codebase. - * See https://github.com/Fastcode/NUClear for further info. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef NUCLEAR_LOGLEVEL_HPP -#define NUCLEAR_LOGLEVEL_HPP - -#include - -// Why do we need to include platform.hpp here? -// Because windows defines a bunch of things for legacy reasons, one of which is a #define for ERROR as blank -// Of course this causes a problem when we define our own token below as error as the preprocessor removes it -// The platform.hpp fixes this (and many other windows nonsense) so include it here to solve that issue -#include "util/platform.hpp" - -namespace NUClear { - -/** - * LogLevel defines the different levels log messages can be set to. - * - * Log levels are used to provide different levels of detail on a per-reactor basis. - * The logging level of a reactor can be changed by setting it in the install function. - */ -enum LogLevel : uint8_t { - /** - * Don't use this log level when emitting logs, it is for setting reactor log level from non reactor sources. - * - * Specifically when a NUClear::log is called from code that is not running in a reaction (even transitively) then - * the reactor_level will be set to UNKNOWN. - */ - UNKNOWN, - - /** - * The Trace level contains messages that are used to trace the exact flow of execution. - * - * This level is extremely verbose and often has a message per line of code. - */ - TRACE, - - /** - * Debug contains messages that represent the inputs and outputs of different computation units. - * - * If you have a function that performs three steps to do something then it's likely that you will have a message - * for the input and output of those three steps. - * Additionally you would likely have messages that check if it hit different branches. - */ - DEBUG, - - /** - * The info level is used to provide high level goal messages such as function start or successful completion. - * - * This shows when key user-facing functionality is executed and tells us that everything is working without getting - * into the details. - */ - INFO, - - /** - * The warning level is used to notify us that everything might not be working perfectly. - * - * Warnings are errors or inconsistencies that aren't fatal and generally do not completely break the system. - * However a warning message should require action and should point to a section of the system that needs attention. - */ - WARN, - - /** - * The error level is used to report unexpected behavior. - - * This level doesn't need to prefix a program-crashing issue but should be used to report major unexpected branches - * in logic or other constraint breaking problems such as failed assertions. - * All errors should require action from someone and should be addressed immediately. - */ - ERROR, - - /** - * Fatal is a program destroying error that needs to be addressed immediately. - * - * If a fatal message is sent it should point to something that should never ever happen and ideally provide as much - * information as possible as to why it crashed. - * Fatal messages require action immediately and should always be addressed. - */ - FATAL -}; - -/** - * This function is used to convert a LogLevel into a string - * - * @param level the LogLevel to convert - * - * @return the string representation of the LogLevel - */ -std::string to_string(const LogLevel& level); - -/** - * This function is used to convert a string into a LogLevel - * - * @param level the string to convert - * - * @return the LogLevel representation of the string - */ -LogLevel from_string(const std::string& level); - -/** - * This function is used to convert a LogLevel into a string for printing. - * - * @param os the output stream to write to - * @param level the LogLevel to convert - * @return the output stream - */ -std::ostream& operator<<(std::ostream& os, const LogLevel& level); - -} // namespace NUClear - -#endif // NUCLEAR_LOGLEVEL_HPP diff --git a/src/nuclear/src/PowerPlant.cpp b/src/nuclear/src/PowerPlant.cpp deleted file mode 100644 index 89f30ea6..00000000 --- a/src/nuclear/src/PowerPlant.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2013 NUClear Contributors - * - * This file is part of the NUClear codebase. - * See https://github.com/Fastcode/NUClear for further info. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "PowerPlant.hpp" - -#include -#include - -#include "Reactor.hpp" -#include "dsl/store/DataStore.hpp" -#include "dsl/word/Shutdown.hpp" -#include "dsl/word/Startup.hpp" -#include "dsl/word/emit/Inline.hpp" -#include "extension/ChronoController.hpp" -#include "extension/IOController.hpp" -#include "extension/NetworkController.hpp" -#include "message/CommandLineArguments.hpp" -#include "message/LogMessage.hpp" -#include "threading/ReactionTask.hpp" - -namespace NUClear { -namespace util { - struct GroupDescriptor; - struct ThreadPoolDescriptor; -} // namespace util - -// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) -PowerPlant* PowerPlant::powerplant = nullptr; - -// This is taking argc and argv as given by main so this should not take an array -// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) -PowerPlant::PowerPlant(Configuration config, int argc, const char* argv[]) - : scheduler(config.default_pool_concurrency) { - - // Stop people from making more then one powerplant - if (powerplant != nullptr) { - throw std::runtime_error("There is already a powerplant in existence (There should be a single PowerPlant)"); - } - - // Store our static variable - powerplant = this; - - // Emit our arguments if any. - message::CommandLineArguments args; - for (int i = 0; i < argc; ++i) { - args.emplace_back(argv[i]); - } - - // Emit the command line arguments so they are available for any With clauses. - emit(std::make_unique(args)); -} - -PowerPlant::~PowerPlant() { - // Make sure reactors are destroyed before anything else - while (!reactors.empty()) { - reactors.pop_back(); - } - - // Bye bye powerplant - powerplant = nullptr; -} - -void PowerPlant::start() { - - // Inline emit startup event and command line arguments - emit(std::make_unique()); - emit_shared(dsl::store::DataStore::get()); - - // Start all of the threads - scheduler.start(); -} - -void PowerPlant::add_idle_task(const std::shared_ptr& reaction, - const std::shared_ptr& pool_descriptor) { - scheduler.add_idle_task(reaction, pool_descriptor); -} - -void PowerPlant::remove_idle_task(const NUClear::id_t& id, - const std::shared_ptr& pool_descriptor) { - scheduler.remove_idle_task(id, pool_descriptor); -} - -void PowerPlant::submit(std::unique_ptr&& task) noexcept { - scheduler.submit(std::move(task)); -} - -void PowerPlant::log(const LogLevel& level, std::string message) { - // Get the current task - const auto* current_task = threading::ReactionTask::get_current_task(); - - // Inline emit the log message to default handlers to pause the current task until the log message is processed - emit(std::make_unique( - level, - current_task != nullptr ? current_task->parent->reactor.log_level : LogLevel::UNKNOWN, - std::move(message), - current_task != nullptr ? current_task->statistics : nullptr)); -} -void PowerPlant::log(const LogLevel& level, std::stringstream& message) { - log(level, message.str()); -} - -void PowerPlant::shutdown(bool force) { - - // Emit our shutdown event - emit(std::make_unique()); - - // Shutdown the scheduler - scheduler.stop(force); -} - -} // namespace NUClear diff --git a/src/nuclear/src/PowerPlant.hpp b/src/nuclear/src/PowerPlant.hpp deleted file mode 100644 index c7dc6969..00000000 --- a/src/nuclear/src/PowerPlant.hpp +++ /dev/null @@ -1,358 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2013 NUClear Contributors - * - * This file is part of the NUClear codebase. - * See https://github.com/Fastcode/NUClear for further info. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE - * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef NUCLEAR_POWER_PLANT_HPP -#define NUCLEAR_POWER_PLANT_HPP - -#include -#include -#include -#include -#include -#include - -// Utilities -#include "Configuration.hpp" -#include "Environment.hpp" -#include "LogLevel.hpp" -#include "id.hpp" -#include "threading/ReactionTask.hpp" -#include "threading/scheduler/Scheduler.hpp" -#include "util/FunctionFusion.hpp" -#include "util/demangle.hpp" - -namespace NUClear { - -// Forward declarations -class Reactor; -namespace util { - struct ThreadPoolDescriptor; -} // namespace util -namespace dsl { - namespace word { - namespace emit { - template - struct Local; - } // namespace emit - } // namespace word -} // namespace dsl - -/** - * The PowerPlant is the core of a NUClear system. It holds all Reactors in it and manages their communications. - * - * At the centre of every NUClear system is a PowerPlant. - * A PowerPlant contains all of the reactors that are used within the system and sets up their reactions. - * It is also responsible for storing information between reactions and ensuring threading is handled appropriately. - */ -class PowerPlant { - // Reactors and PowerPlants are very tightly linked - friend class Reactor; - - /** - * This is our Function Fusion wrapper class that allows it to call emit functions - * - * @tparam Handler The emit handler that we are wrapping for - */ - template - struct EmitCaller { - template - static auto call(Arguments&&... args) - // THIS IS VERY IMPORTANT, the return type must be dependent on the function call - // otherwise it won't check it's valid in SFINAE (the comma operator does it again!) - -> decltype(Handler::emit(std::forward(args)...), true) { - Handler::emit(std::forward(args)...); - return true; - } - }; - -public: - // There can only be one powerplant, so this is it - static PowerPlant* powerplant; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables) - - /** - * Constructs a PowerPlant with the given configuration and provides access to argv for all reactors. - * - * Arguments passed to this function will be emitted as a CommandLineArguments message. - * - * @param config The PowerPlant's configuration - * @param argc The number of command line arguments - * @param argv The command line argument strings - */ - // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) - PowerPlant(Configuration config = Configuration(), int argc = 0, const char* argv[] = nullptr); - ~PowerPlant(); - - // There can only be one! - PowerPlant(const PowerPlant& other) = delete; - PowerPlant(const PowerPlant&& other) = delete; - PowerPlant& operator=(const PowerPlant& other) = delete; - PowerPlant& operator=(const PowerPlant&& other) = delete; - - /** - * Starts up the PowerPlant's components in order and begins it running. - * - * Starts up the PowerPlant instance and starts all the pool threads. - * This method is blocking and will release when the PowerPlant shuts down. - * It should only be called from the main thread so that statics are not destructed. - */ - void start(); - - /** - * Shuts down the PowerPlant, tells all component threads to terminate and waits for them to finish. - * - * @param force If true, the PowerPlant will shutdown immediately without waiting for tasks to finish - */ - void shutdown(bool force = false); - - /** - * Installs a reactor of a particular type to the system. - * - * This function constructs a new Reactor of the template type. - * It passes the specified LogLevel in the environment of that reactor so that it can be used to filter logs. - * - * @tparam T The type of the reactor to build and install - * @tparam Args The types of the extra arguments to pass to the reactor constructor - * @tparam level The initial logging level for this reactor to use - * - * @param arg Extra arguments to pass to the reactor constructor - * - * @return A reference to the installed reactor - */ - template - T& install(Args&&... args) { - - // Make sure that the class that we received is a reactor - static_assert(std::is_base_of::value, "You must install Reactors"); - - // The reactor constructor should handle subscribing to events - reactors.push_back(std::make_unique(std::make_unique(*this, util::demangle(typeid(T).name())), - std::forward(args)...)); - - return static_cast(*reactors.back()); - } - - /** - * Adds an idle task to the task scheduler. - * - * This function adds an idle task to the task scheduler, which will be executed when the thread pool associated - * with the given `pool_id` has no other tasks to execute. - * The `task` parameter is a Reaction from which a task will be submitted when the pool is idle. - * - * @param reaction The reaction to be executed when idle - * @param pool_descriptor The descriptor for the thread pool to test for idle or nullptr for all pools - */ - void add_idle_task(const std::shared_ptr& reaction, - const std::shared_ptr& pool_descriptor = nullptr); - - /** - * Removes an idle task from the task scheduler. - * - * This function removes an idle task from the task scheduler. The `id` and `pool_id` parameters are used to - * identify the idle task to be removed. - * - * @param id The reaction id of the task to be removed - * @param pool_descriptor The descriptor for the thread pool to test for idle - */ - void remove_idle_task(const NUClear::id_t& id, - const std::shared_ptr& pool_descriptor = nullptr); - - /** - * Submits a new task to the ThreadPool to be queued and then executed. - * - * @param task The Reaction task to be executed in the thread pool - */ - void submit(std::unique_ptr&& task) noexcept; - - /** - * Log a message through NUClear's system. - * - * Logs a message through the system so the various log handlers can access it. - * The arguments being logged should be able to be added into a stringstream. - * - * @tparam level The level to log at (defaults to DEBUG) - * @tparam Arguments The types of the arguments we are logging - * - * @param args The arguments we are logging - */ - template - void log(Arguments&&... args) { - log(level, std::forward(args)...); - } - template - void log(const LogLevel& level, Arguments&&... args) { - std::stringstream ss; - log(level, ss, std::forward(args)...); - } - template - void log(const LogLevel& level, std::stringstream& ss, First&& first, Arguments&&... args) { - ss << std::forward(first) << " "; - log(level, ss, std::forward(args)...); - } - template - void log(const LogLevel& level, std::stringstream& ss, Last&& last) { - ss << std::forward(last); - log(level, ss); - } - void log(const LogLevel& level, std::stringstream& message); - void log(const LogLevel& level, std::string message); - - /** - * Emits data to the system and routes it to the other systems that use it. - * - * Emits at Local scope which creates tasks using the thread pool. - * - * @see NUClear::dsl::word::emit::Local for info about Local scope. - * - * @tparam T The type of the data that we are emitting - * - * @param data The data we are emitting - */ - template - void emit(std::unique_ptr&& data) { - emit(std::move(data)); - } - template - void emit(std::unique_ptr& data) { - emit(std::move(data)); - } - template