cutelyst 4.8.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst::DispatchType Class Referenceabstract

Abstract class to described a dispatch type. More...

#include <Cutelyst/DispatchType>

Inheritance diagram for Cutelyst::DispatchType:

Public Types

enum  MatchType { NoMatch , PartialMatch , ExactMatch }
 

Public Member Functions

 DispatchType (QObject *parent=nullptr)
 
virtual ~DispatchType ()
 
virtual ActionexpandAction (const Context *c, Action *action) const
 
virtual bool inUse ()=0
 
virtual bool isLowPrecedence () const
 
virtual QByteArray list () const =0
 
virtual MatchType match (Context *c, QStringView path, const QStringList &args) const =0
 
virtual bool registerAction (Action *action)
 
virtual QString uriForAction (Action *action, const QStringList &captures) const =0
 

Protected Member Functions

void setupMatchedAction (Context *c, Action *action) const
 

Friends

class Application
 
class Dispatcher
 

Detailed Description

This abstract class can be used to describe a dispatch type.

Definition at line 24 of file dispatchtype.h.

Member Enumeration Documentation

◆ MatchType

This enum is used to describe the kind of a match

Definition at line 29 of file dispatchtype.h.

Constructor & Destructor Documentation

◆ DispatchType()

DispatchType::DispatchType ( QObject *  parent = nullptr)
explicit

Construct a new DispatchType object with the given parent.

Definition at line 11 of file dispatchtype.cpp.

◆ ~DispatchType()

DispatchType::~DispatchType ( )
virtual

Destroys the DispatchType object.

Definition at line 16 of file dispatchtype.cpp.

Member Function Documentation

◆ expandAction()

Action * DispatchType::expandAction ( const Context c,
Action action 
) const
virtual

Expand the action to a list of actions which is used in chained. The default implementation does nothing and returns a nullptr.

Reimplemented in Cutelyst::DispatchTypeChained.

Definition at line 20 of file dispatchtype.cpp.

◆ inUse()

virtual bool Cutelyst::DispatchType::inUse ( )
pure virtual

If false the dispatcher will be unregistered for performance reasons. This method can be used to prepare actions for dispatcher as in a Chain of Actions there is no garantee of registering order.

In the common case if the dispatcher has registered any action, or in some special case that it doesn't need actions it will return true.

Implemented in Cutelyst::DispatchTypeChained, and Cutelyst::DispatchTypePath.

◆ isLowPrecedence()

bool DispatchType::isLowPrecedence ( ) const
virtual

Returns true if the dispatch type has low precedence when the precedence is the same the Class name is used to sort them.

The default implementation return false.

Definition at line 40 of file dispatchtype.cpp.

◆ list()

virtual QByteArray Cutelyst::DispatchType::list ( ) const
pure virtual

Lists the registered actions. Has to be implemented by subclasses.

Implemented in Cutelyst::DispatchTypeChained, and Cutelyst::DispatchTypePath.

◆ match()

virtual MatchType Cutelyst::DispatchType::match ( Context c,
QStringView  path,
const QStringList &  args 
) const
pure virtual

Returns the MatchType for the given path and args. Has to be implemented by subclasses.

Implemented in Cutelyst::DispatchTypeChained, and Cutelyst::DispatchTypePath.

◆ registerAction()

bool DispatchType::registerAction ( Action action)
virtual

Register an action and return true on success. The default implementation does nothing and returns always true.

Reimplemented in Cutelyst::DispatchTypeChained, and Cutelyst::DispatchTypePath.

Definition at line 34 of file dispatchtype.cpp.

◆ setupMatchedAction()

void DispatchType::setupMatchedAction ( Context c,
Action action 
) const
protected

Sets the matched action to the Context c.

Definition at line 45 of file dispatchtype.cpp.

References Cutelyst::Context::action.

Referenced by Cutelyst::DispatchTypeChained::match(), and Cutelyst::DispatchTypePath::match().

◆ uriForAction()

QString DispatchType::uriForAction ( Action action,
const QStringList &  captures 
) const
pure virtual

Returns an uri for an action with given captures. Has to be implemented by subclasses.

Implemented in Cutelyst::DispatchTypeChained, and Cutelyst::DispatchTypePath.

Definition at line 27 of file dispatchtype.cpp.

Friends And Related Symbol Documentation

◆ Application

friend class Application
friend

Definition at line 101 of file dispatchtype.h.

◆ Dispatcher

friend class Dispatcher
friend

Definition at line 100 of file dispatchtype.h.