/*!
@header FTReferenceImpl
@abstract Module of FT
@availability OS X, GNUstep
@copyright 2004, 2005, 2006 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-------------------------------------------------------------------------
Modification history
30.08.05 ola initial version
23.08.06 ola license changed
-------------------------------------------------------------------------
*/
#include
#include
@implementation FTReferenceImpl
- initWithNodeId: (id ) aNodeId edgeId: (id ) anEdgeId {
self = [super init];
if( nil == aNodeId || nil == anEdgeId ) {
[[[ECIllegalArgumentException alloc]
initWithArgumentInfo: @"FTReferenceImpl::initWithNodeId: Either nodeId "\
"nor edgeId may equal nil!"] raise];
}
self->nodeId = [aNodeId retain];
self->edgeId = [anEdgeId retain];
return self;
}
- (void) dealloc {
[self->nodeId release];
[self->edgeId release];
[super dealloc];
}
/* Method used for comparison: */
- (BOOL) isEqual: (id) anObject {
BOOL to_return = NO;
if( nil != anObject ) {
if( [anObject isKindOfClass: [self class]] ) {
if( [self->nodeId isEqual: [anObject nodeId]] ) {
to_return = [self->edgeId isEqual: [anObject edgeId]];
}
}
}
return to_return;
}
- (unsigned) hash {
unsigned to_return;
NSString *hashStr = [[NSString alloc]
initWithFormat: @"%u%u", [self->nodeId hash], [self->edgeId hash]];
to_return = [hashStr hash];
[hashStr release];
return to_return;
}
/* NSCoding protocol: */
- (id) initWithCoder: (NSCoder *) decoder {
self->nodeId = nil;
self->edgeId = nil;
NS_DURING
self->nodeId = [[decoder decodeObject] retain];
self->edgeId = [[decoder decodeObject] retain];
NS_HANDLER
if( nil != self->nodeId ) {
[self->nodeId release];
}
if( nil != self->edgeId ) {
[self->edgeId release];
}
[localException raise];
NS_ENDHANDLER
return self;
}
- (NSString *) description {
return [[NSString alloc] initWithFormat: @"{FTReferenceImpl, nodeId=%@, "\
"edgeId=%@}", [self->nodeId description], [self->edgeId description]];
}
- (void) encodeWithCoder: (NSCoder *) encoder {
[encoder encodeObject: self->nodeId];
[encoder encodeObject: self->edgeId];
}
- (id ) nodeId {
return self->nodeId;
}
- (id ) edgeId {
return self->edgeId;
}
@end