00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _ID_H
00011 #define _ID_H
00012
00017 class Id
00018 {
00019 public:
00021
00023
00026 Id();
00027
00031 Id( unsigned int id );
00032
00036 Id( const std::string& path, const std::string& separator = "/" );
00037
00041 Id( const ObjId& oi );
00042
00046 ~Id(){}
00047
00049
00051
00052
00053
00059 static Id nextId();
00060
00061
00065 static unsigned int numIds();
00066
00070 void bindIdToElement( Element* e );
00071
00077 void destroy() const;
00078
00080
00082
00085 std::string path( const std::string& separator = "/" ) const;
00086
00087
00105 Element* element() const;
00106
00107
00108
00112 Eref eref() const;
00113
00118 static Id str2Id( const std::string& s );
00119
00123 static std::string id2str( Id id );
00124
00125 unsigned int value() const;
00126
00128
00130 bool operator==( const Id& other ) const {
00131
00132 return id_ == other.id_;
00133 }
00134
00135 bool operator!=( const Id& other ) const {
00136
00137 return id_ != other.id_;
00138 }
00139
00140 bool operator<( const Id& other ) const {
00141
00142
00143 return ( id_ < other.id_ );
00144 }
00145
00146
00147
00148 static bool isValid(Id id)
00149 {
00150 return (id.id_ < elements().size()) && (elements()[id.id_] != 0);
00151 }
00152
00153 static bool isValid(unsigned int id)
00154 {
00155 return (id < elements().size()) && (elements()[id] != 0);
00156 }
00157
00159
00162 static void clearAllElements();
00163
00167 void zeroOut() const;
00169
00170 friend ostream& operator <<( ostream& s, const Id& i );
00171 friend istream& operator >>( istream& s, Id& i );
00172
00173 private:
00174
00175 unsigned int id_;
00176
00177 static vector< Element* >& elements();
00178 };
00179
00180 #endif // _ID_H