Main Page   Namespace List   Compound List   File List   Compound Members   File Members  

copy-ocsBitString.hh

Go to the documentation of this file.
00001 // $Id: ocsBitString.hh,v 1.14 2002/04/29 20:10:51 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 
00116  // The following method can be used in a Monte Carlo simulation application
00117   // to get a new random string for the next MC experiment.
00118   // It will only do this if TypeBitString is one of the  RANDOM 
00119   // types. Otherwise it will not change the bit string at all.
00120 
00121   void GetRandomString();
00122 
00123   void SetAllZeros(int ChannelArrayIndex);
00124   void SetAllOnes(int ChannelArrayIndex);
00125   void SetSingleOne(int ChannelArrayIndex);
00126   
00127   void SetStringToSingleMarkPerChannel(void);
00128 
00129   // An OptDemuxer extracts a single channel signal from a WDM Signal.
00130   // The following method is used by the Demuxer to extract the BitString
00131   // of the extracted single channel signal  from the BitString of the
00132   // WDM Signal
00133   // Before calling this method we assume that the BitString object
00134   // is a multi-channel. The method changes the BitString to be 
00135   // single channel
00136   // In particular the parameter NumChannels is changed from 
00137   // NumChannels to 1 within this method.
00138 
00139   void ReduceToSingleChannelBitString(int ChannelArrayIndex);
00140   void ReduceToSingleChannelBitString(BitString * SCBitString);
00141 
00142 
00143   // ### Private Methods #######
00144 
00145   string ReadString(string ParameterName, ifstream * InFile);
00146 
00147   void SetRandomString(int ChannelArrayIndex);
00148   void SetPseudoRandomString(int ChannelArrayIndex);
00149   void SetUserDefined(ifstream * InFile);
00150 
00151   //##  Allocate/release the bit string array
00152   //#  It is necessary to make conversions from
00153   //#  WDM to single channel in the demuxer. (IL)
00154   void AllocateBitStringArray(int NumChannels2);
00155   void ReleaseBitStringArray(void)
00156      { delete [] BitStringArray;};
00157   
00158   // ### Private Data ####
00159 
00160   private:
00161 
00162   typeBitString TypeBitString;
00163 
00164   int NumChannels;
00165   int StringLength; // Length of bit string in a single channel
00166   int * BitStringArray;  // Pointer to 1D array of length 
00167                         // NumChannels*StringLength which stores the BitStrings
00168                         // for all of the channels. Accessed using the methods
00169                         // SetBitString and GetBitString
00170 
00171   RanNumGen *RNG;
00172 
00173   int DebugLevel;
00174         // Typically debug level will be 1,2,3
00175         // The higher the level the more data is written to LogFile and cout.
00176 
00177 }; // end class BitString
00178 
00179 #endif /* _OCS_BIT_STRING_HH_ */
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 

Generated at Mon Jun 9 20:08:09 2003 for OCS by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000