//----------------------------------------------------------------------
//  SPECIFICATION FILE (pbxcalls.h)
//  This module exports facilities for controlling
//  telephone calls made locally within the PBX
//----------------------------------------------------------------------
#include "bool.h"

const int MAX_PREFIX = 2;
const int MAX_LINES = 200;

typedef int PhoneNumType;   // 1000..MAX_PREFIX*1000+999
typedef int TimeType;       // Time in computer minutes

struct OneLine {
    Boolean      inUse;
    PhoneNumType source;
    PhoneNumType receiver;
    TimeType     time;
};

class PbxType {
public:
    void Dial( /* in */  PhoneNumType caller,
               /* in */  PhoneNumType called,
               /* in */  TimeType     startTime,
               /* out */ Boolean&     busy      );
        // PRE:  caller and called are in PhoneNumType range
        //    && Assigned(startTime)
        // POST: busy == TRUE,  if the called phone is in use
        //            == FALSE, otherwise
        //    && NOT busy --> startTime is recorded as call starting time

    void HangUp( /* in */ PhoneNumType caller,
                 /* in */ TimeType     endTime );
        // PRE:  caller is in PhoneNumType range  &&  Assigned(endTime)
        // POST: IF caller currently connected THEN
        //          caller's current call terminated at time endTime
        //       ELSE
        //          no action taken

    PbxType();
        // Constructor
        // POST: Private data initialized
private:
    Boolean phoneInUse[1000*MAX_PREFIX];
    OneLine line[MAX_LINES];
};

