00001 #ifndef DV_UTIL_RANDOM_H 00002 #define DV_UTIL_RANDOM_H 00003 // $Id: random.h,v 1.3 2002/11/13 16:19:04 dvermeir Exp $ 00004 00005 /*! \file 00006 Random number generator using /dev/urandom. 00007 */ 00008 00009 #include <stdexcept> 00010 00011 00012 namespace Dv { 00013 namespace Util { 00014 00015 //! Class supporting random number generation. 00016 /*! Example usage 00017 \code 00018 unsigned long key = Dv::Util::Random::rand(); 00019 \endcode 00020 */ 00021 class Random { 00022 //! Produces a random unsigned long taken from /dev/urandom. 00023 /*! An exception is thrown if anything goes wrong, e.g. 00024 the file /dev/urandom cannot be opened. 00025 00026 Later extensions should automatically switch to another 00027 implementation if /dev/urandom is not available. 00028 */ 00029 public: 00030 static unsigned long rand() throw (std::runtime_error); 00031 }; 00032 00033 }} 00034 #endif
dvutil-0.13.15 | [30 December, 2004] |