beautypg.com

HP Integrity NonStop J-Series User Manual

Page 215

background image

also given as the bus example in the toolexam directory.

class Bus : public RWCollectable {
RWDECLARE_COLLECTABLE(Bus)

public:

Bus();
Bus(int busno, const RWCString& driver);
~Bus();

// Inherited from class "RWCollectable":
Rwspace binaryStoreSize() const;
int compareTo(const RWCollectable*) const;
RWBoolean isEqual(const RWCollectable*) const;
unsigned hash() const;
void restoreGuts(RWFile&);
void restoreGuts(RWvistream&);
void saveGuts(RWFile&) const;
void saveGuts(RWvostream&) const;

void addPassenger(const char* name);
void addCustomer(const char* name);
size_t customers() const;
size_t passengers() const;
RWCString driver() const {return driver_;}
int number() const {return busNumber_;}

private:

RWSet customers_;
RWSet* passengers_;
int busNumber_;
RWCString driver_;
};

class Client : public RWCollectable {
RWDECLARE_COLLECTABLE(Client)
Client(const char* name) : name_(name) {}
private:
RWCString name_;
//ignore other client information for this example
};

Note how both classes inherit from

RWCollectable

. We have chosen to implement the set of

customers by using class

RWSet

, which does not allow duplicate entries. This will guarantee

This manual is related to the following products: