Jive reference manual
List of all members | Public Member Functions | Static Public Member Functions
jem::Object Class Reference

Provides a single superclass for many classes in jem. More...

#include <jem/base/Object.h>

Inherits jem::Collectable.

Inherited by jem::Boolean, jem::Character, jem::gl::Attributes, jem::gl::ColorMap, jem::gl::Controller, jem::gl::ErrorHandler, jem::gl::EventHandler, jem::gl::FrameGrabber, jem::gl::GfxError, jem::gl::GLSetup, jem::gl::GraphViewer, jem::gl::MarkerStyle, jem::gl::Menu, jem::gl::Orb, jem::gl::OSContext, jem::gl::Palette, jem::gl::Transformer, jem::gl::VertexSet, jem::gl::Viewer, jem::hdf5::H5File, jem::hdf5::H5Object, jem::io::DirListing, jem::io::FileStream, jem::io::InputStream, jem::io::Logger, jem::io::OutputStream, jem::io::Pipe, jem::io::Reader, jem::io::TermReader, jem::io::Writer, jem::mp::Context, jem::mp::Driver, jem::mp::DriverFactory, jem::mp::Request, jem::mp::RequestList, jem::mp::SyncTimer, jem::mp::Task, jem::mt::WorkPool, jem::mt::WorkPool::Job, jem::mt::WorkPool::Task, jem::NamedObject, jem::Number, jem::numeric::Function, jem::Process, jem::StringObject, jem::Thread, jem::util::Calendar, jem::util::Enumerator, jem::util::ObjectCollection, jem::util::ObjectConverter, jem::util::ObjectPair, jem::util::Tokenizer, jem::xml::DOMElement, jem::xml::ParseLog, jem::xml::Parser, jem::xml::Tokenizer, jive::algebra::AbstractMatrix, jive::algebra::ConDistiller, jive::algebra::VectorSpace, jive::app::CmdCompleter, jive::app::GroupConverter, jive::app::ProgramArgs, jive::fem::Boundary, jive::fem::BoundaryManager, jive::fem::Element, jive::fem::FEIterator, jive::fem::InternalBoundary, jive::fem::MeshBlock, jive::fem::MeshCutter, jive::geom::BoxManager, jive::geom::MaskMatrix, jive::geom::Shape, jive::gl::ColorField, jive::gl::GfxMesh, jive::gl::GfxMesher, jive::gl::GfxShape, jive::gl::MarkerStyleTable, jive::gl::PaletteTable, jive::gl::ShapeMapper, jive::gl::VectorField, jive::graph::Partition, jive::graph::PartitionControl, jive::mbody::SurfaceUpdater, jive::mesh::StripMesher, jive::mp::DataExchanger, jive::mp::ItemMask, jive::mp::TableExchanger, jive::mp::VectorExchanger, jive::solver::Solver, jive::util::Constraints, jive::util::DofSpace, jive::util::GroupConverter, jive::util::ItemGroup, jive::util::ItemMap, jive::util::ItemSet, jive::util::ParserScope, and jive::util::VectorManager.

Public Member Functions

virtual ClassgetClass () const
 Returns the Class instance representing the runtime class of this object. More...
 
virtual String toString () const
 Returns a short textual description of this object. More...
 
virtual long hashValue () const
 Returns a hash value for this object. More...
 
virtual bool equals (const Ref< Object > &obj) const
 Tests whether two objects are equal. More...
 
Ref< Objectclone () const
 Returns a copy of this object. More...
 

Static Public Member Functions

static ClassgetType ()
 Returns the Class instance representing the Object class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from jem::Collectable
 Collectable ()
 Creates an empty Collectable. More...
 
 ~Collectable ()
 Frees resources. More...
 

Detailed Description

Many classes in jem are directly or indirectly derived from the class Object. It can therefore be used to implement heterogeneous data structures and generic algorithms. For instance, a list containing Object instances can be used to store instances of all classes derived from the Object class.

Because the Object class is not the superclass of all classes, Jem provides two non-member functions that can be used to convert non-Object instances to Object instances and the other way around. These two functions, named toObject() and toValue(), mimick the boxing/unboxing mechanism provided by the C# programming language.

The Object class in jem is comparable with the Object class in Java.

Note
Since Object is derived from Collectable, all Object instances are subjected to automatic garbage collection. This is also true for all classes derived from Object.
Examples:
Event.cpp.

Member Function Documentation

static Class* jem::Object::getType ( )
static

Returns a pointer to the Class instance representing the Object class. This pointer is valid during the entire lifetime of the program. The getType method should be overloaded by all classes that are represented by a different Class object.

Returns
A pointer to the Class instance representing the Object class.
See also
Class, ClassTemplate.
virtual Class* jem::Object::getClass ( ) const
virtual

Returns a pointer to the Class instance representing the runtime class of this object. If T denotes the runtime class of this object, then this function is equivalent with T::getType(). The pointer is valid during the entire lifetime of the program.

Returns
A pointer to the Class instance representing the runtime class of this object.

Reimplemented in jive::geom::Shape, jive::geom::InternalShape, jive::algebra::SparseMatrix, jive::geom::BoundaryShape, jive::algebra::AbstractMatrix, jive::solver::Solver, jem::util::HashDictionary, jem::util::Enumerator, jem::util::Dictionary, jem::util::ObjectCollection, and jem::util::DictionaryEnumerator.

virtual String jem::Object::toString ( ) const
virtual
virtual long jem::Object::hashValue ( ) const
virtual

Returns a hash value for this object. This function should return the same hash value when it is invoked more than once on the same object, provided that the object is not modified. If two object are equal according to the equals method, then those objects should return the same hash value. Note that two objects which are not equal may also return the same hash value.

The hashValue implementation of the Object class returns a hash value for the memory address of the object.

Returns
A long integer representing the hash value of this object.

Reimplemented in jem::util::Calendar, jem::Float, jem::Integer, jem::Character, jem::Boolean, jem::StringObject, and jem::util::ObjectPair.

virtual bool jem::Object::equals ( const Ref< Object > &  obj) const
virtual

Tests whether this Object is equal to the Object obj. The equals method should be:

  • reflexive: for all objects x, x->equals(x) should return true.
  • symmetric: for all objects x and y, x->equals(y) should return the same value as y->equals(x).
  • transitive: if, for any objects x, y, and z, x->equals(y) returns true and y->equals(z) returns true, then x->equals(z) should return true.
  • consistent: for all objects x and y, multiple invocations of x->equals(y) should return the same value as long as the objects are not modified.

In addition, x->equals(NIL) should return false for all objects x.

The default implementation of equals returns true if and only if this object and the argument obj are located at the same memory address. That is, the default implementation returns (this == obj).

Parameters
obj- the object this object should be compared to, or NIL.
Returns
true is this object equals the object obj, and false otherwise.

Reimplemented in jem::util::Calendar, jem::Float, jem::Integer, jem::Character, jem::Boolean, jem::StringObject, and jem::util::ObjectPair.

Ref<Object> jem::Object::clone ( ) const

If this object implements the Clonable interface, this function calls the clone method corresponding with the runtime class of this object. Otherwise, an exception is thrown.

Returns
A reference to a copy of this object.
Exceptions
IllegalOperationException- if this object does not implement the Clonable interface.