I3Identifier.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00025 #ifndef __I3IDENTIFIER_H__
00026 #define __I3IDENTIFIER_H__
00027 
00028 #include <omnetpp.h>
00029 #include <OverlayKey.h>
00030 
00037 #define DEFAULT_PREFIX_LENGTH   160
00038 #define DEFAULT_KEY_LENGTH      256
00039 
00040 class I3Identifier {
00041 public:
00043     I3Identifier();
00044 
00048     I3Identifier(unsigned char b);
00049 
00054     I3Identifier(int prefixL, int keyL);
00055 
00059     I3Identifier(const I3Identifier& id);
00060 
00064     I3Identifier(std::string s);
00065 
00067     int getKeyLength() const;
00068 
00070     int getPrefixLength() const;
00071 
00073     void clear();
00074 
00076     int compareTo(const I3Identifier&) const;
00077 
00079     bool operator <(const I3Identifier&) const;
00080 
00082     bool operator >(const I3Identifier&) const;
00083 
00085     bool operator ==(const I3Identifier&) const;
00086 
00088     I3Identifier &operator =(const I3Identifier&);
00089 
00091     bool isClear();
00092 
00096     bool isMatch(const I3Identifier& id) const;
00097 
00107     int distanceTo(const I3Identifier& id) const;
00108 
00113     void createFromHash(const std::string &s, const std::string &o = "");
00114 
00115     void createRandomKey();
00116     void createRandomPrefix();
00117     void createRandomSuffix();
00118 
00119     int length() const;
00120 
00125     OverlayKey asOverlayKey() const;
00126 
00127     void setName(std::string s);
00128     std::string getName();
00129 
00135     friend std::ostream& operator<<(std::ostream& os, const I3Identifier& id);
00136 
00138     ~I3Identifier();
00139 
00140 protected:
00142     unsigned char *key;
00143 
00145     unsigned short prefixLength;
00146 
00148     unsigned short keyLength;
00149 
00150     std::string name;
00151 
00156     void initKey(int prefixL, int keyL);
00157 };
00158 
00159 #endif
00160 
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3