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

nixvec.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2000 University of Southern California.
00003  * All rights reserved.                                            
00004  *                                                                
00005  * Redistribution and use in source and binary forms are permitted
00006  * provided that the above copyright notice and this paragraph are
00007  * duplicated in all such forms and that any documentation, advertising
00008  * materials, and other materials related to such distribution and use
00009  * acknowledge that the software was developed by the University of
00010  * Southern California, Information Sciences Institute.  The name of the
00011  * University may not be used to endorse or promote products derived from
00012  * this software without specific prior written permission.
00013  * 
00014  * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
00015  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00016  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017  *
00018  *
00019  * Support for NixVector routing
00020  * contributed to ns from 
00021  * George F. Riley, Georgia Tech, Spring 2000
00022  */
00023 
00024 #ifndef __NIXVEC_H__
00025 #define __NIXVEC_H__
00026 
00027 #include <utility>  // for pair
00028 #ifdef WIN32
00029 #include <pair.h>   // for MSVC 6.0 that doens't have a proper <utility>
00030 #endif /* WIN32 */
00031 
00032 // Define a type for the neighbor index
00033 typedef unsigned long Nix_t;
00034 typedef unsigned long Nixl_t; // Length of a NV
00035 const   Nix_t NIX_NONE = 0xffffffff;    // If not a neighbor
00036 const   Nixl_t NIX_BPW = 32;            // Bits per long word
00037 typedef pair<Nix_t,  Nixl_t> NixPair_t; // Index, bits needed
00038 typedef pair<Nix_t*, Nixl_t> NixpPair_t;// NV Pointer, length
00039 
00040 
00041 // The variable length neighbor index routing vector
00042 class NixVec {
00043   public :
00044     NixVec () : m_pNV(0), m_used(0), m_alth(0) { };
00045     NixVec(NixVec*);              // Construct from existing
00046     ~NixVec();                    // Destructor
00047     void   Add(NixPair_t);        // Add bits to the nix vector
00048     Nix_t  Extract(Nixl_t);       // Extract the specified number of bits
00049     Nix_t  Extract(Nixl_t, Nixl_t*); // Extract using external "used"
00050     NixpPair_t Get(void);         // Get the entire nv
00051     void   Reset();               // Reset used to 0
00052     Nixl_t Lth();                 // Get length in bits of allocated
00053     void   DBDump();              // Debug..print it out
00054     Nixl_t ALth() { return m_alth;} // Debug...how many bits actually used
00055     static Nixl_t GetBitl(Nix_t); // Find out how many bits needed
00056   private :
00057     Nix_t* m_pNV;  // Points to variable lth nixvector (or actual if l == 32)
00058   //    Nixl_t m_lth;  // Length of this nixvector (computed from m_alth)
00059     Nixl_t m_used; // Used portion of this nixvector
00060     Nixl_t m_alth; // Actual length (largest used)
00061 };
00062 
00063 #endif

Generated on Tue Apr 20 12:14:25 2004 for NS2.26SourcesOriginal by doxygen 1.3.3