OFFilenameCreator Class Reference

A class for automatically creating unique pseudo-random filenames. More...

List of all members.

Public Member Functions

 OFFilenameCreator ()
 default constructor
 OFFilenameCreator (const OFFilenameCreator &copy)
 copy constructor
virtual ~OFFilenameCreator ()
 destructor
OFFilenameCreatoroperator= (const OFFilenameCreator &copy)
 assignment operator
OFBool makeFilename (unsigned int seed, const char *dir, const char *prefix, const char *postfix, OFString &filename)
 creates a new unique filename.

Static Public Member Functions

static unsigned int hashString (const char *str)
 creates hash value.
static int myrand_r (unsigned int *seed)
 simple but thread safe random number generator.

Static Private Member Functions

static void addLongToString (unsigned long l, OFString &s)
 appends the lower 32 bit of the given number to the given string.

Private Attributes

unsigned long creation_time
 date/time of creation of this object


Detailed Description

A class for automatically creating unique pseudo-random filenames.

Definition at line 39 of file offname.h.


Member Function Documentation

OFBool OFFilenameCreator::makeFilename ( unsigned int  seed,
const char *  dir,
const char *  prefix,
const char *  postfix,
OFString filename 
)

creates a new unique filename.

Parameters:
seed seed of random number generator
dir directory in which the file name should be located
prefix filename prefix
postfix filename postfix
filename string in which the filename (path) is returned
Returns:
OFTrue if successful, OFFalse if no filename could be created.

static unsigned int OFFilenameCreator::hashString ( const char *  str  )  [static]

creates hash value.

(i.e. random seed) from character string.

Parameters:
str null-terminated string
Returns:
hash value

static int OFFilenameCreator::myrand_r ( unsigned int *  seed  )  [static]

simple but thread safe random number generator.

The interface is derived from the Posix rand_r function. Uses a multiplicative congruential random-number generator with period 2**32 that returns successive pseudo-random numbers in the range of 0 to 0x7fffffff.

Parameters:
seed pointer to seed of random number generator, must not be NULL.
Returns:
pseudo-random number in the range of 0 to 0x7fffffff.

static void OFFilenameCreator::addLongToString ( unsigned long  l,
OFString s 
) [static, private]

appends the lower 32 bit of the given number to the given string.

Always appends exactly 8 digits (padded with leading zeroes).

Parameters:
l number to be appended to string
s string to be added to


The documentation for this class was generated from the following file:


Generated on 6 Jan 2011 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.5.1