Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Core::Boolean Class Reference

Bool type wrapper. More...

#include <Boolean.h>

Inheritance diagram for Core::Boolean:

Inheritance graph
[legend]
Collaboration diagram for Core::Boolean:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Boolean (bool val)
 operator bool (void)
 Answer value converted to C++ type bool.
virtual StringclassName (void) const
 Answer receiver class name.
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 isEqual (bool cBool) const
virtual void printOn (Stream *stream) const
 Print object identification into the stream.
virtual bool isBoolean (void) const
 Answer if the receiver is a Boolean.
virtual void visitBy (Visitor *visitor)

Static Public Attributes

static Boolean True
static Boolean False

Protected Attributes

bool value
 Value of Boolean object.

Detailed Description

Bool type wrapper.

Definition at line 36 of file Boolean.h.


Constructor & Destructor Documentation

Boolean::Boolean bool  val  ) 
 

Definition at line 34 of file Boolean.cc.

References value.

00035 {
00036     value = val;
00037 }


Member Function Documentation

String * Boolean::className void   )  const [virtual]
 

Answer receiver class name.

Because there isn't any standard way to obtain class name this method comes to place.

Every class should rewrite this method but many didn't (yet).

Reimplemented from Core::Object.

Definition at line 45 of file Boolean.cc.

00046 {
00047     return new String("Boolean");
00048 }

long Boolean::hash void   )  const [virtual]
 

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 from Core::Object.

Definition at line 51 of file Boolean.cc.

References value.

00052 {
00053     return value ? 1 : 0;
00054 }

bool Boolean::isBoolean void   )  const [virtual]
 

Answer if the receiver is a Boolean.

Reimplemented from Core::Object.

Definition at line 74 of file Boolean.cc.

00075 {
00076     return true;
00077 }

bool Boolean::isEqual bool  cBool  )  const [virtual]
 

Definition at line 62 of file Boolean.cc.

References value.

00063 {
00064     return value == cBool;
00065 }

virtual bool Core::Boolean::isEqual const Object object  )  const [inline, virtual]
 

Compare receiver with given object.

Do not rewrite this method. It just a sugar for Object::isEqual(Object *).

  • object - object to compare receiver with

Reimplemented from Core::Object.

Definition at line 60 of file Boolean.h.

References Core::Object::isEqual().

00061       { return Object::isEqual(object); }

bool Boolean::isEqual const Object object  )  const [virtual]
 

Compare receiver with given object.

This method could compare objects with more sophisticated algorithm (eg. based on instance variables comparing or so).

If you rewrite this method you should rewrite hash() too.

  • object - object to compare receiver with

Reimplemented from Core::Object.

Definition at line 56 of file Boolean.cc.

References Core::Object::isBoolean(), and value.

00057 {
00058     return object->isBoolean() &&
00059            value == ((Boolean *) object)->value;
00060 }

Boolean::operator bool void   ) 
 

Answer value converted to C++ type bool.

Definition at line 39 of file Boolean.cc.

References value.

00040 {
00041     return value;
00042 }

void Boolean::printOn Stream stream  )  const [virtual]
 

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.

  • stream - stream to print to.

Reimplemented from Core::Object.

Definition at line 68 of file Boolean.cc.

References Core::Stream::nextPutAll(), and value.

00069 {
00070     stream->nextPutAll(value ? "true" : "false");
00071 }

void Boolean::visitBy Visitor visitor  )  [virtual]
 

Reimplemented from Core::Object.

Definition at line 80 of file Boolean.cc.

References Core::Visitor::visitBoolean().

00081 {
00082     visitor->visitBoolean(this);
00083 }


Member Data Documentation

Boolean Boolean::False [static]
 

Boolean Boolean::True [static]
 

bool Core::Boolean::value [protected]
 

Value of Boolean object.

The value must not be equal to Boolean::True or Boolean::False. So identity comparation can fail. Use isEqual() instead.

Definition at line 43 of file Boolean.h.

Referenced by Boolean(), hash(), isEqual(), operator bool(), and printOn().


The documentation for this class was generated from the following files:
Generated on Mon Nov 27 09:51:07 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2