This chapter describes additional COM interfaces defined by the OSKit.
The oskit_random COM interface provides a simple encapsulation for pseudo-random number generators. The interface is based on the common C library functions random and srandom. The interface inherits from oskit_iunknown and provides the following additional methods:
The oskit_random_create function can be used to create instances of the oskit_random interface.
Create a new oskit_random object in the default seed state.
Upon success, returns 0. Upon failure, the return value is set to a code indicating the reason for failure. (See <oskit/error.h>.)
#include <oskit/com/random.h>
OSKIT_COMDECL oskit_random_random(oskit_random_t *r, [out] oskit_s32_t *out_num);
Use r to generate a new pseudo-random number in the range 0 to 231 - 1.
Upon success, returns 0. Upon failure, the return value is set to a code indicating the reason for failure. (See <oskit/error.h>.)
#include <oskit/com/random.h>
OSKIT_COMDECL oskit_random_srandom(oskit_random_t *r, oskit_u32_t seed);
Use seed to reinitialize the random number generator r.
Upon success, returns 0. Upon failure, the return value is set to a code indicating the reason for failure. (See <oskit/error.h>.)