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
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