LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::Util::StandardNAMFactory Class Reference

A standard QML QNetworkAccessManager factory. More...

#include "standardnamfactory.h"

+ Inheritance diagram for LC::Util::StandardNAMFactory:
+ Collaboration diagram for LC::Util::StandardNAMFactory:

Public Types

using CacheSizeGetter_f = std::function< int()>
 The type of the function used to query the cache size by the factory. More...
 

Public Member Functions

 StandardNAMFactory (QString subpath, CacheSizeGetter_f getter, QQmlEngine *engine=nullptr)
 Constructs a new StandardNAMFactory. More...
 
QNetworkAccessManager * create (QObject *parent) override
 Creates the network access manager with the given parent. More...
 

Detailed Description

A standard QML QNetworkAccessManager factory.

StandardNAMFactory allows easily creating QNetworkAccessManager instances in QML contexts.

The created managers are all using the same cache, located at the cache path passed and limited by the maximum size passed to the constructor.

Several different factories may be created sharing the same cache location. In this case, the minimum value of the cache size would be used as the maximum.

Definition at line 35 of file standardnamfactory.h.

Member Typedef Documentation

◆ CacheSizeGetter_f

using LC::Util::StandardNAMFactory::CacheSizeGetter_f = std::function<int ()>

The type of the function used to query the cache size by the factory.

Definition at line 42 of file standardnamfactory.h.

Constructor & Destructor Documentation

◆ StandardNAMFactory()

LC::Util::StandardNAMFactory::StandardNAMFactory ( QString  subpath,
CacheSizeGetter_f  getter,
QQmlEngine *  engine = nullptr 
)

Constructs a new StandardNAMFactory.

The cache uses a subdirectory subpath in the network directory of the user cache location.

Parameters
[in]subpathThe subpath in cache user location.
[in]getterThe function that would be queried during periodical cache garbage collection to fetch the current maximum cache size.
[in]engineThe QML engine where this factory should be installed, if not null.

Definition at line 22 of file standardnamfactory.cpp.

Member Function Documentation

◆ create()

QNetworkAccessManager * LC::Util::StandardNAMFactory::create ( QObject *  parent)
override

Creates the network access manager with the given parent.

This function implements a pure virtual in Qt's base factory class (QDeclarativeNetworkAccessManagerFactory for Qt4 or QQmlNetworkAccessManagerFactory for Qt5).

The ownership of the returned QNetworkAccessManager is passed to the caller.

Parameters
[in]parentThe parent of the QNetworkAccessManager to be created.
Returns
A new QNetworkAccessManager.

Definition at line 32 of file standardnamfactory.cpp.


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