LeechCraft Monocle  0.6.70-13729-g7046a9d2a7
Modular document viewer for LeechCraft
LC::Monocle::IBackendPlugin Class Referenceabstract

Basic interface for plugins providing support for various document formats for Monocle. More...

#include "ibackendplugin.h"

Public Types

enum  LoadCheckResult { LoadCheckResult::Cannot, LoadCheckResult::Can, LoadCheckResult::Redirect }
 Describes the result of checking whether a file can be loaded. More...
 

Public Member Functions

virtual ~IBackendPlugin ()
 Virtual destructor. More...
 
virtual LoadCheckResult CanLoadDocument (const QString &filename)=0
 Checks whether the given document can be loaded. More...
 
virtual IDocument_ptr LoadDocument (const QString &filename)=0
 Loads the given document. More...
 
virtual IRedirectProxy_ptr GetRedirection (const QString &filename)
 Returns the redirection proxy for the given document. More...
 
virtual QStringList GetSupportedMimes () const =0
 Returns the MIME types supported by the backend. More...
 
virtual bool IsThreaded () const
 Returns whether the backend supports threads. More...
 

Detailed Description

Basic interface for plugins providing support for various document formats for Monocle.

This interface should be implemented by plugins that provide format backends for Monocle document reader — that is, for those plugins that can load documents or convert them.

Some backends only convert a document from their format to another format, probably supported by another Monocle plugin. This is called a redirection, and the backend should return LoadCheckResult::Redirect from the CanLoadDocument() method in this case. The backend should also return a valid redirect proxy from the GetRedirection() method in this case.

See also
IDocument

Definition at line 59 of file ibackendplugin.h.

Member Enumeration Documentation

◆ LoadCheckResult

Describes the result of checking whether a file can be loaded.

See also
CanLoadDocument()
Enumerator
Cannot 

The file cannot be loaded by this backend.

Can 

The file can be loaded by this backend.

Redirect 

The file cannot be loaded by this backend, but can be converted to another format.

Definition at line 71 of file ibackendplugin.h.

Constructor & Destructor Documentation

◆ ~IBackendPlugin()

virtual LC::Monocle::IBackendPlugin::~IBackendPlugin ( )
inlinevirtual

Virtual destructor.

Definition at line 64 of file ibackendplugin.h.

Member Function Documentation

◆ CanLoadDocument()

virtual LoadCheckResult LC::Monocle::IBackendPlugin::CanLoadDocument ( const QString &  filename)
pure virtual

Checks whether the given document can be loaded.

This method should return LoadCheckResult::Can if the document can possibly be loaded, LoadCheckResult::Cannot if it can't be loaded at all, and LoadCheckResult::Redirect if the document can be preprocessed and converted to some other format probably loadable by another Monocle plugin.

The cheaper this function is, the better. It is discouraged to just check by document extension, though.

It is OK to return nullptr or invalid document from LoadDocument() even if this method returns LoadCheckResult::Can for a given filename.

If this function returns LoadCheckResult::Redirect, then the GetRedirection() method should return a non-null redirect proxy (which can fail to convert the document, though).

Parameters
[in]filenamePath to the document to check.
Returns
Whether the document at filename can be loaded.
See also
LoadDocument()
GetRedirection()

◆ GetRedirection()

virtual IRedirectProxy_ptr LC::Monocle::IBackendPlugin::GetRedirection ( const QString &  filename)
inlinevirtual

Returns the redirection proxy for the given document.

This function should return a redirect proxy for the document at filename, or a null pointer if the document cannot be redirected (for example, if it is invalid or can be handled directly by this module). However, a null pointer can be returned only if CanLoadDocument() returned LoadCheckResult::Can or LoadCheckResult::Cannot for the same document.

The default implementation simply does nothing and returns a null pointer.

Parameters
[in]filenameThe document to redirect.
Returns
The redirect proxy for filename, or null pointer.
See also
LoadDocument()
IRedirectProxy

Definition at line 157 of file ibackendplugin.h.

◆ GetSupportedMimes()

virtual QStringList LC::Monocle::IBackendPlugin::GetSupportedMimes ( ) const
pure virtual

Returns the MIME types supported by the backend.

Only those MIMEs that can be handled directly (by the LoadDocument() method) should be returned.

The returned MIME types are only considered when dealing with redirections. CanLoadDocument() and LoadDocument() methods can still be called on a file whose MIME isn't contained in the returned list. The reverse is also true: CanLoadDocument() and LoadDocument() can reject loading a document even if its MIME is contained in the list returned by this method.

Returns
The list of MIMEs the backend supports.

◆ IsThreaded()

virtual bool LC::Monocle::IBackendPlugin::IsThreaded ( ) const
inlinevirtual

Returns whether the backend supports threads.

This function returns true if the implementation supports threaded pages rendering.

The default implementation simply returns false.

Returns
Whether threaded rendering is supported by this backend.

Definition at line 189 of file ibackendplugin.h.

◆ LoadDocument()

virtual IDocument_ptr LC::Monocle::IBackendPlugin::LoadDocument ( const QString &  filename)
pure virtual

Loads the given document.

This method should load the document at filename and return a pointer to it, or a null pointer if the document is invalid.

The ownership is passed to the caller: that is, this backend plugin should keep no strong owning references to the returned document.

It is OK for this method to return a null or invalid document even if CanLoadDocument() returned true for this filename.

Parameters
[in]filenameThe document to load.
Returns
The document object for filename, or null pointer, or invalid document if an error has occurred.
See also
CanLoadDocument()
GetRedirection()
IDocument

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