31#include "../fast_any/any.h"
62 void SetSignalCount(
int signalCount );
63 int GetSignalCount()
const;
65 fast_any::any* GetSignal(
int signalIndex );
67 bool HasValue(
int signalIndex )
const;
69 template <
typename ValueType>
70 ValueType* GetValue(
int signalIndex )
const;
72 template <
typename ValueType>
73 void SetValue(
int signalIndex,
const ValueType& newValue );
75 template <
typename ValueType>
76 void MoveValue(
int signalIndex, ValueType&& newValue );
78 void SetSignal(
int toSignalIndex,
const fast_any::any& fromSignal );
79 void MoveSignal(
int toSignalIndex, fast_any::any& fromSignal );
81 void ClearAllValues();
83 fast_any::type_info GetType(
int signalIndex )
const;
86 std::vector<fast_any::any> _signals;
89inline SignalBus::SignalBus() =
default;
91inline SignalBus::SignalBus(
SignalBus&& rhs )
92 : _signals( std::move( rhs._signals ) )
96inline SignalBus::~SignalBus() =
default;
98inline void SignalBus::SetSignalCount(
int signalCount )
100 _signals.resize( signalCount );
103inline int SignalBus::GetSignalCount()
const
105 return (
int)_signals.size();
108inline fast_any::any* SignalBus::GetSignal(
int signalIndex )
118 return &_signals[signalIndex];
121inline bool SignalBus::HasValue(
int signalIndex )
const
123 return _signals[signalIndex].has_value();
126template <
typename ValueType>
127inline ValueType* SignalBus::GetValue(
int signalIndex )
const
133 return _signals[signalIndex].as<ValueType>();
136template <
typename ValueType>
137inline void SignalBus::SetValue(
int signalIndex,
const ValueType& newValue )
139 _signals[signalIndex].emplace<ValueType>( newValue );
142template <
typename ValueType>
143inline void SignalBus::MoveValue(
int signalIndex, ValueType&& newValue )
145 _signals[signalIndex].emplace<ValueType>( std::forward<ValueType>( newValue ) );
148inline void SignalBus::SetSignal(
int toSignalIndex,
const fast_any::any& fromSignal )
150 _signals[toSignalIndex].emplace( fromSignal );
153inline void SignalBus::MoveSignal(
int toSignalIndex, fast_any::any& fromSignal )
165 _signals[toSignalIndex].swap( fromSignal );
168inline void SignalBus::ClearAllValues()
170 for (
auto& signal : _signals )
176inline fast_any::type_info SignalBus::GetType(
int signalIndex )
const
178 return _signals[signalIndex].type();