List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
XCachedHash Class Referenceabstract

The XCachedHash combines a templated QHash with a QObject that clears itself upon receipt of a specific database notification or set of notifications. More...

#include <xcachedhash.h>

Public Member Functions

virtual ~XCachedHash ()
 
virtual const V value (const K &key)
 

Protected Member Functions

 XCachedHash (QObject *pParent, const QStringList &pNotification, QSqlDatabase pDb=QSqlDatabase::database())
 
 XCachedHash (QObject *pParent=0, const QString &pNotification=QString(), QSqlDatabase pDb=QSqlDatabase::database())
 
virtual void clear ()
 
virtual bool refresh (const K &key)=0
 
void setNotification (QStringList pNotification)
 

Protected Attributes

QSqlDatabase _db
 

Detailed Description

The XCachedHash combines a templated QHash with a QObject that clears itself upon receipt of a specific database notification or set of notifications.

This allows for straightforward access to a named object that's stored in the database, such as a script or metasql statement with minimal database access. The database is queried whenever a named object is not in the hash. The value retrieved from the database is stored in the hash and returned to the caller. The next time a caller requests that object, it is returned from the hash directly. The hash clears itself when the named database notification is received. Thus the next time a caller requests that named object, the hash requeries.

This is currently designed to be subclassed.

See also
MqlHash for an example.

Constructor & Destructor Documentation

◆ ~XCachedHash()

virtual XCachedHash::~XCachedHash ( )
inlinevirtual

◆ XCachedHash() [1/2]

XCachedHash::XCachedHash ( QObject pParent = 0,
const QString &  pNotification = QString(),
QSqlDatabase  pDb = QSqlDatabase::database() 
)
inlineprotected

◆ XCachedHash() [2/2]

XCachedHash::XCachedHash ( QObject pParent,
const QStringList &  pNotification,
QSqlDatabase  pDb = QSqlDatabase::database() 
)
inlineprotected

Member Function Documentation

◆ clear()

virtual void XCachedHash::clear ( )
inlineprotectedvirtual

◆ refresh()

virtual bool XCachedHash::refresh ( const K &  key)
protectedpure virtual

◆ setNotification()

void XCachedHash::setNotification ( QStringList  pNotification)
inlineprotected

◆ value()

virtual const V XCachedHash::value ( const K &  key)
inlinevirtual

Member Data Documentation

◆ _db

QSqlDatabase XCachedHash::_db
protected

The documentation for this class was generated from the following file:

Generated on Mon May 3 2021 xTuple ERP Programmer Reference, Version 4.12.0 doxygen 1.8.17