1 //                                               -*- C++ -*-
2 /**
3  *  @brief RandomGeneratorState implements methods to manage the random generator state
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #ifndef OPENTURNS_RANDOMGENERATORSTATE_HXX
22 #define OPENTURNS_RANDOMGENERATORSTATE_HXX
23 
24 #include "openturns/PersistentObject.hxx"
25 #include "openturns/Indices.hxx"
26 
27 
28 BEGIN_NAMESPACE_OPENTURNS
29 
30 /** A couple (internal state array, picking index) */
31 class OT_API RandomGeneratorState
32   : public PersistentObject
33 {
34   CLASSNAME
35 
36   friend class RandomGenerator;
37 
38 public:
39 
40   /** Default constructor */
41   RandomGeneratorState();
42 
43   /** Standard constructor */
44   RandomGeneratorState(const Indices buffer, const UnsignedInteger index);
45 
46   /** Virtual constructor */
47   RandomGeneratorState * clone() const override;
48 
49   /** String converter */
50   String __repr__() const override;
51   String __str__(const String & offset = "") const override;
52 
53   /** Buffer Acccessor */
54   Indices getBuffer() const;
55 
56   /** Index Acccessor */
57   UnsignedInteger getIndex() const;
58 
59   /** Comparison operator */
60   Bool operator ==(const RandomGeneratorState & other) const;
61 
62   /** Method save() stores the object through the StorageManager */
63   void save(Advocate & adv) const override;
64 
65   /** Method load() reloads the object from the StorageManager */
66   void load(Advocate & adv) override;
67 
68 
69 private:
70   Indices buffer_;
71   UnsignedInteger index_;
72 
73 
74 }; /* end class RandomGeneratorState */
75 
76 
77 END_NAMESPACE_OPENTURNS
78 
79 #endif /* OPENTURNS_RANDOMGENERATORSTATE_HXX */
80