Re: RFC: getting a unique integer value


Subject: Re: RFC: getting a unique integer value
From: Matti Picus (matti@picus.org)
Date: Sat Oct 13 2001 - 12:38:11 CDT


This is just an example, not any kind of full-blown class. If you want to
see an implementation, look at ie_imp_RTF.cpp. Anyone looking for a design
pattern for this task can feel free to use it, for AbiWord or for any other
purpose.

There is no reason to initialize the static member to 100. The role of m_ID
is to uniquely identify the class instance, so that a different class
instance can hold the m_ID instead of a pointer to the class.

Matti

At 10:53 AM 12/10/2001 +0200, you wrote:
>Matti Picus wrote:
>
>>Generating a unique int ID seems to be faulty in many places in AbiWord.
>>The general method is to use the result from UT_rand() and hope that it
>>is unique. I recently modified the RTF importer with a different method:
>>using a static member variable.
>>I hope the construct is portable to all platforms.
>>Here is what it looks like:
>>-------- NeedToIncrement.h-----------------
>>class NeedToIncrement
>>{
>> static UT_uint32 m_incrementer;
>> UT_uint32 m_ID;
>>}
>>-----------------------------------------
>
>
>Matti, is it the full class, or just a brief version?
>
>Because I'm not seeing any public: methods there (except the default ones)...
>
>Besides that, it seems a nice idea!
>
>btw, why do you initialize m_incrementer to 100? What's the role of m_ID?
>
>Cheers,
>
>--
>Joaquin Cuenca Abela
>e98cuenc@yahoo.com



This archive was generated by hypermail 2b25 : Sat Oct 13 2001 - 12:58:50 CDT