Skip to content

Commit dd6bcc4

Browse files
committed
Enable GMS looping from python
1 parent 2da68cb commit dd6bcc4

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Dataflow/Network/ModuleStateInterface.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,33 @@ namespace Networks {
123123
}
124124
}
125125

126+
template <class T>
127+
T convertVariable(const Core::Algorithms::Variable&)
128+
{
129+
return {};
130+
}
131+
132+
template <>
133+
inline int convertVariable<int>(const Core::Algorithms::Variable& var)
134+
{
135+
return var.toInt();
136+
}
137+
138+
template <class T>
139+
T transient_value_cast_with_variable_check(const ModuleStateInterface::TransientValueOption& x)
140+
{
141+
if (!x)
142+
return{};
143+
144+
if (transient_value_check<T>(x))
145+
return any_cast_or_default_<T>(*x);
146+
147+
if (transient_value_check<Core::Algorithms::Variable>(x))
148+
return convertVariable<T>(any_cast_or_default_<Core::Algorithms::Variable>(*x));
149+
150+
return {};
151+
}
152+
126153
class SCISHARE StateChangeObserver
127154
{
128155
public:

src/Modules/Math/GetMatrixSlice.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ void GetMatrixSlice::execute()
8585
throw;
8686
}
8787

88-
89-
auto playMode = transient_value_cast<int>(state->getTransientValue(Parameters::PlayModeActive));
88+
auto playMode = transient_value_cast_with_variable_check<int>(state->getTransientValue(Parameters::PlayModeActive));
9089
if (playMode == GetMatrixSliceAlgo::PLAY)
9190
{
9291
auto sliceIncrement = state->getValue(Parameters::SliceIncrement).toInt();

0 commit comments

Comments
 (0)