HomePhorge

Implement tuple values in the deluxe interface

Description

Implement tuple values in the deluxe interface

Ref T137
Define rosa::deluxe::DeluxeTuple as an std::tuple with some static type-related information for RoSA. Make DeluxeSensor and DeluxeAgent work with DeluxeTuple values. Extend DeluxeContext so that it supports creating sensors and agents with processing functions working with single built-in values as before and the new DeluxeTuple values as well.

There are some limitations in the public interface provided by DeluxeContext:

  • all types of processing functions used for creating a sensor or agent need to be either single types or DeluxeTuples, those cannot be mixed;
  • an agent that produces master-output values but not for all of its slaves needs to be defined using DeluxeTuples so that the type EmptyDeluxeTuple indicates no master-output for a slave position.

Details

Auditors
btutzer
Provenance
Dávid JuhászAuthored on May 2 2019, 1:45 AM
juhaszPushed on May 2 2019, 1:46 AM
Parents
R20:9ee73cb502ee: Move to_string() and operator<<() to namespace std
Branches
Unknown
Tags
Unknown
Tasks
Restricted Maniphest Task

Event Timeline

Dávid Juhász <juhasz.david.scholar@gmail.com> committed R20:fb3a26551f89: Implement tuple values in the deluxe interface (authored by Dávid Juhász <juhasz.david.scholar@gmail.com>).May 2 2019, 1:45 AM
Diffusion added a task: Restricted Maniphest Task.
This commit now requires audit.May 2 2019, 3:21 PM
btutzer subscribed.

This commit introduces some doxygen warnings during the build:

/home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp:581: warning: no matching class member found for 
  template < MT, T, typename >
  AgentHandle rosa::deluxe::DeluxeContext::createSensor(const std::string &Name, std::function< void(std::pair< MT, bool >)> &&MF, std::function< T(void)> &&F)
Possible candidates:
  'template < T, typename >
  AgentHandle rosa::deluxe::DeluxeContext::createSensor(const std::string &Name, std::function< T(void)> &&F=[](void) { return T();}) noexcept
  'template < MT, T >
  AgentHandle rosa::deluxe::DeluxeContext::createSensor(const std::string &Name, std::function< void(std::pair< MT, bool >)> &&MF, std::function< T(void)> &&F=[](void) { return T();}) noexcept

/home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp:761: warning: no uniquely matching class member found for 
  template < MT, T, Ts, As, typename >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< std::tuple< rosa::Optional< Ts >... >(std::pair< MT, bool >)> &&MF, std::function< std::tuple< rosa::Optional< T >, rosa::Optional< Ts >... >(std::pair< As, bool >...)> &&F)
Possible candidates:
  'template < T, As >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< Optional< T >(std::pair< As, bool >...)> &&F) noexcept' at line 274 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp
  'template < MT, T, As >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< void(std::pair< MT, bool >)> &&MF, std::function< Optional< T >(std::pair< As, bool >...)> &&F) noexcept' at line 307 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp
  'template < T, Ts, As >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< std::tuple< Optional< T >, Optional< Ts >... >(std::pair< As, bool >...)> &&F) noexcept' at line 344 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp
  'template < MT, T, Ts, As >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< std::tuple< Optional< Ts >... >(std::pair< MT, bool >)> &&MF, std::function< std::tuple< Optional< T >, Optional< Ts >... >(std::pair< As, bool >...)> &&F) noexcept' at line 384 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp
  'template < T, As, typename >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< Optional< T >(std::pair< As, bool >...)> &&F) noexcept' at line 618 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp
  'template < MT, T, As, typename >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< void(std::pair< MT, bool >)> &&MF, std::function< Optional< T >(std::pair< As, bool >...)> &&F) noexcept' at line 662 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp
  'template < T, Ts, As, typename >
  AgentHandle rosa::deluxe::DeluxeContext::createAgent(const std::string &Name, std::function< std::tuple< Optional< T >, Optional< Ts >... >(std::pair< As, bool >...)> &&F) noexcept' at line 712 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeContext.hpp

