LibrePCB Developers Documentation
NetworkAccessManager Class Referencefinal

A network access manager which processes network requests in a separate thread. More...

#include <networkaccessmanager.h>

Inherits QThread.

+ Collaboration diagram for NetworkAccessManager:

Public Member Functions

 NetworkAccessManager (const FilePath &cache=FilePath()) noexcept
 
 NetworkAccessManager (const NetworkAccessManager &other)=delete
 
 ~NetworkAccessManager () noexcept
 
QNetworkReply * get (const QNetworkRequest &request) noexcept
 
QNetworkReply * post (const QNetworkRequest &request, const QByteArray &data) noexcept
 
std::unique_ptr< QIODevice > readFromCache (const QUrl &url, QString &contentType) noexcept
 
bool setMinimumCacheExpirationDate (const QUrl &url, const QDateTime &dt) noexcept
 
NetworkAccessManageroperator= (const NetworkAccessManager &rhs)=delete
 

Static Public Member Functions

static NetworkAccessManagerinstance () noexcept
 

Private Member Functions

void run () noexcept override
 
void stop () noexcept
 

Private Attributes

const FilePath mCacheFp
 
QSemaphore mThreadStartSemaphore
 
QNetworkAccessManager * mManager
 

Static Private Attributes

static NetworkAccessManagersInstance = nullptr
 

Detailed Description

A network access manager which processes network requests in a separate thread.

Note
One instance of this class must be created in the main application thread, and must be deleted before stopping the main application thread. It's not allowed to create a librepcb::NetworkAccessManager object in other threads, or to create multiple instances at the same time.

After the singleton was created, you can get it with the static method instance(). But for executing network requests, you don't need to access this object directly. You only need the classes librepcb::NetworkRequest and librepcb::FileDownload instead.

See also
librepcb::NetworkRequestBase, librepcb::NetworkRequest, librepcb::FileDownload

Constructor & Destructor Documentation

◆ NetworkAccessManager() [1/2]

NetworkAccessManager ( const FilePath cache = FilePath())
explicitnoexcept
+ Here is the call graph for this function:

◆ NetworkAccessManager() [2/2]

NetworkAccessManager ( const NetworkAccessManager other)
delete

◆ ~NetworkAccessManager()

~NetworkAccessManager ( )
noexcept
+ Here is the call graph for this function:

Member Function Documentation

◆ get()

QNetworkReply * get ( const QNetworkRequest &  request)
noexcept
+ Here is the caller graph for this function:

◆ post()

QNetworkReply * post ( const QNetworkRequest &  request,
const QByteArray &  data 
)
noexcept
+ Here is the caller graph for this function:

◆ readFromCache()

std::unique_ptr< QIODevice > readFromCache ( const QUrl &  url,
QString &  contentType 
)
noexcept
+ Here is the caller graph for this function:

◆ setMinimumCacheExpirationDate()

bool setMinimumCacheExpirationDate ( const QUrl &  url,
const QDateTime &  dt 
)
noexcept
+ Here is the caller graph for this function:

◆ operator=()

NetworkAccessManager & operator= ( const NetworkAccessManager rhs)
delete

◆ instance()

NetworkAccessManager * instance ( )
staticnoexcept
+ Here is the caller graph for this function:

◆ run()

void run ( )
overrideprivatenoexcept
+ Here is the call graph for this function:

◆ stop()

void stop ( )
privatenoexcept
+ Here is the caller graph for this function:

Member Data Documentation

◆ mCacheFp

const FilePath mCacheFp
private

◆ mThreadStartSemaphore

QSemaphore mThreadStartSemaphore
private

◆ mManager

QNetworkAccessManager* mManager
private

◆ sInstance

NetworkAccessManager * sInstance = nullptr
staticprivate

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