random.h

00001 //==========================================================================
00002 //  RANDOM.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  Random number generator functions
00008 //
00009 //==========================================================================
00010 
00011 /*--------------------------------------------------------------*
00012   Copyright (C) 1992-2008 Andras Varga
00013   Copyright (C) 2006-2008 OpenSim Ltd.
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __RANDOM_H
00020 #define __RANDOM_H
00021 
00022 #include "simkerneldefs.h"
00023 #include "csimulation.h"
00024 #include "cmodule.h"
00025 #include "crng.h"
00026 #include "cenvir.h"
00027 
00028 NAMESPACE_BEGIN
00029 
00030 
00031 // helper: return the "current" RNG.
00032 inline cRNG *__contextModuleRNG(int k) {
00033     return simulation.getContextModule() ? simulation.getContextModule()->getRNG(k) : ev.getRNG(k);
00034 }
00035 
00041 
00045 inline long intrand(long r)  {return __contextModuleRNG(0)->intRand(r);}
00046 
00050 inline double dblrand()  {return __contextModuleRNG(0)->doubleRand();}
00051 
00055 inline long genk_intrand(int k,long r)  {return __contextModuleRNG(k)->intRand(r);}
00056 
00060 inline double genk_dblrand(int k)  {return __contextModuleRNG(k)->doubleRand();}
00062 
00063 NAMESPACE_END
00064 
00065 
00066 #endif
00067 
00068 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3