/home/benedikt/repos/SoC_ROSA_port/lib/deluxe/DeluxeTuple.cpp:23: warning: no uniquely matching class member found for 
  void rosa::deluxe::DeluxeTuple< Ts >::dump(std::ostream &OS)
Possible candidates:
  'template < S0 >
  void rosa::deluxe::DeluxeTuple< Ts >::dump(std::ostream &OS, Seq< S0... >) const noexcept' at line 103 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeTuple.hpp
  void rosa::deluxe::DeluxeTuple< Ts >::dump(std::ostream &OS) const noexcept' at line 109 of file /home/benedikt/repos/SoC_ROSA_port/include/rosa/deluxe/DeluxeTuple.hpp

Are you aware of that?
Is it possible to fix them?

This commit now has outstanding concerns.May 3 2019, 11:40 AM
/include/rosa/deluxe/DeluxeAgent.hpp
381

Is there a reason you did not document this function yet?

template <typename... Ts>
template <size_t... S0>
void DeluxeTuple<Ts...>::dump(std::ostream &OS, Seq<S0...>) const noexcept {
  STATIC_ASSERT(sizeof...(S0) == sizeof...(Ts), "inconsistent type arguments");
  OS << "{";
  (OS << ... << (" " + std::to_string(std::get<S0>(*this))));
  OS << " }";
}

Will this also work if the type of S0 is already std::string??

This commit introduces some doxygen warnings during the build:
[...]

I have no problem building documentation with doxygen 1.8.13. Maybe you use an older version?

The errors themselfes look like a doxygen bug: any documentation is written for a function declaration and so I do not understand how it would not match any declaration.

/include/rosa/deluxe/DeluxeAgent.hpp
381

I missed this one, fixed in R20:67d936624bf6.

