Description
I would like to change this line to also consider BT::AnyTypeAllowed
. This would allow the user to correctly allow all types for a specific port.
When using BT::Any
instead, the BT::TypeInfo
of the port defines the functor for converting from string like here. This essentially breaks the scripting language because BT::convertFromString<BT::Any>()
is illegal but will be called internally when a script is evaluated for a variable associated with a BT::Any
port (This association is defined during tree initialization to validate types).
Therefore, I suggest to replace
if constexpr(std::is_same_v<BT::Any, T>)
{
if(config().manifest->ports.at(key).type() != typeid(BT::Any))
{
throw LogicError("setOutput<Any> is not allowed, unless the port "
"was declared using OutputPort<Any>");
}
}
with this
if constexpr(std::is_same_v<BT::Any, T>)
{
const std::type_index type = config().manifest->ports.at(key).type();
if(type != typeid(BT::Any) && type != typeid(BT::AnyTypeAllowed))
{
throw LogicError("setOutput<BT::Any> is not allowed, unless the port "
"was declared using OutputPort<BT::Any> or "
"OutputPort<BT::AnyTypeAllowed>");
}
}
from here.
It would be nice if what I'm trying to do here would be possible with BT::Any
alone but I guess this requires to dig deep in the type validation and scripting logic.