// RandomRegistry.h #ifndef RandomRegistry_H #define RandomRegistry_H // Maintains a list of pointers to RandomGenerator objects. // The method record is called to record the state of each // and set is called to reset the state of each to previously recorded // values. #include #include #include "ptr/Ptr.h" #include "ptr/NullPolicy.h" #include "ptr/AutoPolicy.h" #include "RandomGenerator.h" class RandomRegistry { private: // typedefs // Random generator pointer. typedef Ptr GenPtr; // Const random generator pointer. typedef Ptr CGenPtr; // list of generators typedef std::vector GenList; // const list of generators typedef std::vector CGenList; // pointer to such a list typedef Ptr CGenListPtr; // list of generator lists typedef std::vector StateList; private: // attributes // Known generators. GenList _gens; // Array of states for each generator. StateList _states; private: // methods // output stream. void ostr(std::ostream& stream) const; // Hide copy. RandomRegistry(const RandomRegistry& rhs); // Hide assignment. RandomRegistry& operator=(const RandomRegistry& rhs); public: // methods // Constructor. RandomRegistry(); // Destructor. ~RandomRegistry(); // Register a generator. void add_generator(RandomGenerator& gen); // Record the states. A unique integer labeling the state is returned. int record(); // Return the number of registered generators. int get_generator_count() const; // Return the number of recorded states. int get_state_count() const; // Reset the states. // Return nonzero for error (e.g. unknown state index). int set(int istate); // output stream friend std::ostream& operator<<(std::ostream& stream, const RandomRegistry& reg); }; #endif