Skip to content

Commit

Permalink
Refs #21222. Apply suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Jul 4, 2024
1 parent 6746326 commit 3fdb2a8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ module DDS { module XTypes {


// eProsima extension to support TypeIdentifier no value cases.
@final
@final @nested
struct Dummy
{
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ namespace std {

template <> struct hash<eprosima::fastdds::dds::xtypes::TypeIdentifierSeq>
{
std::size_t operator()(const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq &k) const
std::size_t operator ()(
const eprosima::fastdds::dds::xtypes::TypeIdentifierSeq& k) const
{
std::size_t hash_value = 0;
for (const auto &id : k)
for (const auto& id : k)
{
hash_value ^= (static_cast<size_t>(id.equivalence_hash()[0]) << 16) |
(static_cast<size_t>(id.equivalence_hash()[1]) << 8) |
(static_cast<size_t>(id.equivalence_hash()[2]));
(static_cast<size_t>(id.equivalence_hash()[1]) << 8) |
(static_cast<size_t>(id.equivalence_hash()[2]));
}
return hash_value;
}

};

} // namespace std
Expand All @@ -75,19 +77,22 @@ class TypeLookupManager;
*/
class TypeLookupRequestListener : public fastdds::rtps::ReaderListener, public fastdds::rtps::WriterListener
{
public:
public:

/**
* @brief Constructor.
* @param manager Pointer to the TypeLookupManager.
*/
TypeLookupRequestListener(TypeLookupManager *manager);
TypeLookupRequestListener(
TypeLookupManager* manager);

/**
* @brief Destructor.
*/
virtual ~TypeLookupRequestListener() override;

protected:
protected:

/**
* @brief Starts the thread that process the received requests.
*/
Expand All @@ -107,19 +112,21 @@ class TypeLookupRequestListener : public fastdds::rtps::ReaderListener, public f
* @brief Gets TypeObject from TypeObjectRegistry, creates and sends reply.
* @param request_id[in] The SampleIdentity of the request.
* @param request[in] The request data.
* @param vendor_id[in] Vendor identifier which sent the request.
* @param vendor_id[in] Vendor identifier that sent the request.
*/
void check_get_types_request(SampleIdentity request_id,
const TypeLookup_getTypes_In &request,
const rtps::VendorId_t &vendor_id);
void check_get_types_request(
SampleIdentity request_id,
const TypeLookup_getTypes_In& request,
const rtps::VendorId_t& vendor_id);

/**
* @brief Gets type dependencies from TypeObjectRegistry, creates and sends reply.
* @param request_id[in] The SampleIdentity of the request.
* @param request[in] The request data.
*/
void check_get_type_dependencies_request(SampleIdentity request_id,
const TypeLookup_getTypeDependencies_In &request);
void check_get_type_dependencies_request(
SampleIdentity request_id,
const TypeLookup_getTypeDependencies_In& request);

/**
* @brief Creates a TypeLookup_getTypeDependencies_Out using continuation points to manage size.
Expand All @@ -129,42 +136,52 @@ class TypeLookupRequestListener : public fastdds::rtps::ReaderListener, public f
* @return The reply containing the dependent types.
*/
TypeLookup_getTypeDependencies_Out
prepare_get_type_dependencies_response(const xtypes::TypeIdentifierSeq &id_seq,
const std::unordered_set<xtypes::TypeIdentfierWithSize> &type_dependencies,
const std::vector<uint8_t> &continuation_point);
prepare_get_type_dependencies_response(
const xtypes::TypeIdentifierSeq& id_seq,
const std::unordered_set<xtypes::TypeIdentfierWithSize>& type_dependencies,
const std::vector<uint8_t>& continuation_point);

/**
* @brief Creates and sends the TypeLookup_Reply.
* @param request_id[in] The SampleIdentity of the request.
* @param exception_code[in] The RemoteExceptionCode_t used in the header.
* @param out[in] Reply to the query included in the received request.
*/
void answer_request(SampleIdentity request_id,
rpc::RemoteExceptionCode_t exception_code,
TypeLookup_getTypeDependencies_Out &out);
void answer_request(
SampleIdentity request_id,
rpc::RemoteExceptionCode_t exception_code,
TypeLookup_getTypeDependencies_Out& out);
void
answer_request(SampleIdentity request_id, rpc::RemoteExceptionCode_t exception_code, TypeLookup_getTypes_Out &out);
void answer_request(SampleIdentity request_id, rpc::RemoteExceptionCode_t exception_code);
answer_request(
SampleIdentity request_id,
rpc::RemoteExceptionCode_t exception_code,
TypeLookup_getTypes_Out& out);
void answer_request(
SampleIdentity request_id,
rpc::RemoteExceptionCode_t exception_code);

/**
* @brief Method call when this class is notified of a new cache change.
* @param reader The reader receiving the cache change.
* @param change The cache change.
*/
void on_new_cache_change_added(fastdds::rtps::RTPSReader *reader,
const fastdds::rtps::CacheChange_t *const change) override;
void on_new_cache_change_added(
fastdds::rtps::RTPSReader* reader,
const fastdds::rtps::CacheChange_t* const change) override;

void onWriterChangeReceivedByAll(fastdds::rtps::RTPSWriter *, fastdds::rtps::CacheChange_t *change) override;
void onWriterChangeReceivedByAll(
fastdds::rtps::RTPSWriter*,
fastdds::rtps::CacheChange_t* change) override;

//! A pointer to the typelookup manager.
TypeLookupManager *typelookup_manager_;
TypeLookupManager* typelookup_manager_;

//! Mutex to protect access to requests_with_continuation_.
std::mutex requests_with_continuation_mutex_;

//! Collection of the requests that needed continuation points.
std::unordered_map<xtypes::TypeIdentifierSeq, std::unordered_set<xtypes::TypeIdentfierWithSize>>
requests_with_continuation_;
requests_with_continuation_;

eprosima::thread request_processor_thread;
std::queue<std::pair<TypeLookup_Request, rtps::VendorId_t>> requests_queue_;
Expand Down

0 comments on commit 3fdb2a8

Please sign in to comment.