void DeluxeTuple<Ts...>::dump(std::ostream &OS, Seq<S0...>) const noexcept {

Will this also work if the type of S0 is already std::string??

Thanks; std::to_string is indeed not defined for std::string itself.
Fixed in R20:a37df9760aa6.

This commit introduces some doxygen warnings during the build:
[...]

I have no problem building documentation with doxygen 1.8.13. Maybe you use an older version?

Unfortunately, I had to wipe my computer clean as after updating libstdc++ from debian experimental to be able to build ROSA I was unable to boot.
I am now using clang-6 from the backports repo, which builds rosa fine, but breaks my build with this particular branch, due to 'std::is_same_v' missing.
I searched around and found no fix for that other than installing libstdc++ from testing, and I am not doing that again... Is there a way to work around std::is_same_v? If not, please tell me what distribution you are using so I can set up a virtual machine, but I would like to avoid that very much.

I am wondering if I am the only one having issues with this. Are all others working on MSVS?

Also, I am not a fan of using bleeding-edge features that are incompatible with commonly used compilers / libstd versions. This should at least be mentioned in the build-requirements.

Unfortunately, I had to wipe my computer clean as after updating libstdc++ from debian experimental to be able to build ROSA I was unable to boot.
I am now using clang-6 from the backports repo, which builds rosa fine, but breaks my build with this particular branch, due to 'std::is_same_v' missing.
I searched around and found no fix for that other than installing libstdc++ from testing, and I am not doing that again... Is there a way to work around std::is_same_v? If not, please tell me what distribution you are using so I can set up a virtual machine, but I would like to avoid that very much.

Oh, please do not install anything from experimental or unstable or testing just to build anything...

I am using Ubuntu on Windows 10, release Ubuntu 18.04.2 LTS. But what is important is C++17, which has (partial) support in Clang for quite some time (https://clang.llvm.org/cxx_status.html#cxx17), most features has been done in Clang 4.

RoSA should compile with Clang 4, I think the necessary features are implemented by that version. We can adjust the build scripts to recognize Clang 4 and use the proper flag to activate C++17 mode. (Note: You can use Clang in C++17 mode with the -std=c++17 option (use -std=c++1z in Clang 4 and earlier).)

As for the C++ standard library, my system has version 7.4.0 of GNU Standard C++ Library v3. I can see that Debian stable currently has version 6.3.0, but I could not find any easily-searchable documentation to check what are the differences between those two versions.

Regarding std::is_same_v, it is quite simple to not use this C++17 feature of the standard library: all std::vvv_v<VVV> in C++17 is simply std::vvv<VVV>::value with an older feature std::vvv . Similarly, std::ttt_t<TTT> in C++17 is simply typename std::ttt<TTT>::type with an older feature std::ttt.

I am wondering if I am the only one having issues with this. Are all others working on MSVS?

I have no idea what others do, but no one complained to me so far.

Also, I am not a fan of using bleeding-edge features that are incompatible with commonly used compilers / libstd versions. This should at least be mentioned in the build-requirements.

This is a standard C++ 17 feature, which is mentioned in the build-requirements.

I am not against to lock ourselfes to some minimal LLVM and libstdc++ versions (so enforcing some partial implementation of C++17).

I would of course not enforce exact versions by build scripts, but it would be everyone's responsibility to make their code build with the designated minimal versions of build tools and libraries.

I think that should be discussed as a separate issue.

Replaced with std::is_same in R20:06e9cd4317c1.

Thanks!
I still can't build though.

/home/benedikt/repos/SoC_Rosa_port/include/rosa/deluxe/DeluxeSensor.hpp:518:12: error: lambda capture 'this' is not used [-Werror,-Wunused-lambda-capture]
  return [ this, MF ](void) noexcept {
           ^
/home/benedikt/repos/SoC_Rosa_port/include/rosa/deluxe/DeluxeSensor.hpp:580:11: note: in instantiation of function template specialization 'rosa::deluxe::DeluxeSensor::triggerHandlerFromProcessingFunction<>'
      requested here
      MFP(triggerHandlerFromProcessingFunction(std::move(MF),
          ^
/home/benedikt/repos/SoC_Rosa_port/include/rosa/deluxe/DeluxeSystem.hpp:217:20: note: in instantiation of function template specialization 'rosa::deluxe::DeluxeSensor::DeluxeSensor<rosa::deluxe::DeluxeTuple<>,
      rosa::deluxe::DeluxeTuple<int>, void>' requested here
        return new DeluxeSensor(atoms::SensorKind, Id, Name, S, std::move(MF),
                   ^
/home/benedikt/repos/SoC_Rosa_port/include/rosa/deluxe/DeluxeContext.hpp:597:27: note: in instantiation of function template specialization 'rosa::deluxe::DeluxeSystem::createSensor<rosa::deluxe::DeluxeTuple<>,
      rosa::deluxe::DeluxeTuple<int> >' requested here
  AgentHandle H = System->createSensor(Name, std::move(MF), std::move(F));
                          ^
/home/benedikt/repos/SoC_Rosa_port/include/rosa/deluxe/DeluxeContext.hpp:610:12: note: in instantiation of function template specialization
      'rosa::deluxe::DeluxeContext::createSensorImpl<rosa::deluxe::DeluxeTuple<>, rosa::deluxe::DeluxeTuple<int>, std::enable_if<true, void> >' requested here
    return createSensorImpl(
           ^
/home/benedikt/repos/SoC_Rosa_port/apps/sa-ews1/sa-ews1.cpp:110:29: note: in instantiation of function template specialization 'rosa::deluxe::DeluxeContext::createSensor<int, void>' requested here
  AgentHandle HRSensor = C->createSensor<int32_t>("HR Sensor");
                            ^
1 error generated.

I have no experience with using Lambdas in C++ so unfortunately I have no idea what you are doing here. Could you help me out?

I still can't build though.

I've seen this kind of problem with Clang 6 in another project... Warning suppressed in R20:04dbc622e75c.

I still can't build though.

I've seen this kind of problem with Clang 6 in another project... Warning suppressed in R20:04dbc622e75c.

Thanks!

All concerns with this commit have now been addressed.May 21 2019, 3:14 PM