XCachedHash< K, V > Class Template 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 Slots

virtual void sConnectionLost ()
 
virtual void sNotified (const QString &pNotification)
 

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
 
virtual void setNotification (QStringList pNotification)
 

Protected Attributes

QSqlDatabase _db
 
QStringList _notice
 

Detailed Description

template<class K, class V>
class XCachedHash< K, V >

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()

template<class K , class V >
virtual XCachedHash< K, V >::~XCachedHash ( )
inlinevirtual

◆ XCachedHash() [1/2]

template<class K , class V >
XCachedHash< K, V >::XCachedHash ( QObject * pParent = 0,
const QString & pNotification = QString(),
QSqlDatabase pDb = QSqlDatabase::database() )
inlineprotected

◆ XCachedHash() [2/2]

template<class K , class V >
XCachedHash< K, V >::XCachedHash ( QObject * pParent,
const QStringList & pNotification,
QSqlDatabase pDb = QSqlDatabase::database() )
inlineprotected

Member Function Documentation

◆ clear()

template<class K , class V >
virtual void XCachedHash< K, V >::clear ( )
inlineprotectedvirtual

Implements XCachedHashQObject.

◆ refresh()

template<class K , class V >
virtual bool XCachedHash< K, V >::refresh ( const K & key)
protectedpure virtual

Implemented in MqlHash.

◆ sConnectionLost

void XCachedHashQObject::sConnectionLost ( )
virtualslotinherited

◆ setNotification()

template<class K , class V >
virtual void XCachedHash< K, V >::setNotification ( QStringList pNotification)
inlineprotectedvirtual

◆ sNotified

void XCachedHashQObject::sNotified ( const QString & pNotification)
virtualslotinherited

◆ value()

template<class K , class V >
virtual const V XCachedHash< K, V >::value ( const K & key)
inlinevirtual

Member Data Documentation

◆ _db

template<class K , class V >
QSqlDatabase XCachedHash< K, V >::_db
protected

◆ _notice

QStringList XCachedHashQObject::_notice
protectedinherited

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

Generated on Mon Feb 17 2025 xTuple ERP Programmer Reference, Version 6.1.0 doxygen 1.11.0