container_test::Person Class Reference

A type of Entity that represents a person. More...

#include <person.h>

Inheritance diagram for container_test::Person:

Inheritance graph
[legend]
Collaboration diagram for container_test::Person:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Person (string firstName, string lastName)
 Person (const Person &orig)
virtual ~Person ()
string getFirstName ()
void setFirstName (string name)
string getLastName ()
void setLastName (string name)
virtual int compareKeyTo (const Entity &second) const
 Compare this Entity with second.
virtual const InfotypeInfo () const
 Return the instance of Object::Info that describes the class of this object.
virtual Objectclone (bool deepCopy=false) const
 A polymorphic copy constructor.

Static Public Attributes

static const Info *const TYPE_INFO = Object::typeInfoFactory("Person")

Protected Member Functions

virtual string * generateKeyAsString () const

Private Member Functions

 Person ()

Private Attributes

string firstName
string lastName


Detailed Description

A type of Entity that represents a person.

Person is used to test SortedLinkedList and also provides an example of how to create a sub-class of Entity. The Person class' implementation of compareKeyTo results in an alphabetical sort order by last name, using the first name as a tie breaker.


Constructor & Destructor Documentation

container_test::Person::Person (  )  [private]

00047 { }

Here is the caller graph for this function:

container_test::Person::Person ( string  firstName,
string  lastName 
)

00049                                                  : firstName(first_Name),
00050 lastName(last_Name) { }

container_test::Person::Person ( const Person orig  ) 

00052                                 : Entity(orig), firstName(orig.firstName),
00053 lastName(orig.lastName) { }

container_test::Person::~Person (  )  [virtual]

00055 { }


Member Function Documentation

Object * container_test::Person::clone ( bool  deepCopy = false  )  const [virtual]

A polymorphic copy constructor.

Reimplemented from container::Entity.

00110                                          {
00111    // Alwasy does a deep copy. 
00112    return new Person(*this);
00113 }

Here is the call graph for this function:

int container_test::Person::compareKeyTo ( const Entity second  )  const [virtual]

Compare this Entity with second.

Used to determine the sort order of a collection of Entity objects. Sub-classes should override compareKeyTo to provide their own concept of less-than, equal, and greater-than. This method is used by Container classes to sort Entity objects and to determine whether two instances are duplicates.

Returns:
An integer less than zero if: this < second

Zero if: this == second

An integer greater than zero if: this > second

Precondition:
second is the same type as this Entity
Postcondition:
Neither Entity has changed state

Reimplemented from container::Entity.

00079                                                    {
00080    if (&second == NULL) {
00081       return COMPARE_KEY_TO_NULL_RVAL;
00082    }
00083 
00084    int delta = typeInfo()->typeName.compare(second.typeInfo()->typeName);
00085    if (delta != 0) {
00086       return delta;
00087    }
00088 
00089    const Person& p2 = (Person&)second;
00090    delta = lastName.compare(p2.lastName);
00091    if (delta != 0) {
00092       return delta;
00093    }
00094 
00095    return firstName.compare(p2.firstName);
00096 }

Here is the call graph for this function:

string * container_test::Person::generateKeyAsString (  )  const [protected, virtual]

Reimplemented from container::Entity.

00100                                           {
00101    return new string(firstName + " " + lastName);
00102 }

string container_test::Person::getFirstName (  ) 

00059                             {
00060    return firstName;
00061 }

Here is the caller graph for this function:

string container_test::Person::getLastName (  ) 

00068                            {
00069    return lastName;
00070 }

void container_test::Person::setFirstName ( string  name  ) 

00063                                      {
00064    firstName = name;
00065    invalidateKeyAsString();
00066 }

Here is the call graph for this function:

Here is the caller graph for this function:

void container_test::Person::setLastName ( string  name  ) 

00072                                     {
00073    lastName = name;
00074    invalidateKeyAsString();
00075 }

Here is the call graph for this function:

const Object::Info * container_test::Person::typeInfo (  )  const [virtual]

Return the instance of Object::Info that describes the class of this object.

Instantiation of Object::Info is controlled by the protected method Object::typeInfoFactory(const string&). Each sub-class of Object should create one and only one instance of Object::Info.

Reimplemented from container::Entity.

00106                                          {
00107    return TYPE_INFO;
00108 }

Here is the caller graph for this function:


Member Data Documentation

const Object::Info *const container_test::Person::TYPE_INFO = Object::typeInfoFactory("Person") [static]

Reimplemented from container::Entity.


The documentation for this class was generated from the following files:

Generated on Tue Jun 16 23:13:03 2009 by  doxygen 1.5.9