home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C++ / Applications / Nuntius 1.2 / src / Nuntius / UDiscussion.h < prev    next >
Encoding:
Text File  |  1994-02-20  |  2.5 KB  |  89 lines  |  [TEXT/MPS ]

  1. // Copyright © 1992 Peter Speck, speck@dat.ruc.dk. All rights reserved.
  2. // UDiscussion.h
  3.  
  4. #define __UDISCUSSION__
  5.  
  6. #ifndef __XTYPES__
  7. #include "XTypes.h"
  8. #endif
  9.  
  10. #ifndef __STDIO__
  11. #include <stdio.h>
  12. #endif
  13.  
  14. enum TableType {kMsgID, kName, kIDTable};
  15. const short kLastTable = kIDTable;
  16.  
  17. #define qDebugCDiscussion qDebug & 0
  18.  
  19. class CDiscussion 
  20. {
  21.     public:
  22.         // the following methods:
  23.         // AddArticle, AddArticleAsOriginator, GetArticleIDList
  24.         // which adds something to a CDiscussion
  25.         // returns the amount of space needed for that operation.
  26.         // if they returns non-zero, the CDiscussion is not touched,
  27.         // if zero: operation has completed!
  28.  
  29.         // be warned:
  30.         // all methods except GetArticleIDList executes with CDiscussion 
  31.         // in unlocked memory
  32.  
  33.         short AddArticle(long id);
  34.         short AddArticleAsOriginator(long id, 
  35.                                         HandleOffsetLength msgIDHol, short hash, ArrayIndex link, 
  36.                                         HandleOffsetLength nameHol);
  37.         
  38.         void UpdateAlloc(short newSize);
  39.  
  40.         short GetNoArticles();
  41.         short GetHash();
  42.         unsigned long GetLastActiveDateTime();
  43.         
  44.         Boolean CompareMsgID(Ptr p, long len);
  45.         
  46.         void GetName(CStr255 &name);
  47.         
  48.         void SetLink(ArrayIndex newLink);
  49.         ArrayIndex GetLink();
  50.  
  51.         TLongintList *GetArticleIDList(); // caller _owns_ returned list
  52.         long GetArticleID(long articleIndex);
  53.         long GetLastArticleID();
  54.  
  55.         void Dump(FILE *file, long index);
  56.         Boolean SanityCheck(long index);
  57.         short GetFreeSpace(); // for debug
  58.  
  59.         void Initialize(short initialTableSize, short hash); // set create time/date
  60.     private:
  61.         ArrayIndex fLink; // kNone when last in chain (only used by PDiscList)
  62.  
  63.         unsigned long fCreateDateTime;
  64.         unsigned long fLastActiveDateTime; // only updated for discussions
  65.         short fHash;
  66.  
  67.         short fNoArticles; // number of articles in this discussion
  68.         short fTableBytesAlloc; // size of space allocated for tables
  69.  
  70.         struct
  71.         {
  72.             short fOffset, fLength, fUsedLength, fFiller;
  73.         } fTable[kLastTable + 1];
  74.         
  75.         short ExpandTableEntry(TableType table, short newUsedSize);
  76.         // if !0: nothing touched (returns amount of extra space needed)
  77.         // if 0:  tables resized
  78.  
  79.  
  80.         short SetNameFromHOL(HandleOffsetLength hol);
  81.         short SetMsgIDFromHOL(HandleOffsetLength hol, short hash);
  82. };
  83.  
  84. inline void CDiscussion::SetLink(ArrayIndex newLink) { fLink = newLink; }
  85. inline ArrayIndex CDiscussion::GetLink() { return fLink; }
  86. inline short CDiscussion::GetHash() { return fHash; }
  87. inline unsigned long CDiscussion::GetLastActiveDateTime() { return fLastActiveDateTime; }
  88. inline void CDiscussion::UpdateAlloc(short newSize) { fTableBytesAlloc = newSize; }
  89.