Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ void GatewayApplication::PropagateService(const std::string& specifier_str)
return;
}

std::vector<ServiceElementConfiguration> elements{};
std::vector<impl::EventInfo> elements{};
const auto& event_map = proxy_it->second.GetEvents();
for (auto it = event_map.cbegin(); it != event_map.cend(); ++it)
{
const auto sample_size = it->second.GetSampleSize();
elements.push_back(ServiceElementConfiguration{std::string(it->first), DataTypeSizeInfo{sample_size, 0U}});
elements.push_back(impl::EventInfo{it->first, impl::DataTypeMetaInfo{sample_size, 0U}});
}

auto provide_result = transport_layer_->ProvideService(std::move(specifier_result).value(), std::move(elements));
Expand Down Expand Up @@ -334,7 +334,7 @@ void GatewayApplication::ReRegisterActiveEventSubscriptions(const std::string& s
}

score::Result<void> GatewayApplication::ProvideService(impl::InstanceSpecifier service_instance_specifier,
std::vector<ServiceElementConfiguration> service_elements)
std::vector<impl::EventInfo> service_elements)
{
if (!IsServiceInstanceAccepted(service_instance_specifier.ToString()))
{
Expand Down Expand Up @@ -368,17 +368,8 @@ score::Result<void> GatewayApplication::ProvideService(impl::InstanceSpecifier s
return {};
}

std::vector<impl::EventInfo> event_infos;
event_infos.reserve(service_elements.size());

for (const auto& element : service_elements)
{
event_infos.push_back(
{element.element_name, impl::DataTypeMetaInfo{element.size_info.Size(), element.size_info.Alignment()}});
}

impl::GenericSkeletonServiceElementInfo skeleton_info;
skeleton_info.events = event_infos;
skeleton_info.events = service_elements;
auto skeleton_result = impl::GenericSkeleton::Create(service_instance_specifier, skeleton_info);
if (!skeleton_result.has_value())
{
Expand All @@ -396,7 +387,7 @@ score::Result<void> GatewayApplication::ProvideService(impl::InstanceSpecifier s
auto& skeleton = skeletons_.at(service_instance_specifier_str);
for (const auto& element : service_elements)
{
RegisterEventReceiveHandlerCallback(skeleton, service_instance_specifier_str, element.element_name);
RegisterEventReceiveHandlerCallback(skeleton, service_instance_specifier_str, std::string{element.name});
}

auto offer_result = skeleton.OfferService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class GatewayApplication : public GatewayCore
score::Result<void> Start();

score::Result<void> ProvideService(impl::InstanceSpecifier service_instance_specifier,
std::vector<ServiceElementConfiguration> service_elements) override;
std::vector<impl::EventInfo> service_elements) override;
void StopOfferService(impl::InstanceSpecifier service_instance_specifier) override;
score::Result<void> OfferService(impl::InstanceSpecifier service_instance_specifier) override;
score::Result<void> RegisterUpdateNotification(impl::InstanceSpecifier service_instance_specifier,
Expand Down
2 changes: 1 addition & 1 deletion score/mw/com/gateway/gateway_application/gateway_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GatewayCore
/// for the service instance, which will be realized as a Forwarding Skeleton (GenericSkeleton).
/// \return result indicating success or failure.
virtual score::Result<void> ProvideService(impl::InstanceSpecifier service_instance_specifier,
std::vector<ServiceElementConfiguration> service_elements) = 0;
std::vector<impl::EventInfo> service_elements) = 0;

/// \brief Stop providing the given service instance locally within the destination domain.
/// \param service_instance_specifier instance specifier of the service instance to stop offering. It is expected,
Expand Down
12 changes: 1 addition & 11 deletions score/mw/com/gateway/transport_layer/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ cc_library(
"//score/mw/com/gateway:__subpackages__",
],
deps = [
"//score/mw/com/impl:generic_skeleton",
"//score/mw/com/impl:instance_specifier",
"//score/mw/com/impl:service_element_type",
"@score_baselibs//score/memory:data_type_size_info",
"@score_baselibs//score/result",
],
)
Expand Down Expand Up @@ -81,13 +81,3 @@ cc_unit_test(
"@score_baselibs//score/result",
],
)

cc_unit_test(
name = "transport_test",
srcs = ["transport_test.cpp"],
features = COMPILER_WARNING_FEATURES,
deps = [
":transport",
"@score_baselibs//score/result",
],
)
28 changes: 2 additions & 26 deletions score/mw/com/gateway/transport_layer/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,17 @@
#ifndef SCORE_MW_COM_GATEWAY_TRANSPORT_LAYER_TRANSPORT_H
#define SCORE_MW_COM_GATEWAY_TRANSPORT_LAYER_TRANSPORT_H

#include "score/memory/data_type_size_info.h"
#include "score/mw/com/impl/generic_skeleton.h"
#include "score/mw/com/impl/instance_specifier.h"
#include "score/mw/com/impl/service_element_type.h"
#include "score/result/result.h"

#include <cstddef>
#include <string>
#include <tuple>
#include <type_traits>
#include <vector>

namespace score::mw::com::gateway
{

using DataTypeSizeInfo = score::memory::DataTypeSizeInfo;

static_assert(std::is_trivially_copyable_v<DataTypeSizeInfo>, "DataTypeSizeInfo must be trivially copyable");

/// \brief Describes a single service element (event, field, or method) and its serialization type info.
struct ServiceElementConfiguration
{
std::string element_name;
DataTypeSizeInfo size_info;

std::tuple<const std::string&, const DataTypeSizeInfo&> GetSerializeMembers() const
{
return {element_name, size_info};
}

std::tuple<std::string&, DataTypeSizeInfo&> GetSerializeMembers()
{
return {element_name, size_info};
}
};

/// \brief Abstract base class for gateway transport layer implementations.
class Transport
{
Expand Down Expand Up @@ -78,7 +54,7 @@ class Transport
/// provide. This information is needed to create the (generic) skeleton on the destination gateway side.
/// \return result indicating success or failure.
virtual score::Result<void> ProvideService(impl::InstanceSpecifier service_instance_specifier,
std::vector<ServiceElementConfiguration> service_elements) = 0;
std::vector<impl::EventInfo> service_elements) = 0;

/// \brief OfferService API to trigger service-instance offering at the destination gateway side.
/// \details Transport layer implementation shall "forward" this call to the destination gateway and trigger the
Expand Down
2 changes: 1 addition & 1 deletion score/mw/com/gateway/transport_layer/transport_mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TransportMock : public Transport
MOCK_METHOD(void, Shutdown, (), (override));
MOCK_METHOD(score::Result<void>,
ProvideService,
(impl::InstanceSpecifier, std::vector<ServiceElementConfiguration>),
(impl::InstanceSpecifier, std::vector<impl::EventInfo>),
(override));
MOCK_METHOD(score::Result<void>, StopOfferService, (impl::InstanceSpecifier), (override));
MOCK_METHOD(score::Result<void>, OfferService, (impl::InstanceSpecifier), (override));
Expand Down
48 changes: 0 additions & 48 deletions score/mw/com/gateway/transport_layer/transport_test.cpp

This file was deleted.

Loading