/home/croftj/photogrotto/dbPhotoService.h

00001 /*********************************************************************************
00002 **
00003 **   $Id: //depot/WorkInProgress/photogrotto/dbPhotoService.h#6 $
00004 **   Copyright (c) 2007 Joe Croft joe@croftj.net
00005 **   
00006 **   This file is part of Photogrotto
00007 **
00008 **   Photogrotto is free software; you can redistribute it and/or modify
00009 **   it under the terms of the GNU General Public License as published by
00010 **   the Free Software Foundation; either version 2 of the License, or
00011 **   (at your option) any later version.
00012 **
00013 **   Foobar is distributed in the hope that it will be useful,
00014 **   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 **   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 **   GNU General Public License for more details.
00017 **
00018 **   You should have received a copy of the GNU General Public License
00019 **   along with Foobar; if not, write to the Free Software
00020 **   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 **
00022 *********************************************************************************/
00023 
00024 #ifndef DBPHOTOSERVICE
00025 #define DBPHOTOSERVICE
00026 
00027 # include <QDomDocument>
00028 # include <QHash>
00029 # include <QMap>
00030 # include <QMutex>
00031 # include <QSqlDatabase>
00032 # include <QString>
00033 # include <QVariant>
00034 # include "QcjHttpService.h"
00035 
00036 class DbPhotoService : public QcjHttpService
00037 {
00038    Q_OBJECT
00039 
00040 public:
00041    DbPhotoService(int sockDescripter, QDomDocument *pdoc, long ttl = 0, QObject *parent = 0) :
00042       QcjHttpService(sockDescripter, parent, 20, 0, ttl)
00043    {
00044       printf("DbPhotoService::DbPhotoService(%s): sockDescripter = %d\n", qPrintable(QString::number(currentThreadId())), sockDescripter);
00045       if ( pdoc != 0 ) 
00046          doc = *pdoc;
00047       cacheDimension = 256;
00048       maxDimension = 1024;
00049    };
00050    void setMaxCache(int n);
00051    
00052 protected:
00053    void processRequest(QMap<QString, QVariant> *req, QMap<QString, QVariant> *rsp);
00054    void clearLocks();
00055 //   void processRequest(QMap<QString, QVariant> *req);
00056 
00057    QSqlDatabase getServerParms(QString host);
00058 
00059 private:
00060    QSqlDatabase                        db;
00061    QDomDocument                        doc;
00062    QString                             imageFormat;
00063    QString                             sqlTemplate;
00064    QString                             photoTable;
00065    QString                             htmlTemplate;
00066    QHash<QString, QSqlDatabase>        dbCache;
00067    unsigned int                        cacheDimension;
00068    unsigned int                        maxDimension;
00069 //   dbPhotoProcessor                    processor;
00070 };
00071 
00072 #endif

Generated on Fri May 4 11:21:12 2007 for PhotoGrotto by  doxygen 1.5.0