Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The QUniqueIdGenerator class provides a generator of unique identifiers. More...
#include <QUniqueIdGenerator>
The QUniqueIdGenerator class provides a generator of unique identifiers.
The unique identifiers that are generated are 32 bits and are unique within the device they are created upon. If you require an identifier that is unique across multiple devices use QUuid instead.
The identifiers are are generated with a QUuid context identifier and an index. The context should be generated with a program such as uuidgen and represent the data store or context within which the identifier is generated. For example SQL and SIM card storage for QContacts each have their own context. The context is mapped to a 8 bit value allowing for 255 contexts for a single device.
The usual approach to constructing QUniqueIds is:
QUniqueIdGenerator generator(myContext); id = generator.createId();
QUniqueIdGenerator is suitable in cases where you need to generate an average of 100 identifiers a day or less and require a low number of bits when stored. If your program is likely to need more than 100 unique identifiers a day or does not benefit from the low 32bit storage size it is recommended you look at another type of unique id such as QUuid.
Constructs a QUniqueIdGenerator with the given context. It is recommended that the context be hard coded into your application.
Example:
QUniqueIdGenerator(QUUid("bd668b78-d892-4345-b0a3-77502d684f06"));
You can generate the context string using the uuidgen program. As there are only 255 available contexts, you should generate the context when developing your application, not as part of the application's execution.
Constructs a copy of other.
Destroys the QUniqueIdGenerator.
Returns an identifier that is valid only within a single application with the given index component. This identifier should not be shared or persisted between different applications or different executions of the same application. This function does not ensure the constructed identifier is not in conflict with past or future QUniqueId objects.
This function is not threadsafe.
Returns a identifier with the given index component. Does not ensure the constructed identifier is not in conflict with past or future QUniqueId objects.
See also createUniqueId().
Returns a identifier that is valid only within a single application. This identifier should not be shared or persisted between different applications or different executions of the same application.
This function is not threadsafe.
Returns an identifier with the same context component as the generator and an index component that is unique against other identifiers generated with this function for the same context and device.
See also constructUniqueId().
Returns true if the generator is valid and can be used to create or construct unique identifers. Otherwise returns false.
This function should only be needed during debugging as only a generator constructed using null QUuids will be invalid.
Returns a locally mapped integer value for context suitable for efficiently checking if a QUniqueId was generated from an equivalent QUniqueIdGenerator.
See also QUniqueId::mappedContext().
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |