From: Sangyoon Jang Date: Mon, 22 Feb 2021 11:56:31 +0000 (+0900) Subject: Fix some function signatures X-Git-Tag: submit/tizen/20210806.015209~82^2~5^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81a09d492d04c04b4b9100499b0ba6bcb675e0a9;p=platform%2Fcore%2Fappfw%2Fcion.git Fix some function signatures Base class should be accessed by pointer type. Use const reference of vector to avoid unnecessary copy. Change-Id: I8efae6bcc65e8f7917632cee623cb7ff478722cc Signed-off-by: Sangyoon Jang --- diff --git a/cion/channel/broadcast_channel.cc b/cion/channel/broadcast_channel.cc index 330b759..2246306 100644 --- a/cion/channel/broadcast_channel.cc +++ b/cion/channel/broadcast_channel.cc @@ -41,13 +41,13 @@ void BroadcastChannel::Publish(IPayload* data) { } } -void BroadcastChannel::OnDataEvent(const IDataInfo& info, - std::vector data) { +void BroadcastChannel::OnDataEvent(std::shared_ptr info, + const std::vector& data) { } -void BroadcastChannel::OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerInfo) { +void BroadcastChannel::OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerInfo) { } diff --git a/cion/channel/broadcast_channel.hh b/cion/channel/broadcast_channel.hh index cffdd2b..c57125b 100644 --- a/cion/channel/broadcast_channel.hh +++ b/cion/channel/broadcast_channel.hh @@ -39,10 +39,10 @@ public: protected: virtual void OnMessageReceived(IPayload* data, std::shared_ptr peer) = 0; - void OnDataEvent(const IDataInfo& info, - std::vector serialized_payload) override; - void OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerinfo) override; + void OnDataEvent(std::shared_ptr info, + const std::vector& serialized_payload) override; + void OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerinfo) override; std::string GetServiceName() override; int GetChannelId() override; diff --git a/cion/channel/client_channel.cc b/cion/channel/client_channel.cc index 6c8a5f0..6a5bd6b 100644 --- a/cion/channel/client_channel.cc +++ b/cion/channel/client_channel.cc @@ -14,6 +14,8 @@ * limitations under the License. */ +#include + #include "client_channel.hh" #include "client_channel_implementation.hh" #include "control_info.hh" @@ -53,36 +55,39 @@ ClientChannel::Impl::Impl(ClientChannel* parent, std::string service_name, } void ClientChannel::TryDiscovery() { - auto ci = ControlInfo(IControlInfo::ControlType::DISCOVERY, + auto ci = std::make_shared(IControlInfo::ControlType::DISCOVERY, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->sender_->OperateChannel(ci, nullptr); } void ClientChannel::StopDiscovery() { - auto ci = ControlInfo(IControlInfo::ControlType::STOP_DISCOVERY, + auto ci = std::make_shared( + IControlInfo::ControlType::STOP_DISCOVERY, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->sender_->OperateChannel(ci, nullptr); } void ClientChannel::Connect(std::shared_ptr peer) { - auto ci = ControlInfo(IControlInfo::ControlType::CONNECT, + auto ci = std::make_shared(IControlInfo::ControlType::CONNECT, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->sender_->OperateChannel(ci, peer); } void ClientChannel::Disconnect() { - auto ci = ControlInfo(IControlInfo::ControlType::DISCONNECT, + auto ci = std::make_shared(IControlInfo::ControlType::DISCONNECT, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->sender_->OperateChannel(ci, impl_->peer_); } std::vector ClientChannel::SendData(std::vector data, int timeout) { - auto di = DataInfo(IDataInfo::MessageType::Sync, impl_->peer_->GetUUID()); + auto di = std::make_shared(IDataInfo::MessageType::Sync, + impl_->peer_->GetUUID()); return impl_->sender_->SendData(data, di, impl_->peer_, timeout); } void ClientChannel::SendPayLoadAsync(IPayload* data) { - auto di = DataInfo(IDataInfo::MessageType::Sync, impl_->peer_->GetUUID()); + auto di = std::make_shared(IDataInfo::MessageType::Sync, + impl_->peer_->GetUUID()); impl_->sender_->SendData(data->Serialize(), di, impl_->peer_, -1); } @@ -90,17 +95,18 @@ std::shared_ptr ClientChannel::GetPeerInfo() { return impl_->peer_; } -void ClientChannel::OnDataEvent(const IDataInfo& info, std::vector data) { - if (info.GetType() == IDataInfo::MessageType::Async) { - auto pl = DataPayload(data); +void ClientChannel::OnDataEvent(std::shared_ptr info, + const std::vector& data) { + if (info->GetType() == IDataInfo::MessageType::Async) { + auto pl = std::make_shared(data); OnPayloadReceived(pl); } } -void ClientChannel::OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerInfo) { +void ClientChannel::OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerInfo) { std::shared_ptr peer; - IConnectionInfo::ConnectionType type = info.GetConnectionType(); + IConnectionInfo::ConnectionType type = info->GetConnectionType(); switch (type) { case IConnectionInfo::ConnectionType::Connected: { impl_->peer_ = std::shared_ptr(peer); diff --git a/cion/channel/client_channel.hh b/cion/channel/client_channel.hh index 278c000..55ace5b 100644 --- a/cion/channel/client_channel.hh +++ b/cion/channel/client_channel.hh @@ -46,14 +46,14 @@ public: protected: virtual void OnConnentionStatusChaneged(std::shared_ptr peer, IConnectionInfo::ConnectionStatus status) = 0; - virtual void OnPayloadReceived(IPayload& data) = 0; + virtual void OnPayloadReceived(std::shared_ptr data) = 0; virtual void OnErrorReported(int code, std::shared_ptr peer) = 0; virtual void OnDiscovered(std::shared_ptr peer) = 0; - void OnDataEvent(const IDataInfo& info, - std::vector serialized_payload) override; - void OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerinfo) override; + void OnDataEvent(std::shared_ptr info, + const std::vector& serialized_payload) override; + void OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerinfo) override; std::string GetServiceName() override; int GetChannelId() override; diff --git a/cion/channel/ievent_observer.hh b/cion/channel/ievent_observer.hh index b8fae58..b54c922 100644 --- a/cion/channel/ievent_observer.hh +++ b/cion/channel/ievent_observer.hh @@ -18,6 +18,7 @@ #ifndef CION_IEVENTOBSERVER_H_ #define CION_IEVENTOBSERVER_H_ +#include #include #include @@ -31,11 +32,11 @@ namespace channel { class IEventObserver { public: - virtual void OnDataEvent(const IDataInfo& info, - std::vector serialized_payload) = 0; + virtual void OnDataEvent(std::shared_ptr info, + const std::vector& serialized_payload) = 0; - virtual void OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerinfo) = 0; + virtual void OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerinfo) = 0; virtual std::string GetServiceName() = 0; virtual int GetChannelId() = 0; diff --git a/cion/channel/ievent_sender.hh b/cion/channel/ievent_sender.hh index 733bc4d..2f1d340 100644 --- a/cion/channel/ievent_sender.hh +++ b/cion/channel/ievent_sender.hh @@ -31,12 +31,13 @@ namespace channel { class IEventSender { public: - virtual void SendDataAsync(std::vector serialized_payload, - const IDataInfo& info, std::shared_ptr peer_info) = 0; - virtual std::vector SendData(std::vector serialized_payload, - const IDataInfo& info, std::shared_ptr peer_info, + virtual void SendDataAsync(const std::vector& serialized_payload, + std::shared_ptr info, std::shared_ptr peer_info) = 0; + virtual std::vector SendData( + const std::vector& serialized_payload, + std::shared_ptr info, std::shared_ptr peer_info, int timeout) = 0; - virtual void OperateChannel(const IControlInfo& info, + virtual void OperateChannel(std::shared_ptr info, std::shared_ptr peer_info) = 0; virtual void SetSecurity(SecurityInfo sec) = 0; }; diff --git a/cion/channel/server_channel.cc b/cion/channel/server_channel.cc index 4808f77..5a75e50 100644 --- a/cion/channel/server_channel.cc +++ b/cion/channel/server_channel.cc @@ -15,6 +15,8 @@ * limitations under the License. */ +#include + #include "server_channel.hh" #include "server_channel_implementation.hh" #include "control_info.hh" @@ -57,21 +59,21 @@ ServerChannel::Impl::Impl(ServerChannel* parent, std::string service_name, } void ServerChannel::Listen() { - auto ci = ControlInfo(IControlInfo::ControlType::LISTEN, + auto ci = std::make_shared(IControlInfo::ControlType::LISTEN, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->listener_->RegisterObserver(this); impl_->sender_->OperateChannel(ci, impl_->peer_info_); } void ServerChannel::Stop() { - auto ci = ControlInfo(IControlInfo::ControlType::STOP, + auto ci = std::make_shared(IControlInfo::ControlType::STOP, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->listener_->UnregisterObserver(this); impl_->sender_->OperateChannel(ci, impl_->peer_info_); } void ServerChannel::Disconnect(std::shared_ptr peer) { - auto ci = ControlInfo(IControlInfo::ControlType::DISCONNECT, + auto ci = std::make_shared(IControlInfo::ControlType::DISCONNECT, IControlInfo::ChannelType::COMMUNICATION, impl_->service_name_); impl_->sender_->OperateChannel(ci, peer); } @@ -91,13 +93,14 @@ std::list> ServerChannel::GetConnectedPeerList() { } -void ServerChannel::OnDataEvent(const IDataInfo& info, std::vector data) { +void ServerChannel::OnDataEvent(std::shared_ptr info, + const std::vector& data) { for (auto& i : impl_->peerlist_) { - if (i->GetUUID() == info.GetUUID()) { - if (info.GetType() == IDataInfo::MessageType::Async) { - auto pl = DataPayload(data); + if (i->GetUUID() == info->GetUUID()) { + if (info->GetType() == IDataInfo::MessageType::Async) { + auto pl = std::make_shared(data); OnPayloadReceived(pl, i); - } else if (info.GetType() == IDataInfo::MessageType::Sync) { + } else if (info->GetType() == IDataInfo::MessageType::Sync) { OnDataReceived(data, i); } break; @@ -105,10 +108,10 @@ void ServerChannel::OnDataEvent(const IDataInfo& info, std::vector data) { } } -void ServerChannel::OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerInfo) { +void ServerChannel::OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerInfo) { std::shared_ptr peer; - IConnectionInfo::ConnectionType type = info.GetConnectionType(); + IConnectionInfo::ConnectionType type = info->GetConnectionType(); switch (type) { case IConnectionInfo::ConnectionType::ConnectionRequested: { OnConnentionRequest(peer); @@ -122,7 +125,7 @@ void ServerChannel::OnConnectionEvent(const IConnectionInfo& info, } case IConnectionInfo::ConnectionType::Disconnected: { for (auto it : impl_->peerlist_) { - if (it->GetUUID() == info.GetUUID()) { + if (it->GetUUID() == info->GetUUID()) { impl_->peerlist_.remove(it); break; } diff --git a/cion/channel/server_channel.hh b/cion/channel/server_channel.hh index 2e868f5..3c81dc7 100644 --- a/cion/channel/server_channel.hh +++ b/cion/channel/server_channel.hh @@ -49,17 +49,17 @@ class ServerChannel: public IEventObserver { protected: virtual void OnConnentionStatusChaneged(std::shared_ptr peer, IConnectionInfo::ConnectionStatus status) = 0; - virtual std::vector OnDataReceived(std::vector data, + virtual std::vector OnDataReceived(const std::vector& data, std::shared_ptr peer) = 0; - virtual void OnPayloadReceived(IPayload& data, + virtual void OnPayloadReceived(std::shared_ptr data, std::shared_ptr peer) = 0; virtual bool OnConnentionRequest(std::shared_ptr peer) = 0; virtual void OnErrorReported(int code, std::shared_ptr peer) = 0; - void OnDataEvent(const IDataInfo& info, - std::vector serialized_payload) override; - void OnConnectionEvent(const IConnectionInfo& info, - std::vector serialized_peerinfo) override; + void OnDataEvent(std::shared_ptr info, + const std::vector& serialized_payload) override; + void OnConnectionEvent(std::shared_ptr info, + const std::vector& serialized_peerinfo) override; std::string GetServiceName() override; int GetChannelId() override; diff --git a/vine_manager/vine_manager.cc b/vine_manager/vine_manager.cc index 0fca81a..22585e7 100644 --- a/vine_manager/vine_manager.cc +++ b/vine_manager/vine_manager.cc @@ -259,19 +259,21 @@ void VineManager::RegisterObserver(channel::IEventObserver* observer) { void VineManager::UnregisterObserver(channel::IEventObserver* observer) { } -void VineManager::SendDataAsync(std::vector serialized_payload, - channel::IDataInfo& info, int channel_id, +void VineManager::SendDataAsync(const std::vector& serialized_payload, + std::shared_ptr info, int channel_id, std::shared_ptr peer_info) { } -std::vector VineManager::SendData(std::vector serialized_payload, - channel::IDataInfo& info, int channel_id, +std::vector VineManager::SendData( + const std::vector& serialized_payload, + std::shared_ptr info, int channel_id, std::string peer_uuid, int timeout) { return {}; } void VineManager::OperateChannel(int channel_id, - const channel::IControlInfo& info, std::shared_ptr peer_info) { + std::shared_ptr info, + std::shared_ptr peer_info) { } } // namespace cion \ No newline at end of file diff --git a/vine_manager/vine_manager.hh b/vine_manager/vine_manager.hh index d08dbc8..a7d4eb6 100644 --- a/vine_manager/vine_manager.hh +++ b/vine_manager/vine_manager.hh @@ -41,13 +41,14 @@ class EXPORT_API VineManager { void UnregisterSender(int channel_id); void RegisterObserver(channel::IEventObserver* observer); void UnregisterObserver(channel::IEventObserver* observer); - void SendDataAsync(std::vector serialized_payload, - channel::IDataInfo& info, int channel_id, + void SendDataAsync(const std::vector& serialized_payload, + std::shared_ptr info, int channel_id, std::shared_ptr peer_info); - std::vector SendData(std::vector serialized_payload, - channel::IDataInfo& info, int channel_id, + std::vector SendData(const std::vector& serialized_payload, + std::shared_ptr info, int channel_id, std::string peer_uuid, int timeout); - void OperateChannel(int channel_id, const channel::IControlInfo& info, + void OperateChannel(int channel_id, + std::shared_ptr info, std::shared_ptr peer_info); void Discovery(); VineManager(); diff --git a/vine_manager/vine_sender.cc b/vine_manager/vine_sender.cc index 1197fe2..5d706cf 100644 --- a/vine_manager/vine_sender.cc +++ b/vine_manager/vine_sender.cc @@ -34,7 +34,7 @@ VineSender::~VineSender() { } VineSender::Impl::Impl(std::string service_name, int channel_id) - : service_name_(service_name), channel_id_(channel_id) { + : service_name_(service_name), channel_id_(channel_id) { port_ = 0; VineManager::GetInst().RegisterSender(service_name, channel_id); } @@ -43,22 +43,25 @@ VineSender::Impl::~Impl() { VineManager::GetInst().UnregisterSender(channel_id_); } -void VineSender::Impl::OperateChannel(const channel::IControlInfo& info, - std::shared_ptr peer_info) { - - VineManager::GetInst().OperateChannel(channel_id_, info, peer_info); +void VineSender::Impl::OperateChannel( + std::shared_ptr info, + std::shared_ptr peer_info) { + VineManager::GetInst().OperateChannel(channel_id_, info, peer_info); } -void VineSender::SendDataAsync(std::vector serialized_payload, - const channel::IDataInfo& info, std::shared_ptr peer_info) { +void VineSender::SendDataAsync(const std::vector& serialized_payload, + std::shared_ptr info, + std::shared_ptr peer_info) { } -std::vector VineSender::SendData(std::vector serialized_payload, - const channel::IDataInfo& info, std::shared_ptr peer_info, int timeout) { +std::vector VineSender::SendData( + const std::vector& serialized_payload, + std::shared_ptr info, + std::shared_ptr peer_info, int timeout) { return {}; } -void VineSender::OperateChannel(const channel::IControlInfo& info, +void VineSender::OperateChannel(std::shared_ptr info, std::shared_ptr peer_info) { impl_->OperateChannel(info, peer_info); } diff --git a/vine_manager/vine_sender.hh b/vine_manager/vine_sender.hh index 06f55c8..c08bc94 100644 --- a/vine_manager/vine_sender.hh +++ b/vine_manager/vine_sender.hh @@ -40,13 +40,13 @@ class EXPORT_API VineSender : public channel::IEventSender { virtual ~VineSender(); protected: - void SendDataAsync(std::vector serialized_payload, - const channel::IDataInfo& info, + void SendDataAsync(const std::vector& serialized_payload, + std::shared_ptr info, std::shared_ptr peer_info) override; - std::vector SendData(std::vector serialized_payload, - const channel::IDataInfo& info, + std::vector SendData(const std::vector& serialized_payload, + std::shared_ptr info, std::shared_ptr peer_info, int timeout) override; - void OperateChannel(const channel::IControlInfo& info, + void OperateChannel(std::shared_ptr info, std::shared_ptr peer_info) override; void SetSecurity(SecurityInfo sec) override; diff --git a/vine_manager/vine_sender_implementation.hh b/vine_manager/vine_sender_implementation.hh index f16ae79..8aabe5f 100644 --- a/vine_manager/vine_sender_implementation.hh +++ b/vine_manager/vine_sender_implementation.hh @@ -17,6 +17,8 @@ #ifndef CION_API_VINE_SENDER_IMPLEMENTATION_HH_ #define CION_API_VINE_SENDER_IMPLEMENTATION_HH_ +#include + #include "cion/common/peer_info.hh" #include "cion/channel/idata_info.hh" #include "cion/channel/icontrol_info.hh" @@ -32,7 +34,7 @@ class VineSender::Impl { friend class VineSender; explicit Impl(std::string service_name, int channel_id); - void OperateChannel(const channel::IControlInfo& info, + void OperateChannel(std::shared_ptr info, std::shared_ptr peer_info); private: