Biorithm  1.1
 All Classes Functions Variables Typedefs Friends
Rotor.h
00001 /**************************************************************************
00002  * Copyright (c) 2007 Clifford Conley Owens III                           *
00003  *                                                                        *
00004  * This file is part of Biorithm.                                         *
00005  *                                                                        *
00006  * Biorithm is free software: you can redistribute it and/or modify       *
00007  * it under the terms of the GNU General Public License as published by   *
00008  * the Free Software Foundation, either version 3 of the License, or      *
00009  * (at your option) any later version.                                    *
00010  *                                                                        *
00011  * Biorithm is distributed in the hope that it will be useful,            *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00014  * GNU General Public License for more details.                           *
00015  *                                                                        *
00016  * You should have received a copy of the GNU General Public License      *
00017  * along with Biorithm.  If not, see <http://www.gnu.org/licenses/>.      *
00018  *                                                                        *
00019  **************************************************************************/
00020 
00031 #ifndef ROTOR_H
00032 #define ROTOR_H
00033 
00034 // ---------------------------- External Headers ---------------------------- //
00035 
00036 #include <vector>
00037 
00038 using namespace std;
00039 
00046 class Rotor
00047 {
00048     private:
00049         // This is the vector of digits
00050         vector<unsigned int> digits;
00051 
00052         // The number of different values a digit can have
00053         unsigned int values;
00054 
00055         // This lets us know whether or not the digits must be unique
00056         bool unique;
00057 
00058         // Helper methods
00059 
00060         void rotateUnique(unsigned int pos);
00061         void start(unsigned int pos);
00062         void rotateNonunique(unsigned int pos);
00063 
00064     public:
00065         Rotor(unsigned int digitSize = 0, unsigned int valuesSize = 0,
00066             bool unique = false);
00067         Rotor(const Rotor& src);
00068         ~Rotor();
00069         Rotor& operator =(const Rotor& rhs);
00070         unsigned int getValue(unsigned int index) const;
00071         bool isValid() const;
00072         void rotate();
00073         void setUnique();
00074         void reset();
00075         void reset(const vector<unsigned int>& startPos);
00076         void resizeDigits(unsigned int size);
00077         void resizeValues(unsigned int size);
00078         unsigned int getSize() const;
00079         unsigned int getDigit(unsigned int index) const;
00080         bool isEmpty() const;
00081 };
00082 
00083 #endif
 All Classes Functions Variables Typedefs Friends