[haiku-commits] Re: r37936 - haiku/trunk/headers/os/net

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 06 Aug 2010 12:09:55 +0200

On 2010-08-06 at 10:08:02 [+0200], axeld@xxxxxxxxxxxxxxxx wrote:
> Author: axeld
> Date: 2010-08-06 10:08:02 +0200 (Fri, 06 Aug 2010)
> New Revision: 37936
> Changeset: http://dev.haiku-os.org/changeset/37936
> 
> Added:
>    haiku/trunk/headers/os/net/NetworkAddress.h
>    haiku/trunk/headers/os/net/NetworkInterface.h
>    haiku/trunk/headers/os/net/NetworkRoster.h
> Log:
> * Introduced first draft of a C++ network API. Comments welcome (I haven't
>   started implementing it yet, anyway).
> * Note that BNetworkAddress is supposed to replace BNetAddress -- the latter
>   does not provide enough space for a struct sockaddr_storage, and has a 
>   very IPv4 specific and incapable API, anyway.

Looks fine to me, except for some small things in the BNetworkRoster API:

> +class BNetworkRoster {
> +public:
> +            BNetworkRoster&        Default();

-> static

> +
> +            uint32                CountInterfaces();

const? Also while uint32 makes more sense, it's usually int32 in the rest of 
the Be API.

> +            BNetworkInterface*    InterfaceAt(uint32 index);

const? Same remarks about uint32. One advantage of using int32 is that you 
can make a loop like this:

for (int32 i = foo.CountItems() - 1; i >= 0; i--) {
    Bar* bar = foo.ItemAt(i);
    ...
}

> +            
> +            status_t            AddInterface(
> +                                    const BNetworkInterface& interface);
> +            status_t            RemoveInterface(
> +                                    const BNetworkInterface& interface);
> +            status_t            RemoveInterfaceAt(uint32 index);
> +
> +            status_t            StartWatching(const BMessenger& target,
> +                                    uint32 eventMask);
> +            void                StopWatching(const BMessenger& target);
> +
> +private:
> +                                BNetworkRoster();
> +                                ~BNetworkRoster();
> +};
> +
> +
> +#endif    // _NETWORK_ROSTER_H

Best regards,
-Stephan


Other related posts: