home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
ibmodf.zip
/
CUSTOMER.ZIP
/
ICUST.CPP
< prev
next >
Wrap
Text File
|
1995-06-13
|
21KB
|
493 lines
/*******************************************************************************
* FILE NAME: icust.cpp *
* *
* DESCRIPTION: *
* Class implementation of the class(es): *
* ICustomer - IBM sample customer part. *
* *
* COPYRIGHT: *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1994, 1995 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
* DISCLAIMER OF WARRANTIES: *
* The following [enclosed] code is sample code created by IBM *
* Corporation. This sample code is not part of any standard IBM product *
* and is provided to you solely for the purpose of assisting you in the *
* development of your applications. The code is provided "AS IS", *
* without warranty of any kind. IBM shall not be liable for any damages *
* arising out of your use of the sample code, even if they have been *
* advised of the possibility of such damages. *
*******************************************************************************/
#ifndef _ICUST_
#include <icust.hpp>
#endif
#ifndef _INOTIFEV_
#include <inotifev.hpp>
#endif
#include <iadd.hpp>
#pragma export (ICustomer::nameId,, 1200)
const INotificationId ICustomer::nameId =
"ICustomer::name";
#pragma export (ICustomer::addressId,, 1201)
const INotificationId ICustomer::addressId =
"ICustomer::address";
#pragma export (ICustomer::homePhoneId,, 1202)
const INotificationId ICustomer::homePhoneId =
"ICustomer::homePhone";
#pragma export (ICustomer::workPhoneId,, 1203)
const INotificationId ICustomer::workPhoneId =
"ICustomer::workPhone";
#pragma export (ICustomer::dateId,, 1204)
const INotificationId ICustomer::dateId =
"ICustomer::date";
#pragma export (ICustomer::timeId,, 1205)
const INotificationId ICustomer::timeId =
"ICustomer::time";
/*------------------------------------------------------------------------------
| ICustomer::ICustomer |
| |
| Standard constructor. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::ICustomer(),, 1206)
ICustomer::ICustomer() : IPart ()
,iName ("Ken")
,iAddress (new IAddress())
,iHomePhone ("555-1212")
,iWorkPhone ("555-1212")
,iDate ()
,iTime ()
{
enableNotification ();
}
/*------------------------------------------------------------------------------
| ICustomer::ICustomer |
| |
| Constructor with name parameter. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::ICustomer(const IString& aName),, 1207)
ICustomer::ICustomer(const IString& aName) :
IPart (),
iName ("Ken"),
iAddress (new IAddress()),
iHomePhone ("555-1212"),
iWorkPhone ("555-1212"),
iDate (),
iTime ()
{
setName(aName);
enableNotification ();
}
/*------------------------------------------------------------------------------
| ICustomer::ICustomer |
| |
| Standard copy constructor. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::ICustomer(const ICustomer&),, 1208)
ICustomer::ICustomer (const ICustomer& partCopy)
: IPart (partCopy)
,iName (partCopy.name ())
,iAddress (partCopy.address ())
,iHomePhone (partCopy.homePhone ())
,iWorkPhone (partCopy.workPhone ())
,iDate (partCopy.date ())
,iTime (partCopy.time ())
{
enableNotification ();
}
/*------------------------------------------------------------------------------
| ICustomer::ICustomer |
| |
| Standard operator= |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::operator= (const ICustomer&),, 1209)
ICustomer& ICustomer::operator= (const ICustomer& aICustomer)
{
if (this == &aICustomer) {
return *this;
} /* endif */
setName(aICustomer.name());
setAddress(aICustomer.address());
setHomePhone(aICustomer.homePhone());
setWorkPhone(aICustomer.workPhone());
setDate(aICustomer.date());
setTime(aICustomer.time());
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::~ICustomer |
| |
| ICustomer destructor. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::~ICustomer(),, 1210)
ICustomer::~ICustomer()
{
if (iAddress)
delete iAddress;
}
/*------------------------------------------------------------------------------
| ICustomer::asString |
| |
| Perform asString. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::asString() const,, 1211)
IString ICustomer::asString () const
{
return name();
}
/*------------------------------------------------------------------------------
| ICustomer::name |
| |
| Return the name attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::name() const,, 1212)
IString ICustomer::name () const
{
return iName;
}
/*------------------------------------------------------------------------------
| ICustomer::setName |
| |
| Set the name attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setName(const IString&),, 1213)
ICustomer& ICustomer::setName (const IString& aName)
{
if (iName != aName) {
iName = aName;
IString eventData(iName);
notifyObservers(INotificationEvent(nameId, *this,
true, (void*)&eventData));
} /* endif */
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::address |
| |
| Return the address attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::address() const,, 1214)
IAddress* ICustomer::address () const
{
return iAddress;
}
/*------------------------------------------------------------------------------
| ICustomer::setAddress |
| |
| Set the address attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setAddress(const IAddress*),, 1215)
ICustomer& ICustomer::setAddress (IAddress* aAddress)
{
if (iAddress != aAddress) {
if (iAddress)
delete iAddress;
iAddress = aAddress;
notifyObservers(INotificationEvent(addressId, *this,
true, (void*)iAddress));
} /* endif */
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::setAddress |
| |
| Set the address attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setAddress(const IAddress&),, 1216)
ICustomer& ICustomer::setAddress (const IAddress& aAddress)
{
return setAddress(new IAddress(aAddress));
}
/*------------------------------------------------------------------------------
| ICustomer::homePhone |
| |
| Return the homePhone attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::homePhone() const,, 1217)
IString ICustomer::homePhone () const
{
return iHomePhone;
}
/*------------------------------------------------------------------------------
| ICustomer::setHomePhone |
| |
| Set the homePhone attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setHomePhone(const IString&),, 1218)
ICustomer& ICustomer::setHomePhone (const IString& aHomePhone)
{
if (iHomePhone != aHomePhone) {
iHomePhone = aHomePhone;
IString eventData(iHomePhone);
notifyObservers(INotificationEvent(homePhoneId, *this,
true, (void*)&eventData));
} /* endif */
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::workPhone |
| |
| Return the workPhone attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::workPhone() const,, 1219)
IString ICustomer::workPhone () const
{
return iWorkPhone;
}
/*------------------------------------------------------------------------------
| ICustomer::setWorkPhone |
| |
| Set the workPhone attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setWorkPhone(const IString&),, 1220)
ICustomer& ICustomer::setWorkPhone (const IString& aWorkPhone)
{
if (iWorkPhone != aWorkPhone) {
iWorkPhone = aWorkPhone;
IString eventData(iWorkPhone);
notifyObservers(INotificationEvent(workPhoneId, *this,
true, (void*)&eventData));
} /* endif */
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::date |
| |
| Return the date attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::date() const,, 1221)
IDate ICustomer::date () const
{
return iDate;
}
/*------------------------------------------------------------------------------
| ICustomer::setDate |
| |
| Set the date attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setDate(const IDate&),, 1222)
ICustomer& ICustomer::setDate (const IDate& aDate)
{
if (iDate != aDate) {
iDate = aDate;
IDate eventData(iDate);
notifyObservers(INotificationEvent(dateId, *this,
true, (void*)&eventData));
} /* endif */
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::time |
| |
| Return the time attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::time() const,, 1223)
ITime ICustomer::time () const
{
return iTime;
}
/*------------------------------------------------------------------------------
| ICustomer::setTime |
| |
| Set the time attribute. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setTime(const ITime&),, 1224)
ICustomer& ICustomer::setTime (const ITime& aTime)
{
if (iTime != aTime)
{
iTime = aTime;
ITime eventData(iTime);
notifyObservers(INotificationEvent(timeId, *this,
true, (void*)&eventData));
} /* endif */
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::setNameToDefault |
| |
| Perform the setNameToDefault action. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setNameToDefault(),, 1225)
ICustomer& ICustomer::setNameToDefault ()
{
return setName("Ken");
}
/*------------------------------------------------------------------------------
| ICustomer::setAddressToDefault |
| |
| Perform the setAddressToDefault action. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setAddressToDefault(),, 1226)
ICustomer& ICustomer::setAddressToDefault ()
{
if (address())
address()->setToDefault();
return *this;
}
/*------------------------------------------------------------------------------
| ICustomer::setHomePhoneToDefault |
| |
| Perform the setHomePhoneToDefault action. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setHomePhoneToDefault(),, 1227)
ICustomer& ICustomer::setHomePhoneToDefault ()
{
return setHomePhone("555-1212");
}
/*------------------------------------------------------------------------------
| ICustomer::setWorkPhoneToDefault |
| |
| Perform the setWorkPhoneToDefault action. |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::setWorkPhoneToDefault(),, 1228)
ICustomer& ICustomer::setWorkPhoneToDefault ()
{
return setWorkPhone("555-1212");
}
/*------------------------------------------------------------------------------
| ICustomer::operator == (const ICustomer & aValue) |
| |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::operator == (const ICustomer&) const,, 1229)
Boolean ICustomer::
operator == (const ICustomer& aValue) const
{
if (name() != aValue.name()) {
return false;
} /* endif */
if (address() != aValue.address()) {
return false;
} /* endif */
if (homePhone() != aValue.homePhone()) {
return false;
} /* endif */
if (workPhone() != aValue.workPhone()) {
return false;
} /* endif */
if (date() != aValue.date()) {
return false;
} /* endif */
if (time() != aValue.time()) {
return false;
} /* endif */
return true;
}
/*------------------------------------------------------------------------------
| ICustomer::operator != (const ICustomer & aValue) |
| |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::operator != (const ICustomer&) const,, 1230)
Boolean ICustomer::
operator != (const ICustomer& aValue) const
{
if (name() != aValue.name()) {
return true;
} /* endif */
if (address() != aValue.address()) {
return true;
} /* endif */
if (homePhone() != aValue.homePhone()) {
return true;
} /* endif */
if (workPhone() != aValue.workPhone()) {
return true;
} /* endif */
if (date() != aValue.date()) {
return true;
} /* endif */
if (time() != aValue.time()) {
return true;
} /* endif */
return false;
}
/*------------------------------------------------------------------------------
| ICustomer::operator == (const ICustomer * aValue) |
| |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::operator == (const ICustomer*) const,, 1231)
Boolean ICustomer::
operator == (const ICustomer* aValue) const
{
if (name() != aValue->name()) {
return false;
} /* endif */
if (address() != aValue->address()) {
return false;
} /* endif */
if (homePhone() != aValue->homePhone()) {
return false;
} /* endif */
if (workPhone() != aValue->workPhone()) {
return false;
} /* endif */
if (date() != aValue->date()) {
return false;
} /* endif */
if (time() != aValue->time()) {
return false;
} /* endif */
return true;
}
/*------------------------------------------------------------------------------
| ICustomer::operator != (const ICustomer * aValue) |
| |
------------------------------------------------------------------------------*/
#pragma export (ICustomer::operator != (const ICustomer*) const,, 1232)
Boolean ICustomer::
operator != (const ICustomer* aValue) const
{
if (name() != aValue->name()) {
return true;
} /* endif */
if (address() != aValue->address()) {
return true;
} /* endif */
if (homePhone() != aValue->homePhone()) {
return true;
} /* endif */
if (workPhone() != aValue->workPhone()) {
return true;
} /* endif */
if (date() != aValue->date()) {
return true;
} /* endif */
if (time() != aValue->time()) {
return true;
} /* endif */
return false;
}