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 modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (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
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Classified Ads. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef CLASSIFIED_DATAMODEL_BASE_H
21 #define CLASSIFIED_DATAMODEL_BASE_H
22 #include <QSqlDatabase>
23 #include <QObject>
24 #include "../mcontroller.h" // because enum from there is needed
25 
26 class QSqlDatabase ;
27 class QMutex ;
28 class Hash ;
30 
38 class ModelBase : public QObject {
39  Q_OBJECT
40 
41 public:
52  ModelBase(QString aDataTableName,
53  unsigned aMaxRowsToKeep ) ;
54  ~ModelBase() ;
67  bool setTimeLastReference(const Hash& aObjectFingerPrint,
68  quint32 aTimeWhenLastReferenced) ;
72  unsigned getMaxRowsToKeep() ;
76  void setMaxRowsToKeep(unsigned aRows) ;
82  void truncateDataTableToMaxRows(void) ;
84  void updateDbTableRowCount() ;
85 signals:
87  const QString& aExplanation) ;
88 
89 private: // methods
90  virtual bool deleteOldestDataRowInTable() ;
91 protected:
96  QString iDataTableName ;
100  unsigned iMaxRowsToKeep ;
106 } ;
107 #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:37
CAErrorSituation
Definition: mcontroller.h:48
void error(MController::CAErrorSituation aError, const QString &aExplanation)
unsigned iCurrentDbTableRowCount
Definition: datamodelbase.h:105
void updateDbTableRowCount()
datamodel-parts common part. this is inherited and contains common funcs
Definition: datamodelbase.h:38
virtual bool deleteOldestDataRowInTable()
unsigned iMaxRowsToKeep
Definition: datamodelbase.h:100
QString iDataTableName
Definition: datamodelbase.h:96
void truncateDataTableToMaxRows(void)
ModelBase(QString aDataTableName, unsigned aMaxRowsToKeep)
This is content-crypto-operations-specific part of the datamodel.
Definition: contentencryptionmodel.h:36