-
Notifications
You must be signed in to change notification settings - Fork 1
WIP: Improvement/spir 1114/parameter structure #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
… declared as a static type
… to have final logic linked and tested
…tor & RequestHandler
| #define SENSORGATEWAY_CONSTANTFUNCTIONSDEFINITION_H | ||
|
|
||
| #include "ConstantValuesDefinition.h" | ||
| #include "StaticTupleFunctions.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
le nom est pas super parlant.
| auto currentPad = firstPad; | ||
| RingBufferPad<T>* nextPad; | ||
| for (auto i = 1; i < RING_BUFFER_SIZE; ++i) { | ||
| for (size_t i = 1; i < RING_BUFFER_SIZE; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi tu laisses des auto partout et tu modifies celui la?
| typedef Byte AWL; | ||
| typedef Byte GUARDIAN; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
espace inutile
| } | ||
|
|
||
| namespace DataFlow { | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
espace inutile
| using Text = std::string; | ||
| } | ||
| namespace Units { | ||
| // TODO: Use UCUM to correctly encode units |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Laisser un TODO pour un code open source?
| struct ExtractedType { | ||
| using type = T; | ||
| }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Espace en trop
| public: | ||
|
|
||
| explicit Parameter() | ||
| // : value(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi value() en commentaire
|
|
||
| using ServerCommunicator = SensorAccessLinkElement::ServerCommunicator<SERVER_STRUCTURES>; | ||
|
|
||
| using ThisClass = ResponseWriter<SENSOR_STRUCTURES, SERVER_STRUCTURES>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ThisClass, Cela represente quoi ?
|
|
||
| namespace Details { | ||
|
|
||
| template<typename N> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je suis plus trop a jours avec les templates mais typename N ( est ce que pour les template on s oblige a mettre des majuscules pour les typename ou est ce que c<est parce que tu as juste voulu mettre N? ) Par la suite tu mets quelques lignes plus loins typename ValueType
| // TODO : Validate request is allowed --> throw if not | ||
| // TODO : Assemble Request | ||
| // TODO : Pass to RequestHandler | ||
| // for (auto messageIndex = 0; messageIndex < messages.size(); ++messageIndex) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ne pas laisser de TODO dans le master en open source je pense que cela pourrait etre une bonne chose?
| auto message = messages[j]; | ||
| std::fprintf(file, | ||
| "=================================================================================== \n"); | ||
| std::fprintf(file, "SENSOR_ID : %" PRIu64 "\n", message.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je fais la remarque seulement a cet endroit mais pourquoi tu met pas using namespace std en haut ah lieu de devoir le reecrire a chaque fois?
| [&](auto... Is) { return f(std::get<Is>(t)...); } | ||
| ); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
espace inutile
| } | ||
| } | ||
|
|
||
| // template<typename Communicator, typename Strategy> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
En commentaire?
| }; | ||
| } | ||
|
|
||
| //TEST_F(RequestHandlerTest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention test commentés
|
|
||
| namespace ResponseWriterTestMock { | ||
|
|
||
| // using RealisticDataStructures = Sensor::Test::RealisticImplementation::Structures; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JE suppose que c est en WIP d'ou les commentaires ?
| bool hasToReturnSpecificGetParameterValueContents; | ||
| GetParameterValueContentList getParameterValueContentsToReturn; | ||
|
|
||
| // TODO: Create a template class to inherit from when implementing this : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attention comment
Sebdevar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'ai fait mon possible dans la review, mais l'implementation du gateway est beaucoup trop deep dans la technicalite du C++ pour ma comprehension.
| } | ||
| namespace Units { | ||
| // TODO: Use UCUM to correctly encode units | ||
| using not_applicable = StringLiteral<decltype("n/a"_ToString)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ce serais bon d'avoir aussi none = "". Ca eviterait d'avoir a gerer inutilement un n/a et de juste passer directement la valeur.
| typename GatewayParameterDefinition, | ||
| Byte SENSOR_INTERNAL_COMMAND, | ||
| Byte SENSOR_INTERNAL_ADDRESS, | ||
| uint8_t SENSOR_INTERNAL_TOTAL_LENGTH_IN_BITS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sensor Internal total length in bits? Ca represente quoi?
| return nameTuple; | ||
| } | ||
|
|
||
| struct NameEquals { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi une struct pour une egalite de nom... dont la seule utlite c'est de verifier l'egalite de deux string.... tu pourrait pas juste... valider l'egalite des strings la ou necessaire, ou au pire faire juste une fonction, pas besoin d'une struct pour ca.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pareil pour les autres cas semblables comme type name equals
| struct StringLiteral; | ||
|
|
||
| template<char... elements> | ||
| struct StringLiteral<StringType<elements...>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
un template de template de templates o__O? C'est vraiment nécessaire ca?
|
|
||
| static inline DataFlow::Intensity const convertIntensityToSNR(DataFlow::Intensity const& intensity) noexcept { | ||
| DataFlow::Intensity const snr = ((intensity / 1024) / 2.0) - 21; // w+f | ||
| DataFlow::Intensity const snr = (intensity / 2.0) - 21; // w+f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// w+f ???
| responseWriter(responseWriter), | ||
| dataTranslator(dataTranslator) {} | ||
|
|
||
| ~RequestHandler() noexcept {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ~RequestHandler() noexcept {}; | |
| ~RequestHandler() noexcept override = default; |
| Category category = COMMUNICATION_ERROR; | ||
| Severity severity; | ||
| std::string errorMessage; | ||
| if (errorCode == BAD_REQUEST) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c'est le troisieme if else que je vois pour le error handling... pourquoi tu utilise pas un switch case? c'est beaucoup plus clair a la lecture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Va voir la section 6, c'est la base de trucs a faire / eviter dans le gateway. Certains ne sont pas respectes pour de bonnes raisons, mais on essaie de les suivres pour la plupart
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es-tu sure de l'avoir bien lu, la switch est valide et compliant dans ce que tu m'as link.
…nicator, complete ServerCommunicator to RequestHandler code + tests
| std::string const SEPARATOR = " - "; | ||
| std::string const EMPTY_MESSAGE = ""; | ||
|
|
||
| std::string const PARAMETER_NOT_AVAILABLE = "Parameter is not available"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clang-Tidy: Initialization of 'PARAMETER_NOT_AVAILABLE' with static storage duration may throw an exception that cannot be caught
Warning Message for all const created in this file.
| dataTranslator(dataTranslator), | ||
| responseControlMessageScheduler(this) {} | ||
|
|
||
| ~SensorParameterController() noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ~SensorParameterController() noexcept { | |
| ~SensorParameterController() noexcept override { |
|
|
||
| public: | ||
|
|
||
| explicit SensorParameterController(RequestHandler* requestHandler, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never used.
| DataTranslator* dataTranslator; | ||
|
|
||
| SensorControlMessages sensorControlMessageRequests; | ||
| SensorControlMessagePointers sensorControlMessageRequestPointers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both fields never used.
| namespace Details { | ||
|
|
||
| template<typename N, typename ValueType, ValueType v> | ||
| struct NameValuePayload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never Used.
|
|
||
| public: | ||
|
|
||
| explicit StringPayload(std::string const& value) noexcept : value(value) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning: Clang-Tidy: Pass by value and use std::move
Not sure how to fix, I tried following this link
| return value; | ||
| } | ||
|
|
||
| Type const& getValue() const noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never used.
| return value; | ||
| } | ||
|
|
||
| static constexpr bool isSuccess() noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never used.
| // | ||
| // virtual void sendResponse(RealNumberParameterResponse&& realNumberParameterResponse) = 0; | ||
| // | ||
| // virtual void sendResponse(BooleanParameterResponse&& booleanParameterResponse) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code?
|
|
||
| public: | ||
|
|
||
| explicit ServerRequest(PayloadType const& payload) noexcept : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
badRequest et CausedAnError sont pas initialises dans le constructor
| return badRequest; | ||
| } | ||
|
|
||
| bool const& hasCausedAnError() const noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
never used
!!! IMPORTANT!!! not final DO NOT MERGE YET
Introduit beaucoup de changements majeurs (en terme de comportement). Entre-autre :
ServerCommunicatorpour permettre de faire la reception async deRequestAssemblerpour faire la logique, le traitement et les validations des requetes (mostly empty for now, but really helpful to clarify the code)produce/consumepour les Request/Response -> notament :RequestHandlerParameters-> Permet de batch les parametres et de les traiter facilement (mais la classe en elle meme est pas super belle)StringLiteralsqui permet de creer des Strings a la compilation et de les passer entemplate parameters--> (ca c'est un brin de metaprog :success-kid: )std::tupleet fonctions utilitaires qui vont avec pour faciliter les listes de differentstemplate parameters