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 ClearValue(
int signalIndex );
82 void ClearAllValues();
84 fast_any::type_info GetType(
int signalIndex )
const;
87 std::vector<fast_any::any> _signals;
90inline SignalBus::SignalBus() =
default;
92inline SignalBus::SignalBus(
SignalBus&& rhs )
93 : _signals( std::move( rhs._signals ) )
97inline SignalBus::~SignalBus() =
default;
99inline void SignalBus::SetSignalCount(
int signalCount )
101 _signals.resize( signalCount );
104inline int SignalBus::GetSignalCount()
const
106 return (
int)_signals.size();
109inline fast_any::any* SignalBus::GetSignal(
int signalIndex )
119 return &_signals[signalIndex];
122inline bool SignalBus::HasValue(
int signalIndex )
const
124 return _signals[signalIndex].has_value();
127template <
typename ValueType>
128inline ValueType* SignalBus::GetValue(
int signalIndex )
const
134 return _signals[signalIndex].as<ValueType>();
137template <
typename ValueType>
138inline void SignalBus::SetValue(
int signalIndex,
const ValueType& newValue )
140 _signals[signalIndex].emplace<ValueType>( newValue );
143template <
typename ValueType>
144inline void SignalBus::MoveValue(
int signalIndex, ValueType&& newValue )
146 _signals[signalIndex].emplace<ValueType>( std::forward<ValueType>( newValue ) );
149inline void SignalBus::SetSignal(
int toSignalIndex,
const fast_any::any& fromSignal )
151 _signals[toSignalIndex].emplace( fromSignal );
154inline void SignalBus::MoveSignal(
int toSignalIndex, fast_any::any& fromSignal )
166 _signals[toSignalIndex].swap( fromSignal );
169inline void SignalBus::ClearValue(
int signalIndex )
171 _signals[signalIndex].reset();
174inline void SignalBus::ClearAllValues()
176 for (
auto& signal : _signals )
182inline fast_any::type_info SignalBus::GetType(
int signalIndex )
const
184 return _signals[signalIndex].type();