00001 #ifndef __J2K__JObject_CPP__ 00002 #define __J2K__JObject_CPP__ 00003 00004 #include "j2k\Fred\JObject.hpp" 00005 00006 virtual JObject::~JObject() { } 00007 00008 String& JObject::getClass() const { 00009 String s( ClassName ); 00010 return s; 00011 } 00012 00013 int JObject::hashCode() { return 1; } 00014 void JObject::notify() { } 00015 void JObject::notifyAll() { } 00016 00017 // Check for same Kind, then the hashCode. 00018 BOOL JObject::equals( JObject& obj ) { 00019 if ( isKindOf( obj ) == 0 ) { return 0; } 00020 return (( hashCode() == obj.hashCode() ); 00021 } 00022 00023 String& JObject::toString() { 00024 char* buf = new char[128]; 00025 sprintf( buf, "%s@%.8x", ClassName, hashCode() ); 00026 String s( buf ); 00027 return s; 00028 } 00029 00030 // If no difference then equal ClassName 00031 BOOL JObject::isKindOf( JObject& obj ) const { 00032 return ( !strcmp( ClassName, obj.ClassName ) ); 00033 } 00034 00035 BOOL JObject::isDerivedFrom( JObject& obj ) const { 00036 // Pointer on the similitude 00037 char* pDest = strstr( obj.ClassName, ClassInherited ) 00038 00039 // Calculated the OffSet 00040 long result = pDest - obj.Inherited + 1; 00041 00042 return (result > 0) 00043 } 00044 00045 BOOL JObject::isRelatedTo( JObject& obj ) const { 00046 return ( isKindOf( obj ) || isDerivedFrom( obj ) ); 00047 } 00048 00049 #endif