Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

CNewsgroup.h

Go to the documentation of this file.
00001 #ifndef __CNewsgroup_h__
00002 #define __CNewsgroup_h__
00003 
00004 #include "NServer.h"
00005 #include "NVNewsgroup.h"
00006 
00013 class CNewsgroup:public NVNewsgroup {
00014       protected:
00015         nvtime_t _TTLGroup;
00016         RServer *_RServer;
00017 
00018         void sUpdateGroupInfo(unsigned int *infof, unsigned int *infol);
00019         void sUpdateOverview(void);
00020 
00021         void updateOverview(void) {
00022                 VERB(slog.
00023                      p(Logger::Debug) << "CNewsgroup::updateOverview()\n");
00024                 nvtime_t mt;
00025                  getmtime(&mt);
00026                 if (mt + _TTLGroup >= nvtime(NULL))
00027                          return;
00028                  NVArray::lock(NVcontainer::ExclLock);
00029                  sUpdateOverview();
00030                  NVArray::lock(NVcontainer::UnLock);
00031         } void listgroup(char *lstgrp, unsigned int f, unsigned int l);
00032         virtual Article *retrievearticle(unsigned int nbr);
00033 
00034       public:
00035         CNewsgroup(RServer * nsrvr, OverviewFmt * fmt,
00036                    const char *spooldir, const char *name):NVNewsgroup(fmt,
00037                                                                        spooldir,
00038                                                                        name)
00039         {
00040                 _RServer = nsrvr;
00041         }
00042 
00043         virtual void setttl(nvtime_t grp) {
00044                 _TTLGroup = grp;
00045         }
00046 
00047         virtual void setsize(unsigned int f, unsigned int l) {
00048                 lock(NVcontainer::ShrdLock);
00049                 if (f != arrfst || l != arrlst) {
00050                         NVNewsgroup::setsize(f, l);
00051                         setmtime(0, 1);
00052                 }
00053                 lock(NVcontainer::UnLock);
00054         }
00055 
00056         virtual void prefetchGroup(int lockgrp = 1);
00057 
00058         virtual void prefetchOverview(void) {
00059                 VERB(slog.
00060                      p(Logger::
00061                        Debug) << "CNewsgroup::prefetchOverview()\n");
00062                 NVArray::lock(NVcontainer::ExclLock);
00063                 sUpdateOverview();
00064                 NVArray::lock(NVcontainer::UnLock);
00065         }
00066 
00067         virtual const char *getover(unsigned int nbr) {
00068                 updateOverview();
00069                 return NVNewsgroup::getover(nbr);
00070         }
00071 
00072         virtual void printheaderdb(std::ostream & os,
00073                                    const char *header,
00074                                    unsigned int f = 0, unsigned int l =
00075                                    UINT_MAX) {
00076                 updateOverview();
00077                 NVNewsgroup::printheaderdb(os, header, f, l);
00078         }
00079 
00080         virtual void printlistgroup(std::ostream & os) {
00081                 updateOverview();
00082                 NVNewsgroup::printlistgroup(os);
00083         }
00084 
00085         virtual void printover(std::ostream & os, unsigned int nbr) {
00086                 updateOverview();
00087                 NVNewsgroup::printover(os, nbr);
00088         }
00089 
00090         virtual void printoverdb(std::ostream & os, unsigned int f =
00091                                  0, unsigned int l = UINT_MAX) {
00092                 updateOverview();
00093                 NVNewsgroup::printoverdb(os, f, l);
00094         }
00095 };
00096 
00097 #endif

Generated on Fri Aug 20 10:58:06 2004 for NewsCache by doxygen 1.3.6-20040222