Classified ads
datamodelbase.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Jarvinen 2013.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef CLASSIFIED_DATAMODEL_BASE_H
22 #define CLASSIFIED_DATAMODEL_BASE_H
23 #include <QSqlDatabase>
24 #include <QObject>
25 #include "../mcontroller.h" // because enum from there is needed
26 
27 class QSqlDatabase ;
28 class QMutex ;
29 class Hash ;
31 
39 class ModelBase : public QObject {
40  Q_OBJECT
41 
42 public:
53  ModelBase(QString aDataTableName,
54  unsigned aMaxRowsToKeep ) ;
55  ~ModelBase() ;
68  bool setTimeLastReference(const Hash& aObjectFingerPrint,
69  quint32 aTimeWhenLastReferenced) ;
73  unsigned getMaxRowsToKeep() ;
77  void setMaxRowsToKeep(unsigned aRows) ;
83  void truncateDataTableToMaxRows(void) ;
85  void updateDbTableRowCount() ;
86 signals:
88  const QString& aExplanation) ;
89 
90 private: // methods
91  virtual bool deleteOldestDataRowInTable() ;
92 protected:
97  QString iDataTableName ;
101  unsigned iMaxRowsToKeep ;
107 } ;
108 #endif
unsigned getMaxRowsToKeep()
void setMaxRowsToKeep(unsigned aRows)
bool setTimeLastReference(const Hash &aObjectFingerPrint, quint32 aTimeWhenLastReferenced)
Hash is class that carries 160-bit digest.
Definition: hash.h:38
CAErrorSituation
Definition: mcontroller.h:52
void error(MController::CAErrorSituation aError, const QString &aExplanation)
unsigned iCurrentDbTableRowCount
Definition: datamodelbase.h:106
void updateDbTableRowCount()
datamodel-parts common part. this is inherited and contains common funcs
Definition: datamodelbase.h:39
virtual bool deleteOldestDataRowInTable()
unsigned iMaxRowsToKeep
Definition: datamodelbase.h:101
QString iDataTableName
Definition: datamodelbase.h:97
void truncateDataTableToMaxRows(void)
ModelBase(QString aDataTableName, unsigned aMaxRowsToKeep)
This is content-crypto-operations-specific part of the datamodel.
Definition: contentencryptionmodel.h:37