CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::URLProtocol Class Referenceabstract

The implementation of a URL requester. More...

#include <CeresEngine/Foundation/IO/URLSession.hpp>

Inheritance diagram for CeresEngine::URLProtocol:
CeresEngine::TURLProtocol< FileURLProtocol, "File"> CeresEngine::TURLProtocol< T, N > CeresEngine::FileURLProtocol

Classes

class  Task
 An object that manages the task for a URL request. More...
 

Public Member Functions

 URLProtocol (URLSession &session) noexcept
 Creates a new URLProtocol instance.
 
virtual ~URLProtocol () noexcept=default
 Destroys the URLProtocol instance.
 
virtual bool isRequestSupported (const URLRequest &request)=0
 Checks if the given request is supported by the protocol.
 
virtual URLRequest prepareRequest (URLRequest &&request)
 If the request is supported by the protocol, this method is called to perform and transformation that the protocol may be require on the user request object.
 
virtual Async< URLResponseexecute (Task &connection)=0
 Executes a request.
 
virtual StringView getName () const noexcept=0
 Returns a string that identifies the protocol by a name.
 

Protected Attributes

URLSessionmSession
 The session that owns this protocol instance.
 

Friends

class URLSession
 

Detailed Description

The implementation of a URL requester.

Constructor & Destructor Documentation

◆ URLProtocol()

CeresEngine::URLProtocol::URLProtocol ( URLSession session)
inlineexplicitnoexcept

Creates a new URLProtocol instance.

◆ ~URLProtocol()

virtual CeresEngine::URLProtocol::~URLProtocol ( )
virtualdefaultnoexcept

Destroys the URLProtocol instance.

Member Function Documentation

◆ execute()

virtual Async< URLResponse > CeresEngine::URLProtocol::execute ( Task connection)
pure virtual

Executes a request.

The connection object is passed and is guaranteed to be alive for as long as the the `execute()ยด coroutine remains alive.

Note
This method must be thread-safe, as it may be called multiple times from different threads.
Parameters
connectionThe URL connection object that contains context for the execution.
Returns
A continuable that returns a response after executing the given request.

Implemented in CeresEngine::FileURLProtocol.

◆ getName()

virtual StringView CeresEngine::URLProtocol::getName ( ) const
pure virtualnoexcept

Returns a string that identifies the protocol by a name.

Implemented in CeresEngine::TURLProtocol< T, N >, and CeresEngine::TURLProtocol< FileURLProtocol, "File">.

◆ isRequestSupported()

virtual bool CeresEngine::URLProtocol::isRequestSupported ( const URLRequest request)
pure virtual

Checks if the given request is supported by the protocol.

This method will be called very often, so it must be efficiently implemented.

Note
This method must be thread-safe, as it may be called multiple times from different threads.
Parameters
requestThe request to check for support.
Returns
True if the protocol can execute the request; false otherwise.

Implemented in CeresEngine::FileURLProtocol.

◆ prepareRequest()

virtual URLRequest CeresEngine::URLProtocol::prepareRequest ( URLRequest &&  request)
inlinevirtual

If the request is supported by the protocol, this method is called to perform and transformation that the protocol may be require on the user request object.

All transformations will be performed on a copy of the request object and will be passed to execute().

Note
This method must be thread-safe, as it may be called multiple times from different threads.
Parameters
requestThe request to be transformed.
Returns
A prepared request or move request.

Reimplemented in CeresEngine::TURLProtocol< T, N >, and CeresEngine::TURLProtocol< FileURLProtocol, "File">.

Friends And Related Symbol Documentation

◆ URLSession

Member Data Documentation

◆ mSession

URLSession& CeresEngine::URLProtocol::mSession
protected

The session that owns this protocol instance.


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