DestInfo.h
上传用户:weiyuanprp
上传日期:2020-05-20
资源大小:1169k
文件大小:4k
源码类别:

传真(Fax)编程

开发平台:

C/C++

  1. /* $Id: DestInfo.h,v 1.2 2007/01/05 21:57:24 faxguy Exp $ */
  2. /*
  3.  * Copyright (c) 1990-1996 Sam Leffler
  4.  * Copyright (c) 1991-1996 Silicon Graphics, Inc.
  5.  * HylaFAX is a trademark of Silicon Graphics
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26. #ifndef _DestInfo_
  27. #define _DestInfo_
  28. /*
  29.  * Destination Information Support.
  30.  */
  31. #include "QLink.h"
  32. #include "FaxMachineInfo.h"
  33. #include "Dictionary.h"
  34. class Job;
  35. class fxStr;
  36. /*
  37.  * This structure is used to create a dictionary indexed by
  38.  * canonical destination phone number.  All jobs to a destination
  39.  * are referenced here with jobs blocked due to concurrency
  40.  * limitations queued here.  The FaxMachineInfo data structure
  41.  * common to all jobs going to the same destination is kept
  42.  * here to permit shared access and updates without going to
  43.  * the associated file.  Note that certain interfaces are needed
  44.  * because the data structure only exists as a member of a
  45.  * dictionary (e.g. explicit mechanisms for reading and updating
  46.  * the external file). 
  47.  */ 
  48. class DestInfo : public QLink {
  49. private:
  50.     u_short activeCount; // count of active jobs to destination
  51.     u_short blockedCount; // count of blocked jobs
  52.     u_short callCount; // count of active calls to destination
  53.     FaxMachineInfo info; // remote machine capabilities and such
  54.     Job* running; // jobs to dest being processed
  55. public:
  56.     DestInfo();
  57.     DestInfo(const DestInfo& other);
  58.     ~DestInfo();
  59.     u_int getActive() const; // return count of active jobs
  60.     u_int getBlocked() const; // return count of blocked jobs
  61.     u_int getCount() const; // return count of active+blocked jobs
  62.     bool isEmpty() const; // true if any jobs referenced
  63.     u_int getCalls() const; // return count of active calls
  64.     void call(); // initiate call to destination
  65.     void hangup(); // terminate call to destination
  66.     bool isActive(Job&) const; // true if job is considered active
  67.     bool supportsBatching(); // if remote supports batch protocol
  68.     void active(Job&); // set job active to destination
  69.     void done(Job&); // remove job from active set
  70.     void block(Job&); // add job to blocked queue
  71.     Job* nextBlocked(); // remove and return first blocked job
  72.     void unblock(const Job& job); // remove blocked job by reference
  73.     FaxMachineInfo& getInfo(const fxStr& number);
  74.     void updateConfig(); // write info file if necessary
  75. };
  76. inline u_int DestInfo::getActive() const { return activeCount; }
  77. inline u_int DestInfo::getBlocked() const { return blockedCount; }
  78. inline u_int DestInfo::getCount() const
  79.     { return activeCount + blockedCount; }
  80. inline bool DestInfo::isEmpty() const { return getCount() == 0; }
  81. inline u_int DestInfo::getCalls() const { return callCount; }
  82. inline void DestInfo::call() { callCount++; }
  83. inline void DestInfo::hangup() { callCount--; }
  84. fxDECLARE_StrKeyDictionary(DestInfoDict, DestInfo)
  85. #endif /* _DestInfo_ */