#include <Object.h>
Inheritance diagram for Core::Object:
Public Member Functions | |
Object (void) | |
virtual | ~Object (void) |
virtual String * | className (void) const |
Answer receiver class name. | |
virtual void | error (String *message, String *selector=nil, Object *parameter=nil) |
Raise an Error with specified arguments. | |
virtual void | shouldNotImplement (String *selector) |
Raise an Error saying that method should not be implemented. | |
virtual void | shouldNotImplement (const char *selector) |
virtual long | hash (void) const |
Answer object hash value. | |
virtual bool | isEqual (const Object *object) const |
Compare receiver with given object. | |
virtual bool | isEqual (const Object &object) const |
Compare receiver with given object. | |
virtual bool | isEqualToByteArray (const Object *array) const |
virtual bool | operator== (const Object &object) const |
Compare receiver with given object. | |
virtual bool | isIdentical (const Object *object) const |
Answer if the parameter is identical with the receiver. | |
virtual bool | isIdentical (const Object &object) const |
Answer if the parameter is identical with the receiver. | |
virtual void | printOn (Stream *stream) const |
Print object identification into the stream. | |
virtual String * | printString (void) const |
Print object identification. | |
virtual bool | isAssociation (void) const |
Answer if the receiver is an Association. | |
virtual bool | isBoolean (void) const |
Answer if the receiver is a Boolean. | |
virtual bool | isCharacter (void) const |
Answer if the receiver is a Character. | |
virtual bool | isNumber (void) const |
Answer if the receiver is a Number. | |
virtual bool | isString (void) const |
Answer if the receiver is a String. | |
virtual bool | isInstanceOf (String *className) |
Test the receiver to be an instance of class of the given name. | |
virtual bool | isInstanceOf (const char *className) |
Test the receiver to be an instance of class of the given name. | |
virtual void | visitBy (Visitor *visitor) |
Protected Attributes | |
long | oid |
Object ID. |
Every class inherits from this one. It provides some basic features like comparing and testing facilities, simplified exception raising or stream printing.
Object class inherits from gc_cleanup class which provides garbage collecting (using Boehms conservative garbage collecting algorithm).
Definition at line 70 of file Object.h.
|
Definition at line 39 of file Object.cc. References objectCounter, and oid. 00040 { 00041 oid = objectCounter++; 00042 #if defined(DEBUG) && defined(VERBOSE) 00043 fprintf(stderr, "%ld created (%p)\n", oid, this); 00044 #endif 00045 }
|
|
Definition at line 47 of file Object.cc. References oid. 00048 { 00049 #if defined(DEBUG) && defined(VERBOSE) 00050 fprintf(stderr, "%ld destroyed (%p)\n", oid, this); 00051 #endif 00052 }
|
|
|
|
Answer object hash value. The value should be same for objects found equal with isEqual() method. So if you rewrite this method you should rewrite isEqual() method too. Reimplemented in Core::Association, Core::Boolean, Core::ByteArray, Core::Character, Core::Date, Core::Integer, Core::Real, Core::String, Core::Time, Core::Timestamp, and Tools::Filename. Definition at line 78 of file Object.cc. Referenced by Core::Set::findElementOrNil(), and Core::Association::hash(). 00079 { 00080 return (long) this; 00081 }
|
|
Answer if the receiver is an Association.
Reimplemented in Core::Association. Definition at line 131 of file Object.cc. Referenced by Core::Association::isEqual(), Core::KeysAndValuesIterator::key(), and Core::KeysAndValuesIterator::value(). 00132 { 00133 return false; 00134 }
|
|
Answer if the receiver is a Boolean.
Reimplemented in Core::Boolean. Definition at line 136 of file Object.cc. Referenced by Core::Boolean::isEqual(). 00137 { 00138 return false; 00139 }
|
|
Answer if the receiver is a Character.
Reimplemented in Core::Character. Definition at line 141 of file Object.cc. Referenced by Core::String::put(), Core::Stream::skipSeparators(), and Core::Stream::upToSeparator(). 00142 { 00143 return false; 00144 }
|
|
Compare receiver with given object. Do not rewrite this method. It just a sugar for Object::isEqual(Object *).
Reimplemented in Core::Boolean, Core::ByteArray, Core::Character, Core::Date, Core::Integer, Core::Number, Core::Real, Core::String, Core::Time, Core::Timestamp, and Tools::Filename. Definition at line 88 of file Object.cc. References isEqual(). 00089 { 00090 return isEqual(&object); 00091 }
|
|
|
Reimplemented in Core::ByteArray. Definition at line 93 of file Object.cc. Referenced by Core::ByteArray::isEqual(). 00094 { 00095 return false; 00096 }
|
|
Answer if the parameter is identical with the receiver. Do not rewrite this method. It just a sugar for Object::isIdentical(Object *).
Definition at line 108 of file Object.cc. References isIdentical(). 00109 { 00110 return isIdentical(&object); 00111 }
|
|
Answer if the parameter is identical with the receiver. In fact every object is identical only with itself.
Definition at line 103 of file Object.cc. Referenced by isEqual(), and isIdentical(). 00104 { 00105 return this == object; 00106 }
|
|
Test the receiver to be an instance of class of the given name. Do not rewrite this method. It just a sugar for Object::isInstanceOf(String *).
Definition at line 161 of file Object.cc. References isInstanceOf(). 00162 { 00163 return(this->isInstanceOf(new String(className))); 00164 }
|
|
Test the receiver to be an instance of class of the given name.
Definition at line 156 of file Object.cc. References Core::String::isEqual(). Referenced by isInstanceOf(). 00157 { 00158 return(className->isEqual(this->className())); 00159 }
|
|
Answer if the receiver is a Number.
Reimplemented in Core::Number. Definition at line 146 of file Object.cc. Referenced by Core::ByteArray::checkObject(). 00147 { 00148 return false; 00149 }
|
|
Answer if the receiver is a String.
Reimplemented in Core::String. Definition at line 151 of file Object.cc. Referenced by Core::String::isEqual(). 00152 { 00153 return false; 00154 }
|
|
Compare receiver with given object. By default this calls isEqual() method. But some classes (numbers) may overload it to avoid type matching. Definition at line 98 of file Object.cc. References isEqual(). 00099 { 00100 return isEqual(&object); 00101 }
|
|
Print object identification into the stream. Object identification is formed from its className() by default. But complicated classes (eg. collections) may print some other information.
Reimplemented in Core::Association, Core::Boolean, Core::Character, Core::Collection, Core::Date, Core::Integer, Net::IPSocketAddress, Net::URL, Core::Real, Core::String, Core::Time, Core::Timestamp, and Tools::Configuration. Definition at line 114 of file Object.cc. References className(), Core::SequenceableCollection::first(), and Core::Stream::nextPutAll(). Referenced by Tools::Application::defaultExceptionHandler(), and printString(). 00115 { 00116 String *title = className(); // self class printString 00117 if (((Character *) title->first())->isVowel()) 00118 stream->nextPutAll("an "); 00119 else stream->nextPutAll("a "); 00120 stream->nextPutAll(title); 00121 }
|
|
Print object identification.
Definition at line 123 of file Object.cc. References Core::WriteStream::contents(), and printOn(). Referenced by Core::ExternalWriteStream::closeConnection(). 00124 { 00125 WriteStream stream(new String(16)); 00126 printOn(&stream); 00127 return (String *) stream.contents(); 00128 }
|
|
Definition at line 72 of file Object.cc. References shouldNotImplement(). 00073 { 00074 shouldNotImplement(new String(selector)); 00075 }
|
|
Raise an Error saying that method should not be implemented. This is called in situation when the method has no sense in the class but has to be implemented somehow (eg. to break class abstraction).
Definition at line 67 of file Object.cc. References error(). Referenced by Core::String::add(), Core::ByteArray::add(), Core::Array::add(), Core::SequenceableCollection::asByteArray(), Core::SequenceableCollection::asString(), Core::IOAccessor::changeDescriptorTo(), Core::Callback< void >::execute(), Core::Callback< Object * >::execute(), Core::ReadStream::flush(), Core::WriteStream::next(), Core::ExternalWriteStream::next(), Core::ReadStream::nextPut(), Core::ExternalReadStream::nextPut(), Core::SequenceableCollection::remove(), Core::Dictionary::remove(), OS::UnixPipe::seekTo(), Net::SocketAccessor::seekTo(), OS::MessageQueue::seekTo(), and shouldNotImplement().
|
|
Reimplemented in Core::Association, Core::Boolean, Core::Character, Core::Collection, Core::Dictionary, Core::GenericException, Core::Number, and Core::String. Definition at line 167 of file Object.cc. References Core::Visitor::visitObject(). 00168 { 00169 visitor->visitObject(this); 00170 }
|
|
Object ID. Every object got its unique number. |