1 #ifndef _GLIBMM_RANDOM_H 2 #define _GLIBMM_RANDOM_H 3 4 /* random.h 5 * 6 * Copyright (C) 2002 The gtkmm Development Team 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #include <glibmmconfig.h> 23 #include <glib.h> 24 25 extern "C" { 26 using GRand = struct _GRand; 27 } 28 29 namespace Glib 30 { 31 32 /** @defgroup Random Random Numbers 33 * Pseudo random number generator. 34 * @{ 35 */ 36 37 class GLIBMM_API Rand 38 { 39 public: 40 Rand(); 41 explicit Rand(guint32 seed); 42 ~Rand() noexcept; 43 44 // noncopyable 45 Rand(const Rand&) = delete; 46 Rand& operator=(const Rand&) = delete; 47 48 void set_seed(guint32 seed); 49 50 bool get_bool(); 51 52 guint32 get_int(); 53 gint32 get_int_range(gint32 begin, gint32 end); 54 55 double get_double(); 56 double get_double_range(double begin, double end); 57 gobj()58 GRand* gobj() { return gobject_; } gobj()59 const GRand* gobj() const { return gobject_; } 60 61 private: 62 GRand* gobject_; 63 }; 64 65 /** @} group Random */ 66 67 } // namespace Glib 68 69 #endif /* _GLIBMM_RANDOM_H */ 70