• Main Page
  • Related Pages
  • Classes
  • Files
  • File List
  • File Members

ocsBitString.hh

Go to the documentation of this file.
00001 // $Id: ocsBitString.hh,v 1.1.1.1 2004/06/11 22:56:02 zweck Exp $
00002 
00003 //###################################################################
00004 //
00005 //           Optical Communication Systems Simulator
00006 //
00007 //       Copyright (2000):
00008 //       Optical Fiber Communications Laboratory (OFCL)
00009 //       Computer Science & Electrical Engineering Department (CSEE)
00010 //       University of Maryland Baltimore County (UMBC)
00011 //
00012 //###################################################################
00013 
00014 #ifndef _OCS_BIT_STRING_HH_
00015 #define _OCS_BIT_STRING_HH_
00016 
00017 enum typeBitString { ALL_ZEROS = 0, ALL_ONES = 1, SINGLE_ONE = 2,
00018                      RANDOM_SIMPLE = 3, RANDOM_EQUAL_ZEROS_ONES = 4,
00019                      PSEUDO_RANDOM = 5, USER_DEFINED = 6 };
00020 
00021 
00022 #ifndef _OCS_SYSTEM_HDRS_
00023 #define _OCS_SYSTEM_HDRS_
00024 
00025 #include <iostream.h>
00026 #include <string.h>
00027 #include <math.h> 
00028 #include <fstream.h>
00029 #include <complex.h>
00030 #include <stdlib.h>
00031 #include <stdio.h>
00032 #include <strstream>
00033 
00034 #include <string>
00035   using namespace std;
00036 
00037 
00038 #endif /* _OCS_SYSTEM_HDRS_ */
00039 
00040 #include "ocsConst.hh"
00041 #include "ocsTools.hh"
00042 #include "ocsReadWriteTools.hh"
00043 #include "ocsRanNumGen.hh"
00044 
00045 
00046 #include "StatisticsOfArray.hh"
00047 
00048 #include <string>
00049 
00050 // ##### Class BitString ############
00051 
00052 // Written by John Zweck in October 2000 and Feb 2001.
00053 
00054 // The BitString class is a helper class for the OptSignal class.
00055 // It sets the BitString for the OptSignal. The type of BitString 
00056 // is governed by the typeBitString enumerator which is declared
00057 // in ocsGlobalStructures.hh. 
00058 
00059 // The possible types of BitStrings are 
00060 
00061 // ALL_ZEROS = 0
00062 // ALL_ONES = 1
00063 // SINGLE_ONE = 2
00064 // RANDOM_SIMPLE = 3
00065 // RANDOM_EQUAL_ZEROS_ONES = 4
00066 // PSEUDO_RANDOM = 5
00067 // USER_DEFINED = 6
00068 
00069  
00070 class BitString
00071 {
00072 
00073   // ### Public Methods ####
00074 
00075   public:
00076 
00077   
00078   BitString(ifstream * InFile, RanNumGen *RNG2); 
00079            // Constructor, called by OptSignal object
00080 
00081   BitString(BitString & oBitString); // Copy Constructor 
00082 
00083   BitString(BitString & BitString1,BitString & BitString2,RanNumGen *RNG3);
00084   // Constructor for sum of BitStrings
00085 
00086   friend void AddBitStrings(BitString * BitString1,
00087                             BitString * BitString2,
00088                             BitString * BitString3);
00089 
00090 
00091   BitString & operator=(BitString & RHS_BitString);
00092                   // assignment operator (JZ)
00093 
00094   ~BitString();
00095 
00096   void DeleteMemory(void);
00097   void ReallocateMemory(void);
00098 
00099   string WriteTypeBitString(void);
00100 
00101 
00102   int GetStringLength(void) {return StringLength;};
00103   int GetNumChannels(void) {return NumChannels;};
00104   void SetNumChannels(int value) {NumChannels = value;};
00105 
00106 
00107   int GetChannelPhysicalIndex(int ChannelArrayIndex);
00108   int GetChannelArrayIndex(int ChannelPhysicalIndex);
00109 
00110   void SetBit(int ChannelArrayIndex, int BitSlot, int BitValue); 
00111   int GetBit(int ChannelArrayIndex, int BitSlot); 
00112 
00113   void WriteBitString(void); // For debugging only
00114 
00115   string WriteBitString(int ChannelArrayIndex);
00116 
00117  // The following method can be used in a Monte Carlo simulation application
00118   // to get a new random string for the next MC experiment.
00119   // It will only do this if TypeBitString is one of the  RANDOM 
00120   // types. Otherwise it will not change the bit string at all.
00121 
00122   void GetRandomString();
00123 
00124   void SetAllZeros(int ChannelArrayIndex);
00125   void SetAllOnes(int ChannelArrayIndex);
00126   void SetSingleOne(int ChannelArrayIndex);
00127   
00128   void SetStringToSingleMarkPerChannel(void);
00129 
00130   // An OptDemuxer extracts a single channel signal from a WDM Signal.
00131   // The following method is used by the Demuxer to extract the BitString
00132   // of the extracted single channel signal  from the BitString of the
00133   // WDM Signal
00134   // Before calling this method we assume that the BitString object
00135   // is a multi-channel. The method changes the BitString to be 
00136   // single channel
00137   // In particular the parameter NumChannels is changed from 
00138   // NumChannels to 1 within this method.
00139 
00140   void ReduceToSingleChannelBitString(int ChannelArrayIndex);
00141   void ReduceToSingleChannelBitString(BitString * SCBitString);
00142 
00145   void AddBitStringBM(BitString & BitString2);
00146 
00147 
00148   // ### Private Methods #######
00149 
00150   string ReadString(string ParameterName, ifstream * InFile);
00151 
00152   void SetRandomString(int ChannelArrayIndex);
00153   void SetPseudoRandomString(int ChannelArrayIndex);
00154   void SetUserDefined(ifstream * InFile);
00155 
00156   //##  Allocate/release the bit string array
00157   //#  It is necessary to make conversions from
00158   //#  WDM to single channel in the demuxer. (IL)
00159   void AllocateBitStringArray(int NumChannels2);
00160   void ReleaseBitStringArray(void)
00161      { delete [] BitStringArray;};
00162   
00163   // ### Private Data ####
00164 
00165   private:
00166 
00167   typeBitString TypeBitString;
00168 
00169   int NumChannels;
00170   int StringLength; // Length of bit string in a single channel
00171   int * BitStringArray;  // Pointer to 1D array of length 
00172                         // NumChannels*StringLength which stores the BitStrings
00173                         // for all of the channels. Accessed using the methods
00174                         // SetBitString and GetBitString
00175 
00176   RanNumGen *RNG;
00177 
00178   int DebugLevel;
00179         // Typically debug level will be 1,2,3
00180         // The higher the level the more data is written to LogFile and cout.
00181 
00182 }; // end class BitString
00183 
00184 #endif /* _OCS_BIT_STRING_HH_ */
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 

Generated on Fri Jul 2 2010 12:57:46 for OCS by  doxygen 1.7.1