home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / HighLevel / IARouter.h < prev   
Encoding:
Text File  |  1998-04-16  |  3.1 KB  |  114 lines  |  [TEXT/CWIE]

  1. //----------------------------------------------------------------
  2. //    IARouter
  3. //    Copyright:    © 1997 - 1998 by Apple Computer, Inc., all rights reserved.
  4. //
  5. //    Identifies the cluster of documents that a document belongs to
  6. //
  7. //----------------------------------------------------------------
  8. #pragma once 
  9. #ifndef IARouter_h
  10. #define IARouter_h
  11.  
  12. #pragma import on
  13. #if PRAGMA_STRUCT_ALIGN
  14.     #pragma options align=power
  15. #endif
  16.  
  17. #include <time.h>
  18. class IAStorage;
  19. class IAStoreStream;
  20. class TWVector;
  21. class VectorIndex;
  22. class IADocIterator;
  23. class IADoc;
  24. class IACorpus;
  25. class IACluster;
  26. class IAIndex;
  27. class VectorAccessor;
  28.  
  29. #include "IACommon.h"
  30. #include "IAStorage.h"
  31.  
  32. #pragma IA_BEGIN_EXPORTS
  33.  
  34. class IARouter : public IAObject {
  35. public:
  36.             IARouter(VectorIndex* index, TProgressFn*   progress = NULL, clock_t progressFreq = 0xFFFFFFFFul, void* appData = NULL);
  37.  
  38.     virtual    ~IARouter();
  39.                 
  40.     // clusters is an array of IACluster pointers.    
  41.     void     InitializeClusters(IACluster** clusters, uint32 howManyClusters);
  42.     // given a document, which cluster group is the best to add this document to
  43.     uint32  WhichCluster (IADoc* doc, bool accumulate = false);       
  44.     // save the state of the router and the normalized cluster vectors
  45.     void Store (IAStorage* storage = NULL, IABlockID block = 0) const;
  46.     // restore the state of the router and the normalized cluster vectors from storage
  47.     // if you restore then no need to call InitializeClusters
  48.     void Restore (IAStorage* storage = NULL, IABlockID block = 0);
  49.     // store size of this router
  50.     IABlockSize StoreSize() const;
  51.  
  52.  
  53.     TProgressFn*    GetProgressFn() const         {return fProgressFn;}
  54.     void*            GetProgressData() const     {return fProgressData;}
  55.     clock_t            GetProgressFreq() const     {return fProgressFreq;}
  56.     
  57. protected:
  58.     // return the best matching cluster for the given vector.
  59.     uint32        BestCluster(TWVector *vector ) const;    
  60.     // accumulator
  61.     void        ClearAccumulator( void );
  62.     void        AddDocVectorToAccumulator(TWVector* newDocVector);
  63.     void        AccumulateDocVector(IADoc* doc);
  64.     void         AddToAccumulator (uint32 cluster, TWVector    *docVector);
  65.     
  66. private:
  67.  
  68.     TWVector*            fVectorAccumulator;
  69.     uint32                fClusterCount;        // how many clusters there are
  70.     TWVector**            fClusterVectors;    // vector for centroid of each cluster    
  71.     VectorIndex*        fIndex;                // our index
  72.     TProgressFn*        fProgressFn;        // for showing how we're doing
  73.                                             // may be NULL.
  74.     void*                fProgressData;
  75.     clock_t                fProgressFreq;
  76.     
  77.     VectorAccessor*        fAccessor;
  78. };
  79.  
  80.  
  81.  
  82. class IACluster : public IAObject {
  83. public:
  84.     IACluster (IAIndex* index);
  85.     virtual ~IACluster();
  86.     virtual    IADoc*    GetNextDoc() const = 0; // return the next document 
  87.                                             // in the cluster
  88.                                             // this is platform specific 
  89.                                             // for example HFSCluster will return 
  90.                                             // documents of type HFSDoc
  91.                                             
  92.     virtual    void Reset() = 0;                // resets the iterator for another round of
  93.                                             // iteration
  94. protected:
  95.     IACorpus*    GetCorpus() const {return fCorpus;}
  96. private:
  97.     IACorpus*    fCorpus;                                            
  98. };    
  99.  
  100.  
  101. IAExceptionCode            IARouterAlreadyInitialized = 'VRAI';
  102. IAExceptionCode            IARouterNotInitialized = 'VRNI';
  103.  
  104. #pragma IA_END_EXPORTS
  105.  
  106. #if PRAGMA_STRUCT_ALIGN
  107.     #pragma options align=reset
  108. #endif
  109.  
  110. #pragma import reset
  111.  
  112.  
  113. #endif
  114.