[Miwi-middleware] RFC: NetworkContext opaque object

Dmitri Rubinstein rubinstein at cs.uni-saarland.de
Wed May 14 19:00:21 CEST 2014


Why io_service_ is a shared_ptr ? Boost::asio does not support this. 
NetworkContext should be shared IMHO, and all classes that use it should 
store shared pointer to it. Then there is a guarantee that encapsulated 
boost::asio::io_service will stay as long as users of  NetworkContext do 
exist.

Also usually you should use public inheritance:

  class AsioNetworkContext : public NetworkContext.

Best,

Dmitri

On 05/14/14 17:47, Mathias Hablützel wrote:
> High everyone,
>
> I started to write an opaque structure for storing context
> (boost::asio::io_service), can someone of the KIARA dev team review my
> first steps before I run in the wrong direction?
>
> Inline patch:
>
> ###############
> diff --git a/src/KIARA/Transport/Transport.hpp
> b/src/KIARA/Transport/Transport.hpp
> index d2c8a37..23cc8ef 100644
> --- a/src/KIARA/Transport/Transport.hpp
> +++ b/src/KIARA/Transport/Transport.hpp
> @@ -268,6 +268,26 @@ private:
>       static TransportMap transports_;
>   };
> +// Base class for the network context object
> +class NetworkContext
> +{
> +public:
> +       virtual ~NetworkContext();
> +};
> +
> +// Derived class for the network context object for Boost.Asio
> +class AsioNetworkContext : NetworkContext
> +{
> +public:
> +       explicit AsioNetworkContext(boost::asio::io_service&);
> +       ~AsioNetworkContext();
> +       // Get a reference of the io_service
> +       boost::asio::io_service& getIoService () const;
> +
> +private:
> +       boost::shared_ptr<boost::asio::io_service> io_service_;
> +};
> +
>   } // namespace Transport
>   } // namespace KIARA
> ###############
>
> Thanks for comments
> Mathias
> --
> |_|0|_|   Researcher (Network and Linux)
> |_|_|0|   Institute of Information Technology
> |0|0|0|   Zürich University of Applied Sciences
> http://cloudcomp.ch
>
>
> _______________________________________________
> Miwi-middleware mailing list
> Miwi-middleware at lists.fi-ware.org
> https://lists.fi-ware.org/listinfo/miwi-middleware
>




More information about the Miwi-middleware mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy