VRGroupRWTH / ROSBridge2Unreal

Connects a ROSBridge Instance to the Unreal 4 Engine
BSD 3-Clause "New" or "Revised" License
10 stars 4 forks source link

Feature/refactor data helpers #15

Closed soehrl closed 3 years ago

soehrl commented 3 years ago

This PR refactors the DataHelpers. The main goal was to be able to extract and append arrays without needing to provide a lambda to do the (de-)serialization.

The general syntax will change from

DataHelpers::AppendDouble(OutMessage, "x", X);

to

DataHelpers::Append<double>(OutMessage, "x", X);

The template parameter should be always deductable from the parameter type and, thus, is completely optional. It can be used to explicitely force a specific version of the function as this was a requirement based on previous discussions.

Extracting arrays is now simplified as:

DataHelpers::Append<TArray<double>>(OutMessage, "covariance", Covariance);

instead of

 DataHelpers::ExtractTArray<double>(Message, "covariance", Covariance, [](const ROSData& Array, const char* Key, double& Result)
    {
        return DataHelpers::ExtractDouble(Array, Key, Result);
    });

Again, template parameters are optional.

Usage with an undefined type leads to the following error (MSVC):

1>...\Plugins\Rosbridge2Unreal\Source\Rosbridge2Unreal\Public\DataHelpers.h(208): error C2027: use of undefined type 'DataHelpers::Internal::DataConverter<T,void>'
1>          with
1>          [
1>              T=SomeCustomType
1>          ]

Discussion points

ToDo