00001 // -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 00002 // 00003 // Time-stamp: <2000-09-15 12:53:08 haoboy> 00004 // 00005 // Copyright (c) 2000 by the University of Southern California 00006 // All rights reserved. 00007 // 00008 // Permission to use, copy, modify, and distribute this software and its 00009 // documentation in source and binary forms for non-commercial purposes 00010 // and without fee is hereby granted, provided that the above copyright 00011 // notice appear in all copies and that both the copyright notice and 00012 // this permission notice appear in supporting documentation. and that 00013 // any documentation, advertising materials, and other materials related 00014 // to such distribution and use acknowledge that the software was 00015 // developed by the University of Southern California, Information 00016 // Sciences Institute. The name of the University may not be used to 00017 // endorse or promote products derived from this software without 00018 // specific prior written permission. 00019 // 00020 // THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about 00021 // the suitability of this software for any purpose. THIS SOFTWARE IS 00022 // PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, 00023 // INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 00024 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00025 // 00026 // Other copyrights might apply to parts of this software and are so 00027 // noted when applicable. 00028 // 00029 // Address parameters. Singleton class 00030 // 00031 // $Header: /nfs/jade/vint/CVSROOT/ns-2/routing/addr-params.h,v 1.3 2001/02/01 22:59:58 haldar Exp $ 00032 00033 #ifndef ns_addr_params_h 00034 #define ns_addr_params_h 00035 00036 #include <tclcl.h> 00037 00038 class AddrParamsClass : public TclClass{ 00039 public: 00040 // XXX Default hlevel_ to 1. 00041 AddrParamsClass() : TclClass("AddrParams"), 00042 hlevel_(1), NodeMask_(NULL), 00043 NodeShift_(NULL) { 00044 instance_ = this; 00045 } 00046 virtual TclObject* create(int, const char*const*) { 00047 Tcl::instance().add_errorf("Cannot create instance of " 00048 "AddrParamsClass"); 00049 return NULL; 00050 } 00051 virtual void bind(); 00052 virtual int method(int ac, const char*const* av); 00053 00054 static inline AddrParamsClass& instance() { return *instance_; } 00055 00056 inline int mcast_shift() { return McastShift_; } 00057 inline int mcast_mask() { return McastMask_; } 00058 inline int port_shift() { return PortShift_; } 00059 inline int port_mask() { return PortMask_; } 00060 inline int node_shift(int n) { return NodeShift_[n]; } 00061 inline int node_mask(int n) { return NodeMask_[n]; } 00062 inline int hlevel() { return hlevel_; } 00063 inline int nodebits() { return nodebits_; } 00064 00065 private: 00066 int McastShift_; 00067 int McastMask_; 00068 int PortShift_; 00069 int PortMask_; 00070 int hlevel_; 00071 int *NodeMask_; 00072 int *NodeShift_; 00073 int nodebits_; 00074 static AddrParamsClass *instance_; 00075 }; 00076 00077 #endif // ns_addr_params_h
1.3.3