Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

bitgenerator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           bitgenerator.h  -  description
00003                              -------------------
00004     begin                : Tue May 14 2002
00005     copyright            : (C) 2002 by Peter Haase
00006     email                : mail@p-haase.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 
00030 #ifndef BITGENERATOR_HEADER
00031 #define BITGENERATOR_HEADER
00032 
00033 #include <stdexcept>
00034 #include <fstream>
00035 
00036 
00037 #include "misc.h"
00038 #include "phbib.h"
00039 #include "phrand.h"
00040 #include "signals.h"
00041 #include "basicdevice.h"
00042 
00043 
00044 class simth::Device;
00045 
00046 namespace simthlib
00047 {
00048 
00049 class BitGenerator;
00050 std::ostream& operator<<(std::ostream &os, const BitGenerator& bg);
00051 
00052 
00053 
00054 
00058 class BitGenerator : public simth::Device
00059 {
00060   public:
00061 
00062     enum GenerationMode { RANDOM, ALL_ZERO, ALL_ONE};
00063 
00069     BitGenerator(int deviceID, simth::DeviceSystemIntf* system,
00070          const simth::PropertyList& pl);
00071 
00074     virtual ~BitGenerator(){}
00075 
00076     virtual void updateInputLengths();
00077     virtual void updateOutputLengths();
00078 
00083     void fillBitSequence(simth::BitSeq* bits) const;
00084 
00087     void setBitseqLength(int newLength){setOutputLength(newLength, 0);invariante();}
00088 
00089     virtual void process();
00090 
00091     virtual void print(std::ostream &os) const;
00092 
00093   protected:
00094 
00095     GenerationMode mode() const {return mode_;}
00096 
00097   private:
00098 
00099     simth::GslRandomWrapper rng;
00100 
00101     GenerationMode mode_;
00102 
00103     virtual void invariante() const;
00104 
00105   public:
00106     static void init(const std::string fileName, simth::Device** dev, 
00107              simth::DeviceSystemIntf* sysPtr, int ID,
00108              const std::string& regionQualifier = "");
00109 };
00110 
00111 inline void BitGenerator::invariante() const
00112 {
00113   if(DEBUG) {
00114     if(outputLength(0) <= 0) {
00115       throw std::runtime_error("inline void bitGenerator::invariante() const : error 1");
00116     }
00117   }
00118 }
00119 
00120 
00121 }
00122 
00123 #endif
00124 
00125 
00126 

Generated on Tue Aug 9 14:35:10 2005 for simtheticlib by  doxygen 1.4.1