From 4a834181bd2e1621e7c2bdb7509fda6bc10bca28 Mon Sep 17 00:00:00 2001 From: Trent Houliston Date: Sat, 26 Oct 2024 13:58:11 +1100 Subject: [PATCH 1/2] Store trace events that mark the start of the trace (#157) The trigger that starts the trace itself wasn't logged properly. This made it difficult to get a "zero time" for the trace. Logging the BeginTrace reaction itself means you get to see when the begin trace was requested --- src/extension/TraceController.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extension/TraceController.cpp b/src/extension/TraceController.cpp index 7e135d86..b2a40608 100644 --- a/src/extension/TraceController.cpp +++ b/src/extension/TraceController.cpp @@ -275,6 +275,11 @@ namespace extension { } write_trace_packet(data); + // Write the trace events that happened before the trace started + auto current_stats = threading::ReactionTask::get_current_task()->statistics; + encode_event(ReactionEvent(ReactionEvent::CREATED, current_stats)); + encode_event(ReactionEvent(ReactionEvent::STARTED, current_stats)); + // Bind new handles event_handle = on, Pool>().then([this](const ReactionEvent& e) { // encode_event(e); From 12fab9a01d8a459ba47bb30f476bb479074961d8 Mon Sep 17 00:00:00 2001 From: Trent Houliston Date: Sat, 26 Oct 2024 14:13:33 +1100 Subject: [PATCH 2/2] Add a macro which generates a SFINAE template for checking NUClear words (#155) All of the NUClear DSL words follow a similar pattern for working out if a DSL word exists. This makes a macro which can generate this pattern rather than having almost identical lines all through individual files. --- src/dsl/fusion/BindFusion.hpp | 5 +- src/dsl/fusion/GetFusion.hpp | 5 +- src/dsl/fusion/GroupFusion.hpp | 5 +- src/dsl/fusion/InlineFusion.hpp | 5 +- src/dsl/fusion/PoolFusion.hpp | 5 +- src/dsl/fusion/PostconditionFusion.hpp | 5 +- src/dsl/fusion/PreconditionFusion.hpp | 5 +- src/dsl/fusion/PriorityFusion.hpp | 5 +- src/dsl/fusion/has_bind.hpp | 61 ----------------------- src/dsl/fusion/has_get.hpp | 58 --------------------- src/dsl/fusion/has_group.hpp | 58 --------------------- src/dsl/fusion/has_nuclear_dsl_method.hpp | 60 ++++++++++++++++++++++ src/dsl/fusion/has_pool.hpp | 58 --------------------- src/dsl/fusion/has_postcondition.hpp | 58 --------------------- src/dsl/fusion/has_precondition.hpp | 58 --------------------- src/dsl/fusion/has_priority.hpp | 58 --------------------- src/dsl/fusion/has_run_inline.hpp | 58 --------------------- 17 files changed, 92 insertions(+), 475 deletions(-) delete mode 100644 src/dsl/fusion/has_bind.hpp delete mode 100644 src/dsl/fusion/has_get.hpp delete mode 100644 src/dsl/fusion/has_group.hpp create mode 100644 src/dsl/fusion/has_nuclear_dsl_method.hpp delete mode 100644 src/dsl/fusion/has_pool.hpp delete mode 100644 src/dsl/fusion/has_postcondition.hpp delete mode 100644 src/dsl/fusion/has_precondition.hpp delete mode 100644 src/dsl/fusion/has_priority.hpp delete mode 100644 src/dsl/fusion/has_run_inline.hpp diff --git a/src/dsl/fusion/BindFusion.hpp b/src/dsl/fusion/BindFusion.hpp index f93a68c8..35969fb4 100644 --- a/src/dsl/fusion/BindFusion.hpp +++ b/src/dsl/fusion/BindFusion.hpp @@ -27,12 +27,15 @@ #include "../../util/FunctionFusion.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_bind.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a run_inline method + HAS_NUCLEAR_DSL_METHOD(bind); + /** * This is our Function Fusion wrapper class that allows it to call bind functions. * diff --git a/src/dsl/fusion/GetFusion.hpp b/src/dsl/fusion/GetFusion.hpp index 9bbffe7f..95b6a659 100644 --- a/src/dsl/fusion/GetFusion.hpp +++ b/src/dsl/fusion/GetFusion.hpp @@ -27,12 +27,15 @@ #include "../../util/tuplify.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_get.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a get method + HAS_NUCLEAR_DSL_METHOD(get); + /** * This is our Function Fusion wrapper class that allows it to call get functions. * diff --git a/src/dsl/fusion/GroupFusion.hpp b/src/dsl/fusion/GroupFusion.hpp index e6668b54..21525e6c 100644 --- a/src/dsl/fusion/GroupFusion.hpp +++ b/src/dsl/fusion/GroupFusion.hpp @@ -30,12 +30,15 @@ #include "../../threading/Reaction.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_group.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a group method + HAS_NUCLEAR_DSL_METHOD(group); + // Default case where there are no group words template struct GroupFuser {}; diff --git a/src/dsl/fusion/InlineFusion.hpp b/src/dsl/fusion/InlineFusion.hpp index c73884e1..8ebf052d 100644 --- a/src/dsl/fusion/InlineFusion.hpp +++ b/src/dsl/fusion/InlineFusion.hpp @@ -27,12 +27,15 @@ #include "../../util/Inline.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_run_inline.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a run_inline method + HAS_NUCLEAR_DSL_METHOD(run_inline); + // Default case where there are no Inline words template struct InlineFuser {}; diff --git a/src/dsl/fusion/PoolFusion.hpp b/src/dsl/fusion/PoolFusion.hpp index 578b6e8d..aea11c46 100644 --- a/src/dsl/fusion/PoolFusion.hpp +++ b/src/dsl/fusion/PoolFusion.hpp @@ -29,12 +29,15 @@ #include "../../threading/ReactionTask.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_pool.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a pool method + HAS_NUCLEAR_DSL_METHOD(pool); + // Default case where there are no pool words template struct PoolFuser {}; diff --git a/src/dsl/fusion/PostconditionFusion.hpp b/src/dsl/fusion/PostconditionFusion.hpp index 3eeb9aac..ad2d1bad 100644 --- a/src/dsl/fusion/PostconditionFusion.hpp +++ b/src/dsl/fusion/PostconditionFusion.hpp @@ -26,12 +26,15 @@ #include "../../threading/ReactionTask.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_postcondition.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a postcondition method + HAS_NUCLEAR_DSL_METHOD(postcondition); + // Default case where there are no postcondition words template struct PostconditionFuser {}; diff --git a/src/dsl/fusion/PreconditionFusion.hpp b/src/dsl/fusion/PreconditionFusion.hpp index 09d0b696..103d25f3 100644 --- a/src/dsl/fusion/PreconditionFusion.hpp +++ b/src/dsl/fusion/PreconditionFusion.hpp @@ -26,12 +26,15 @@ #include "../../threading/ReactionTask.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_precondition.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a precondition method + HAS_NUCLEAR_DSL_METHOD(precondition); + // Default case where there are no precondition words template struct PreconditionFuser {}; diff --git a/src/dsl/fusion/PriorityFusion.hpp b/src/dsl/fusion/PriorityFusion.hpp index 5000f9ae..afd8b517 100644 --- a/src/dsl/fusion/PriorityFusion.hpp +++ b/src/dsl/fusion/PriorityFusion.hpp @@ -26,12 +26,15 @@ #include "../../threading/ReactionTask.hpp" #include "../operation/DSLProxy.hpp" #include "FindWords.hpp" -#include "has_priority.hpp" +#include "has_nuclear_dsl_method.hpp" namespace NUClear { namespace dsl { namespace fusion { + /// Make a SFINAE type to check if a word has a priority method + HAS_NUCLEAR_DSL_METHOD(priority); + // Default case where there are no priority words template struct PriorityFuser {}; diff --git a/src/dsl/fusion/has_bind.hpp b/src/dsl/fusion/has_bind.hpp deleted file mode 100644 index 7991f5da..00000000 --- a/src/dsl/fusion/has_bind.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2014 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_DSL_FUSION_HAS_BIND_HPP -#define NUCLEAR_DSL_FUSION_HAS_BIND_HPP - -#include "../../threading/ReactionHandle.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a bind function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_bind { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static yes test_func(R (*)(const std::shared_ptr&, A...)); - static no test_func(...); - - template - static auto test(int) -> decltype(test_func(U::template bind)); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HASBIND_HPP diff --git a/src/dsl/fusion/has_get.hpp b/src/dsl/fusion/has_get.hpp deleted file mode 100644 index e07f2a76..00000000 --- a/src/dsl/fusion/has_get.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2014 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_DSL_FUSION_HAS_GET_HPP -#define NUCLEAR_DSL_FUSION_HAS_GET_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a get function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_get { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) -> decltype(U::template get(std::declval()), - yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_GET_HPP diff --git a/src/dsl/fusion/has_group.hpp b/src/dsl/fusion/has_group.hpp deleted file mode 100644 index e5bf5071..00000000 --- a/src/dsl/fusion/has_group.hpp +++ /dev/null @@ -1,58 +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_DSL_FUSION_HAS_GROUP_HPP -#define NUCLEAR_DSL_FUSION_HAS_GROUP_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a group function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_group { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) -> decltype(U::template group(std::declval()), - yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_GROUP_HPP diff --git a/src/dsl/fusion/has_nuclear_dsl_method.hpp b/src/dsl/fusion/has_nuclear_dsl_method.hpp new file mode 100644 index 00000000..9b1ddad9 --- /dev/null +++ b/src/dsl/fusion/has_nuclear_dsl_method.hpp @@ -0,0 +1,60 @@ +/* + * MIT License + * + * Copyright (c) 2024 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_DSL_FUSION_FUSION_HAS_NUCLEAR_DSL_METHOD_HPP +#define NUCLEAR_DSL_FUSION_FUSION_HAS_NUCLEAR_DSL_METHOD_HPP + +#include "NoOp.hpp" + +/** + * This macro to create an SFINAE type to check for the existence of a NUClear DSL method in a given class. + * + * The macro generates a template struct that can be used to determine if a class contains a specific method. + * + * The macro works by attempting to instantiate a function pointer to the method in question. + * If the method exists, the instantiation will succeed and the struct will inherit from + * `std::true_type`. Otherwise, it will inherit from `std::false_type`. + * + * @note This macro assumes that the method being checked for is a template method that can be instantiated with + * `ParsedNoOp`. + */ +// If you can find a way to do SFINAE in a constexpr for a variable function name let me know +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) +#define HAS_NUCLEAR_DSL_METHOD(Method) \ + template \ + struct has_##Method { \ + private: \ + template \ + static auto test_func(R (*)(A...)) -> std::true_type; \ + static auto test_func(...) -> std::false_type; \ + \ + /* Parenthesis would literally break this code*/ \ + template /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \ + static auto test(int) -> decltype(test_func(&U::template Method)); \ + template \ + static auto test(...) -> std::false_type; \ + \ + public: \ + static constexpr bool value = decltype(test(0))::value; \ + } + +#endif // NUCLEAR_DSL_FUSION_FUSION_HAS_NUCLEAR_DSL_METHOD_HPP diff --git a/src/dsl/fusion/has_pool.hpp b/src/dsl/fusion/has_pool.hpp deleted file mode 100644 index 2f5c81e0..00000000 --- a/src/dsl/fusion/has_pool.hpp +++ /dev/null @@ -1,58 +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_DSL_FUSION_HAS_POOL_HPP -#define NUCLEAR_DSL_FUSION_HAS_POOL_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a pool function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_pool { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) -> decltype(U::template pool(std::declval()), - yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_POOL_HPP diff --git a/src/dsl/fusion/has_postcondition.hpp b/src/dsl/fusion/has_postcondition.hpp deleted file mode 100644 index d782ab43..00000000 --- a/src/dsl/fusion/has_postcondition.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2014 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_DSL_FUSION_HAS_POSTCONDITION_HPP -#define NUCLEAR_DSL_FUSION_HAS_POSTCONDITION_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a postcondition function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_postcondition { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) - -> decltype(U::template postcondition(std::declval()), yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_POSTCONDITION_HPP diff --git a/src/dsl/fusion/has_precondition.hpp b/src/dsl/fusion/has_precondition.hpp deleted file mode 100644 index 5fc22554..00000000 --- a/src/dsl/fusion/has_precondition.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2014 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_DSL_FUSION_HAS_PRECONDITION_HPP -#define NUCLEAR_DSL_FUSION_HAS_PRECONDITION_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a precondition function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_precondition { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) - -> decltype(U::template precondition(std::declval()), yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_PRECONDITION_HPP diff --git a/src/dsl/fusion/has_priority.hpp b/src/dsl/fusion/has_priority.hpp deleted file mode 100644 index 6d97e01b..00000000 --- a/src/dsl/fusion/has_priority.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2014 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_DSL_FUSION_HAS_PRIORITY_HPP -#define NUCLEAR_DSL_FUSION_HAS_PRIORITY_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a priority function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_priority { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) - -> decltype(U::template priority(std::declval()), yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_PRIORITY_HPP diff --git a/src/dsl/fusion/has_run_inline.hpp b/src/dsl/fusion/has_run_inline.hpp deleted file mode 100644 index 3b24b583..00000000 --- a/src/dsl/fusion/has_run_inline.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2014 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_DSL_FUSION_HAS_RUN_INLINE_HPP -#define NUCLEAR_DSL_FUSION_HAS_RUN_INLINE_HPP - -#include "../../threading/ReactionTask.hpp" -#include "NoOp.hpp" - -namespace NUClear { -namespace dsl { - namespace fusion { - - /** - * SFINAE struct to test if the passed class has a run_inline function that conforms to the NUClear DSL. - * - * @tparam T the class to check - */ - template - struct has_run_inline { - private: - using yes = std::true_type; - using no = std::false_type; - - template - static auto test(int) - -> decltype(U::template run_inline(std::declval()), yes()); - template - static no test(...); - - public: - static constexpr bool value = std::is_same(0)), yes>::value; - }; - - } // namespace fusion -} // namespace dsl -} // namespace NUClear - -#endif // NUCLEAR_DSL_FUSION_HAS_RUN_INLINE_HPP