Index: /trunk/SophyaLib/BaseTools/srandgen.c
===================================================================
--- /trunk/SophyaLib/BaseTools/srandgen.c	(revision 3098)
+++ /trunk/SophyaLib/BaseTools/srandgen.c	(revision 3099)
@@ -243,4 +243,25 @@
 }
 
+/*! \ingroup  BaseTools
+  \brief Poisson random number generator.
+  
+  Return an integer value (>=0) corresponding a Poisson distribution with mean \b mu.
+  \warning NOT the most efficient way of generating a large series of numbers
+  with the SAME mean
+*/
+int PoissRand(double mu)
+{
+  double pp,ppi;
+  ppi = pp = exp(-mu);
+  double x = drand01();
+  int n = 0;
+  while (x > ppi) {
+    n++;
+    pp = mu*pp/(double)n;
+    ppi += pp;
+  }
+  return n;
+}
+
 /*=========================================================================*/
 /*
@@ -250,4 +271,7 @@
 	sigma "s" la distribution est limitee entre am +/- GAU_RANGE (obsolete).
 --
+*/
+/*! \ingroup  BaseTools
+ \brief OBSOLETE (gaussian random number generator)
 */
 double GauRnd1(double am, double s)
@@ -371,4 +395,18 @@
 }
 
+
+/*! 
+  \ingroup  BaseTools
+  \class SOPHYA::RandomGenerator
+  \brief Random number generator
+  
+  This is a class with static methods, providing an alternative interface 
+  to random number generations functions declared in srandgen.h.
+
+  \sa frand01 drand01 frandpm1 drandpm1 
+  \sa GauRnd PoissRand
+  \sa Ini_Ranf_Quick Ini_Ranf Get_Ranf Auto_Ini_Ranf
+*/
+
 /*==========================================================================*/
 /*
Index: /trunk/SophyaLib/BaseTools/srandgen.h
===================================================================
--- /trunk/SophyaLib/BaseTools/srandgen.h	(revision 3098)
+++ /trunk/SophyaLib/BaseTools/srandgen.h	(revision 3099)
@@ -8,8 +8,6 @@
 #include "machdefs.h"
 #include <stdlib.h>
-#ifdef __MWERKS__
-#include "unixmac.h"
-#endif
 
+/* ------- SPECIFIQUE Mac Darwin OSX  <= 10.2 (gcc < 3.x) -------- */
 #if defined(Darwin) &&  defined(__GNUC__) && (__GNUC__ < 3)
 #include "osx_values.h"
@@ -27,5 +25,17 @@
 #define drand48() ((double)(random())/LONG_MAX)
 #endif
+/* ------- FIN SPECIFIQUE Mac OSX / Darwin V <= 10.2 --------- */
 
+#ifdef __cplusplus
+/* Declaration en fonctions inlines pour du C++ */
+inline float frand01() { return ( (float) drand48() ); }
+inline double drand01() { return ( drand48() ); }
+inline double ranf01() { return ( drand48() ); }
+
+inline float frandpm1() { return ( 2. * (float) drand48()  - 1.); }
+inline double drandpm1() { return ( 2. * drand48() - 1.); }
+inline double ranfpm1() { return ( 2. * drand48() - 1.); }
+#else
+/* les memes en define pour du C */
 #define frand01() ( (float) drand48() )
 #define drand01() ( drand48() )
@@ -35,4 +45,5 @@
 #define drandpm1() ( 2. * drand01() - 1.)
 #define ranfpm1() drandpm1()
+#endif
 
 struct tirage_alea {
@@ -62,4 +73,6 @@
             ,double mx,double my,double sa,double sb,double teta);
 
+int PoissRand(double mu);
+
 TIREALEA *init_tirage_alea(int nbin,double xmin,double xmax,double (*fonc) (double));
 double tirage_alea(TIREALEA *alea);
@@ -70,4 +83,23 @@
 #endif
 
+/* -- Declaration d'une classe pour la centralier la doc -- Oct 2006 */
+#ifdef __cplusplus
+namespace SOPHYA {
+class RandomGenerator {
+ public:
+  /*! \brief Automatic initialization through Auto_Ini_Ranf() */
+  static inline void AutoInit(int lp=0) { Auto_Ini_Ranf(lp); return; } 
+  /*! \brief Return a random number \b r with a flat distribution  0<=r<=1 */ 
+  static inline double Flat01() { return drand48(); }
+  /*! \brief Return a random number \b r with a flat distribution  -1<=r<=1 */ 
+  static inline double Flatpm1() { return drandpm1(); }
+  /*! \brief Return a random number following a zero mean gaussian distribution  */ 
+  static inline double Gaussian(double sigma=1.) { return GauRnd(0., sigma); }
+  /*! \brief Return a random number following a Poisson distribution with mean \b mu  */ 
+  static inline int    Poisson(double mu) { return PoissRand(mu); }
+};
+} /* namespace SOPHYA */
 #endif
 
+#endif
+
