Design question - static list in class

A

Angus

Hi all

I have a design which models a telephone system. Roughly the design has
these two items:

device class which models an extension on the telephone system. The device
constructor takes a extension number. So program starts by creating a
device object for each extension on the telephone system.

Each device object contains a static list of calls. Calls are modelled by a
class object. The class object takes an extension number in its destructor.

There are various find functions to find a call on a device. Usually on a
device there will be 0, 1 or 2 calls.

The list of calls in the device object is static because sometimes a device
object is created on the stack simply to find a call on the device and maybe
report on its status. If the call list were NOT static then I would get a
zero size call list each time I created the device object on the stack. Not
what I want.

I also have a device list - there is only ever one instance of the class
which accesses the device list. So the number of items in the device list
(a std::list) is set after the program starts.

Eg I get hold of the correct device object like this (device is the
extension object);

device* pDev=FindDeviceByDN(dn);

FindDeviceByDN retrieves a copy of the relevant device object in the device
list.

Then I might do something like this:
call* pCall=pDev->GetCallbyCallID(callid);


I am concerned that the static call list might be bad design. But not sure?
What do people think? Does this design seem ok? Anyone see a better
design?

Angus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,835
Latest member
lila30

Latest Threads

Top