file name: account.hpp, account.cpp
classification: simulation
contents: class CAccountant, struct SNetworkDelay
use: provides a database for the storage of network transmission
delays; the delays are associated with a pair of keys <SINT32 key1,
SINT32 key2>
The accountant uses CTransmissionList as
a primary list with key1, and this list stores secondary lists CTransmissionDelayList
with the index key2.
global items used by CAccountant:
SRandomData
slow: distribution data for transmitting early messages.
SRandomData
regular: distribution data for transmitting timely messages.
SRandomData
fast: distribution data for transmitting late messages.
double probEarly:
probability of early messages.
double probLate:
probability of late messages.
SNetworkDelay():
sets all double members to zero and the distributions to Uniform.
member variables of CAccountant:
SNetworkDelay
*data_: contains a pointer to the transmission data of the currently
accessed entry. If data is NULL, the "data entry" (ie., key1,
key2, data) is considered to be invalid.
default and reset value: NULL
CTransmissionList
*listOfDelays: stores the transmission delays.
EBool initCalled_:
is set to True by Init(), and to False by Dispose().
SINT32
key1_:
SINT32
key2_: <key1, key2> are the keys of the currently accessed entry.
member functions of CAccountant:
CAccountant
(): sets initCalled to False and calls Init().
virtual
~CAccountant (): calls Dispose().
EBool
DeleteKey1 (SINT32 key1): deletes all entries with key1 from the primary
list. If at least one entry exists, True is returned, else False is returned.
If key1 of the data entry was equal to the argument, the data
entry is marked invalid.
EBool
DeleteKey2 (SINT32 key2): deletes all entries with key2 from the secondary
lists. If at least one entry exists, True is returned, else False is returned.
If the deletion leaves secondary lists empty, these are deleted from the
primary list. If key2 of the data entry was equal to the argument,
the data entry is marked invalid.
virtual
void Dispose(): If initCalled is True, the list is deleted,
the data entry is made invalid and initCalled is set to False.
If initCalled is already False, the function has no effect.
EBool
GetDelay (SNetworkDelay *delay, SINT32 key1, SINT32 key2): If the
entry exists, the delay data is copied into delay, the data entry is set
accordingly and True is returned. Otherwise, False is returned and the
data entry is not changed. If delay is NULL, an assert fails.
EBool
GetInformation (SINT32 key1, SINT32 key2): Searches the list for an
entry with the given pair of keys. If the data is available, the data entry
is updated accordingly and the function returns True. If no entry was found,
the method has no effect and False is returned.
virtual
void Init (): If initCalled is False, the function creates
the list object and invalidates the data entry that contains the currently
accessed data and its keys. Member initCalled is set to True.
If initCalled is already True, the function has no effect.
void Reset
(): restores the initial state. The function simply calls Dispose()
and then Init().
void
ResetDataEntry (): Invalidates the data entry (members key1,
key2 and data). The entry is marked invalid by setting
data to NULL.
void
SetDelay (SNetworkDelay delay, SINT32 key1, SINT32 key2): Stores the
delay data. If there was a former entry, its data is overwritten. The data
entry is set to the access keys and their data.
void
SetInformation (): takes over the information stored in the data entry
and saves it in the list. If the data entry is invalid, or if the list
already contains an entry with the keys specified in the data entry, an
assert fails.
void
SetupDataEntry (SINT32 key1, SINT32 key2): searches for an entry with
the given keys. If no entry was found, the function creates and inserts
a new (default) entry. In any case, the data entry is set to the entry.