Skip to content

Commit

Permalink
Lots of minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Aug 13, 2024
1 parent ce2338c commit 601cb6f
Show file tree
Hide file tree
Showing 59 changed files with 205 additions and 159 deletions.
12 changes: 6 additions & 6 deletions docs/extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Bind

.. codeblock:: c++
template <typename DSL>
static inline void bind(const std::shared_ptr<threading::Reaction>& reaction, /*More arguments can be declared*/)
static void bind(const std::shared_ptr<threading::Reaction>& 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.
Expand All @@ -68,7 +68,7 @@ Get

.. codeblock:: c++
template <typename DSL>
static inline T get(threading::Reaction&)
static T get(threading::ReactionTask& task)

This is used to get the data for the callback. The returned value is passed to the callback.

Expand All @@ -84,7 +84,7 @@ Precondition

.. codeblock:: c++
template <typename DSL>
static inline bool precondition(threading::Reaction& reaction)
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.
Expand All @@ -103,7 +103,7 @@ Reschedule

.. codeblock:: c++
template <typename DSL>
static inline std::unique_ptr<threading::ReactionTask> reschedule(std::unique_ptr<threading::ReactionTask>&& task)
static std::unique_ptr<threading::ReactionTask> reschedule(std::unique_ptr<threading::ReactionTask>&& 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.
Expand All @@ -118,7 +118,7 @@ Transient

.. codeblock:: c++
template <>
struct is_transient<word::IO::Event> : std::true_type {};
struct is_transient<word::IO::Event> : public 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
Expand Down Expand Up @@ -167,7 +167,7 @@ Now we define the `reschedule` to interrupt any new tasks if we are currently ru
multithreaded so a mutex is needed when accessing the static members.
.. codeblock:: c++
template <typename DSL>
static inline std::unique_ptr<threading::ReactionTask> reschedule(
static std::unique_ptr<threading::ReactionTask> reschedule(
std::unique_ptr<threading::ReactionTask>&& task) {

// Lock our mutex
Expand Down
6 changes: 3 additions & 3 deletions docs/networking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ 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 inline std::vector<uint8_t> serialise(const T& in)
static std::vector<uint8_t> serialise(const T& in)

static inline T deserialise(const std::vector<uint8_t>& in)
static T deserialise(const std::vector<uint8_t>& in)

static inline uint64_t hash()
static uint64_t hash()
5 changes: 2 additions & 3 deletions src/Reactor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
#ifndef NUCLEAR_REACTOR_HPP
#define NUCLEAR_REACTOR_HPP

#include <atomic>
#include <chrono>
#include <functional>
#include <regex>
#include <sstream>
#include <string>
#include <typeindex>
#include <vector>
Expand All @@ -40,6 +38,7 @@
#include "threading/ReactionIdentifiers.hpp"
#include "util/CallbackGenerator.hpp"
#include "util/Sequence.hpp"
#include "util/demangle.hpp"
#include "util/tuplify.hpp"

namespace NUClear {
Expand Down Expand Up @@ -370,7 +369,7 @@ class Reactor {
* This function is used to create a Reaction in the system.
* By providing the correct template parameters, this function can modify how and when this reaction runs.
*
* @tparam DSL The NUClear domain specific language information
* @tparam DSL The NUClear domain specific language information
* @tparam Arguments The types of the arguments passed into the function
*
* @param args The arguments that will be passed to each of the binding DSL words in order
Expand Down
6 changes: 3 additions & 3 deletions src/dsl/fusion/BindFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_BINDFUSION_HPP
#define NUCLEAR_DSL_FUSION_BINDFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_BIND_FUSION_HPP
#define NUCLEAR_DSL_FUSION_BIND_FUSION_HPP

#include "../../threading/Reaction.hpp"
#include "../../util/FunctionFusion.hpp"
Expand Down Expand Up @@ -152,4 +152,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_BINDFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_BIND_FUSION_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/GetFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_GETFUSION_HPP
#define NUCLEAR_DSL_FUSION_GETFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_GET_FUSION_HPP
#define NUCLEAR_DSL_FUSION_GET_FUSION_HPP

#include "../../threading/Reaction.hpp"
#include "../../util/tuplify.hpp"
Expand Down Expand Up @@ -110,4 +110,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_GETFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_GET_FUSION_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/GroupFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_GROUPFUSION_HPP
#define NUCLEAR_DSL_FUSION_GROUPFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_GROUP_FUSION_HPP
#define NUCLEAR_DSL_FUSION_GROUP_FUSION_HPP

#include <algorithm>
#include <stdexcept>
Expand Down Expand Up @@ -101,4 +101,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_GROUPFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_GROUP_FUSION_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/NoOp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_NOOP_HPP
#define NUCLEAR_DSL_FUSION_NOOP_HPP
#ifndef NUCLEAR_DSL_FUSION_NO_OP_HPP
#define NUCLEAR_DSL_FUSION_NO_OP_HPP

#include <typeindex>

Expand Down Expand Up @@ -103,4 +103,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_NOOP_HPP
#endif // NUCLEAR_DSL_FUSION_NO_OP_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/PoolFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_POOLFUSION_HPP
#define NUCLEAR_DSL_FUSION_POOLFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_POOL_FUSION_HPP
#define NUCLEAR_DSL_FUSION_POOL_FUSION_HPP

#include <algorithm>
#include <stdexcept>
Expand Down Expand Up @@ -101,4 +101,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_POOLFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_POOL_FUSION_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/PostconditionFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_POSTCONDITIONFUSION_HPP
#define NUCLEAR_DSL_FUSION_POSTCONDITIONFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_POSTCONDITION_FUSION_HPP
#define NUCLEAR_DSL_FUSION_POSTCONDITION_FUSION_HPP

#include "../../threading/ReactionTask.hpp"
#include "../operation/DSLProxy.hpp"
Expand Down Expand Up @@ -105,4 +105,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_POSTCONDITIONFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_POSTCONDITION_FUSION_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/PreconditionFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_PRECONDITIONFUSION_HPP
#define NUCLEAR_DSL_FUSION_PRECONDITIONFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_PRECONDITION_FUSION_HPP
#define NUCLEAR_DSL_FUSION_PRECONDITION_FUSION_HPP

#include "../../threading/Reaction.hpp"
#include "../operation/DSLProxy.hpp"
Expand Down Expand Up @@ -102,4 +102,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_PRECONDITIONFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_PRECONDITION_FUSION_HPP
6 changes: 3 additions & 3 deletions src/dsl/fusion/PriorityFusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_FUSION_PRIORITYFUSION_HPP
#define NUCLEAR_DSL_FUSION_PRIORITYFUSION_HPP
#ifndef NUCLEAR_DSL_FUSION_PRIORITY_FUSION_HPP
#define NUCLEAR_DSL_FUSION_PRIORITY_FUSION_HPP

#include "../../threading/Reaction.hpp"
#include "../operation/DSLProxy.hpp"
Expand Down Expand Up @@ -101,4 +101,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_FUSION_PRIORITYFUSION_HPP
#endif // NUCLEAR_DSL_FUSION_PRIORITY_FUSION_HPP
7 changes: 4 additions & 3 deletions src/dsl/operation/CacheGet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_OPERATION_CACHEGET_HPP
#define NUCLEAR_DSL_OPERATION_CACHEGET_HPP
#ifndef NUCLEAR_DSL_OPERATION_CACHE_GET_HPP
#define NUCLEAR_DSL_OPERATION_CACHE_GET_HPP

#include "../store/DataStore.hpp"
#include "../store/ThreadStore.hpp"

namespace NUClear {
namespace dsl {
Expand Down Expand Up @@ -54,4 +55,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_OPERATION_CACHEGET_HPP
#endif // NUCLEAR_DSL_OPERATION_CACHE_GET_HPP
6 changes: 3 additions & 3 deletions src/dsl/operation/ChronoTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_OPERATION_CHRONOTASK_HPP
#define NUCLEAR_DSL_OPERATION_CHRONOTASK_HPP
#ifndef NUCLEAR_DSL_OPERATION_CHRONO_TASK_HPP
#define NUCLEAR_DSL_OPERATION_CHRONO_TASK_HPP

#include "../../clock.hpp"
#include "../../id.hpp"
Expand Down Expand Up @@ -107,4 +107,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_OPERATION_CHRONOTASK_HPP
#endif // NUCLEAR_DSL_OPERATION_CHRONO_TASK_HPP
6 changes: 3 additions & 3 deletions src/dsl/operation/DSLProxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_OPERATION_DSLPROXY_HPP
#define NUCLEAR_DSL_OPERATION_DSLPROXY_HPP
#ifndef NUCLEAR_DSL_OPERATION_DSL_PROXY_HPP
#define NUCLEAR_DSL_OPERATION_DSL_PROXY_HPP

namespace NUClear {
namespace dsl {
Expand All @@ -43,4 +43,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_OPERATION_DSLPROXY_HPP
#endif // NUCLEAR_DSL_OPERATION_DSL_PROXY_HPP
6 changes: 3 additions & 3 deletions src/dsl/operation/TypeBind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_OPERATION_TYPEBIND_HPP
#define NUCLEAR_DSL_OPERATION_TYPEBIND_HPP
#ifndef NUCLEAR_DSL_OPERATION_TYPE_BIND_HPP
#define NUCLEAR_DSL_OPERATION_TYPE_BIND_HPP

#include "../store/TypeCallbackStore.hpp"

Expand Down Expand Up @@ -98,4 +98,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_OPERATION_TYPEBIND_HPP
#endif // NUCLEAR_DSL_OPERATION_TYPE_BIND_HPP
6 changes: 3 additions & 3 deletions src/dsl/trait/is_transient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef NUCLEAR_DSL_TRAIT_ISTRANSIENT_HPP
#define NUCLEAR_DSL_TRAIT_ISTRANSIENT_HPP
#ifndef NUCLEAR_DSL_TRAIT_IS_TRANSIENT_HPP
#define NUCLEAR_DSL_TRAIT_IS_TRANSIENT_HPP

namespace NUClear {
namespace dsl {
Expand All @@ -47,4 +47,4 @@ namespace dsl {
} // namespace dsl
} // namespace NUClear

#endif // NUCLEAR_DSL_TRAIT_ISTRANSIENT_HPP
#endif // NUCLEAR_DSL_TRAIT_IS_TRANSIENT_HPP
3 changes: 1 addition & 2 deletions src/dsl/word/Every.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace dsl {
struct Per;

template <typename Unit, std::intmax_t num, std::intmax_t den>
struct Per<std::chrono::duration<Unit, std::ratio<num, den>>> : clock::duration {
struct Per<std::chrono::duration<Unit, std::ratio<num, den>>> : public clock::duration {
explicit Per(int ticks)
: clock::duration(std::lround((double(num) / double(ticks * den))
* (double(clock::period::den) / double(clock::period::num)))) {}
Expand All @@ -50,7 +50,6 @@ namespace dsl {
/**
* This is used to request any periodic reactions in the system.
*
*
* @code on<Every<ticks, period>>() @endcode
* This request will enact the execution of a task at a periodic rate.
* To set the timing, simply specify the desired period with the request.
Expand Down
12 changes: 5 additions & 7 deletions src/dsl/word/Sync.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ namespace dsl {
* @par Implements
* Group
*
* @tparam GroupType The type/group to synchronize on.
* This needs to be a declared type within the system.
* It is common to simply use the reactors name for a reactor with one group.
* Should more than one group be required, the developer can declare structs within the
* system, to act as a group reference.
* Note that the developer is not limited to the use of a struct; any declared type
* will work.
* @tparam GroupType The type/group to synchronize on.
* This needs to be a declared type within the system.
* It is common to simply use the reactors name for a reactor with one group.
* Should more than one group be required, the developer can declare structs within the
* system, to act as a group reference.
*/
template <typename SyncGroup>
struct Sync : Group<SyncGroup, 1> {};
Expand Down
1 change: 1 addition & 0 deletions src/dsl/word/Watchdog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "../../threading/Reaction.hpp"
#include "../../util/demangle.hpp"
#include "../operation/ChronoTask.hpp"
#include "../operation/Unbind.hpp"
#include "../store/DataStore.hpp"
#include "emit/Direct.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/dsl/word/With.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace dsl {
/**
* This is used to define any extra data which should be provided to a subscribing a reaction.
*
*
* @code on<With<T2>>() @endcode
* Note that during runtime, the emission of data using this word will not trigger a reaction within the
* system.
Expand Down
2 changes: 0 additions & 2 deletions src/dsl/word/emit/Delay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ namespace dsl {
/**
* This will emit data, after the provided delay.
*
*
* @code emit<Scope::DELAY>(data, delay(ticks), dataType); @endcode
* Emissions under this scope will wait for the provided time delay, and then emit the object utilising a
* local emit (that is, normal thread pool distribution).
*
*
* @tparam DataType The datatype of the object to emit
*
* @param data The data to emit
Expand Down
Loading

0 comments on commit 601cb6f

Please sign in to comment.