Class Class Reference

Class that provides run-time type information More...

List of all members.

Public Member Functions

 Class (const char *name, int id, const Class *superclass)
 Constructor.
const char * name () const
 Gets the class name.
int id () const
 Gets the class ID.
const bool isA (int id) const
 Checks the type of an object by ID.
const bool isA (const char *name) const
 Checks the type of an object by name.
const Classsuperclass () const
 Gets a pointer to the superclass.

Protected Attributes

const char *const mName
 Class name
const int mId
 Class ID
const Class *const mSuperclass
 Pointer to the superclass instance.


Detailed Description

Class provides run-time type information for objects in Hunny MIME++. All subclasses of Node contain a pointer to an instance of Class. You may call Node::class_() to obtain a reference to that instance.

The following code example shows how you can check the type of an object at run-time:

    void CheckType(Node* node) {
         if (node->class_().isA(mimepp::MESSAGE_CLASS)) {
             // ...
         }
         else if (node->class_().isA(mimepp::BODY_PART_CLASS)) {
             // ...
         }
     } 

The enumerated type IDs are listed in the mimepp.h header file.


Constructor & Destructor Documentation

Class ( const char *  name,
int  id,
const Class superclass 
) [inline]

Constructor.

Parameters:
name name of the class
id ID of the class
superclass pointer to the superclass of the class


Member Function Documentation

int id (  )  const [inline]

Gets the class ID.

The enumerated type IDs are listed in the mimepp.h header file.

Returns:
ID of the class

const bool isA ( const char *  name  )  const

Returns true if the object associated with this Class instance is of type name.

Parameters:
name name of a class

const bool isA ( int  id  )  const

Returns true if the object associated with this Class instance is of type id.

Parameters:
id ID of a class

const char * name (  )  const [inline]

Gets the class name.

Returns:
name of the class

const Class * superclass (  )  const [inline]

Gets the Class instance associated with the superclass of a class.

This member function returns a pointer that may be NULL. (The pointer is NULL if there is no superclass.)

Returns:
superclass

Copyright © 2001-2009 Hunny Software, Inc. All rights reserved.