home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
g
/
gina15.zip
/
demos
/
Address.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-27
|
9KB
|
248 lines
// This may look like C code, but it is really -*- C++ -*-
// Module : Address.C Version 1.8
// LastSCCS : 7/29/91 18:00:03
// LastEdit : "Thu Mar 7 10:53:21 1991"
// Description :
// Author :
// Copyright : GMD Schloss Birlinghoven
#include "Address.h"
#include "ArrayOb.h"
#include "nihclIO.h"
#define THIS Address
#define BASE Object
#define BASE_CLASSES BASE::desc()
#define MEMBER_CLASSES String::desc(), String::desc(), String::desc(), \
String::desc(), String::desc(), String::desc(), \
String::desc(), String::desc(), String::desc(), \
String::desc(), Date::desc(), Date::desc(), \
Integer::desc()
#define VIRTUAL_BASE_CLASSES
DEFINE_CLASS(Address,1,"@(#)Address.C 1.8 7/29/91",NULL,NULL);
bool Address::operator==(const Address& a) const
// Test two instances of Address for equality
{
return (*the_last_name == *a.the_last_name)
&& (*the_first_names == *a.the_first_names)
&& (*the_street == *a.the_street)
&& (*the_house_number == *a.the_house_number)
&& (*the_country_code == *a.the_country_code)
&& (*the_city_code == *a.the_city_code)
&& (*the_city == *a.the_city)
&& (*the_local_area == *a.the_local_area)
&& (*the_telephone == *a.the_telephone)
&& (*the_email == *a.the_email)
&& (*the_creation_date == *a.the_creation_date)
&& (*the_last_modified == *a.the_last_modified)
&& (the_key_number->value() == a.the_key_number->value());
}
const Class* Address::species() const
// Return a pointer to the descriptor of the species of this class
{
return &classDesc;
}
bool Address::isEqual(const Object& p) const
// Test two objects for equality
{
return p.isSpecies(classDesc) && *this==castdown(p);
}
unsigned Address::hash() const
// If two objects are equal (i.e., isEqual) they must have
// the same hash
{
return the_last_name->hash() ^ the_first_names->hash() ^
the_street->hash() ^ the_house_number->hash() ^
the_country_code->hash() ^ the_city_code->hash() ^
the_city->hash() ^ the_local_area->hash() ^
the_telephone->hash() ^ the_email->hash() ^
the_creation_date->hash() ^ the_last_modified->hash() ^
the_key_number->hash();
}
#define DO_COMPARE_MEMBER(m, obj) { int r = m->compare(*(obj.m)); \
if(r) return(r);}
int Address::compare(const Object& p) const
// Compare two objects. If *this > p return >0,
// *this == p return 0, and if *this < p return <0.
{
assertArgSpecies(p,classDesc,"compare");
const Address & the_obj = (const Address &)p;
DO_COMPARE_MEMBER(the_last_name, the_obj);
DO_COMPARE_MEMBER(the_first_names, the_obj);
DO_COMPARE_MEMBER(the_street, the_obj);
DO_COMPARE_MEMBER(the_house_number, the_obj);
DO_COMPARE_MEMBER(the_country_code, the_obj);
DO_COMPARE_MEMBER(the_city_code, the_obj);
DO_COMPARE_MEMBER(the_city, the_obj);
DO_COMPARE_MEMBER(the_local_area, the_obj);
DO_COMPARE_MEMBER(the_telephone, the_obj);
DO_COMPARE_MEMBER(the_email, the_obj);
DO_COMPARE_MEMBER(the_creation_date, the_obj);
DO_COMPARE_MEMBER(the_key_number, the_obj);
return the_last_modified->compare(*the_obj.the_last_modified);
}
void Address::deepenShallowCopy()
{
the_last_name = (String *)the_last_name->deepCopy();
the_first_names = (String *)the_first_names->deepCopy();
the_street= (String *) the_street->deepCopy();
the_house_number = (String *)the_house_number->deepCopy();
the_country_code = (String *)the_country_code->deepCopy();
the_city_code = (String *)the_city_code->deepCopy();
the_city = (String *)the_city->deepCopy();
the_local_area = (String *)the_local_area->deepCopy();
the_telephone = (String *)the_telephone->deepCopy();
the_email = (String *)the_email->deepCopy();
the_creation_date = (Date *)the_creation_date->deepCopy();
the_last_modified = (Date *)the_last_modified->deepCopy();
the_key_number = (Integer *)the_key_number->deepCopy();
}
void Address::printOn(ostream& strm) const
// Print this object on an ostream
{
strm << endl << *the_last_name << ", " << *the_first_names << endl;
strm << *the_street << " " << *the_house_number << endl;
strm << *the_country_code << "-" << *the_city_code << " ";
strm << *the_city << " " << *the_local_area << endl;
strm << "Telephone: " << *the_telephone << endl;
strm << "Email: " << *the_email << endl;
strm << "Created: " << *the_creation_date << endl;
strm << "Modified: " << *the_last_modified << endl;
strm << "Index: " << *the_key_number << endl;
}
Address::Address(OIOin& strm)
: BASE(strm)
{
the_last_name = String::readFrom(strm);
the_first_names = String::readFrom(strm);
the_street = String::readFrom(strm);
the_house_number = String::readFrom(strm);
the_country_code = String::readFrom(strm);
the_city_code = String::readFrom(strm);
the_city = String::readFrom(strm);
the_local_area = String::readFrom(strm);
the_telephone = String::readFrom(strm);
the_email = String::readFrom(strm);
the_creation_date = Date::readFrom(strm);
the_last_modified = Date::readFrom(strm);
the_key_number = Integer::readFrom(strm);
}
void Address::storer(OIOout& strm) const
{
BASE::storer(strm);
the_last_name->storeOn(strm);
the_first_names->storeOn(strm);
the_street->storeOn(strm);
the_house_number->storeOn(strm);
the_country_code->storeOn(strm);
the_city_code->storeOn(strm);
the_city->storeOn(strm);
the_local_area->storeOn(strm);
the_telephone->storeOn(strm);
the_email->storeOn(strm);
the_creation_date->storeOn(strm);
the_last_modified->storeOn(strm);
the_key_number->storeOn(strm);
}
Address::Address(OIOifd& fd)
: BASE(fd)
{
the_last_name = String::readFrom(fd);
the_first_names = String::readFrom(fd);
the_street = String::readFrom(fd);
the_house_number = String::readFrom(fd);
the_country_code = String::readFrom(fd);
the_city_code = String::readFrom(fd);
the_city = String::readFrom(fd);
the_local_area = String::readFrom(fd);
the_telephone = String::readFrom(fd);
the_email = String::readFrom(fd);
the_creation_date = Date::readFrom(fd);
the_last_modified = Date::readFrom(fd);
the_key_number = Integer::readFrom(fd);
}
void Address::storer(OIOofd& fd) const
{
BASE::storer(fd);
the_last_name->storeOn(fd);
the_first_names->storeOn(fd);
the_street->storeOn(fd);
the_house_number->storeOn(fd);
the_country_code->storeOn(fd);
the_city_code->storeOn(fd);
the_city->storeOn(fd);
the_local_area->storeOn(fd);
the_telephone->storeOn(fd);
the_email->storeOn(fd);
the_creation_date->storeOn(fd);
the_last_modified->storeOn(fd);
the_key_number->storeOn(fd);
}
// New constructor
Address::Address(const String* last_name, const String* first_names,
const String* street, const String* house_number,
const String* country_code, const String* city_code,
const String* city, const String* local_area,
const String* telephone, const String* email,
const Date* creation_date, const Date* last_modified,
const Integer *key_number, bool copy_members)
{
the_last_name = copy_members ? new String(*last_name) : last_name;
the_first_names = copy_members ? new String(*first_names) : first_names;
the_street = copy_members ? new String(*street) : street;
the_house_number = copy_members ? new String(*house_number) : house_number;
the_country_code = copy_members ? new String(*country_code) : country_code;
the_city_code = copy_members ? new String(*city_code) : city_code;
the_city = copy_members ? new String(*city) : city;
the_local_area = copy_members ? new String(*local_area) : local_area;
the_telephone = copy_members ? new String(*telephone) : telephone;
the_email = copy_members ? new String(*email) : email;
the_creation_date = copy_members ? new Date(*creation_date) : creation_date;
the_last_modified = copy_members ? new Date(*last_modified) : last_modified;
the_key_number = copy_members ? new Integer(*key_number) : key_number;
}
// Destructor
Address::
~Address()
{
delete the_last_name;
delete the_first_names;
delete the_street;
delete the_house_number;
delete the_country_code;
delete the_city_code;
delete the_city;
delete the_local_area;
delete the_telephone;
delete the_email;
delete the_creation_date;
delete the_last_modified;
delete the_key_number;
}