qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Conway <acon...@redhat.com>
Subject Re: [c++]: messaging api, uuids and handles
Date Fri, 15 Jan 2010 14:06:21 GMT
On 01/15/2010 08:56 AM, Gordon Sim wrote:
> What do < and > mean for a uuid though? Or is this just in case you want
> to use them in containers that require sorting?

Exactly. map<UUID,Foo> is very likely something people will want to do.

>> Not sure about leaving data public. If you do make it private you need
>> to add operations to copy UUIDs to/from char arrays since the user may
>> want to store/retrive UUIDs in binary form. You could argue it's OK to
>> leave the data in the public API since its part of the ABI anyway, but
>> it looks a bit odd since we generally don't have any public data on our
>> classes, even the value classes. I'd be inclined to stick with
>> convention at the expense of adding:
>>
>> class Uuid {
>> public:
>> static const size_t SIZE=16;
>> /** Copy the UUID from data16, which must point to a 16-byte UUID */
>> Uuid(unsigned char* data16);
>> size_t size() const { return SIZE; } // For compatibility with std
>> sequences.
>> const unsigned char* data() const { return array; }
>>
>> private
>> const char* array[SIZE];
>> }
>
> I deliberated a little about this and initially felt that there was
> little gained by making it private. However I'm happy with your
> suggestion here so unless others have comments I'll go along with that.

I think the main gain is avoiding a clash with convention - the principle of 
least surprise. .size(), .data() are well known conventions (std::string, 
std::vector etc.), a public data member is surprising.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Mime
View raw message