Cutelyst  2.13.0
dispatchtype.h
1 /*
2  * Copyright (C) 2013-2017 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef DISPATCHTYPE_H
19 #define DISPATCHTYPE_H
20 
21 #include <QtCore/qobject.h>
22 #include <QtCore/qstringlist.h>
23 
24 #include <Cutelyst/cutelyst_global.h>
25 
26 namespace Cutelyst {
27 
28 class Context;
29 class Action;
30 class Request;
31 class CUTELYST_LIBRARY DispatchType : public QObject
32 {
33  Q_OBJECT
34 public:
36  enum MatchType {
37  NoMatch = 0,
38  PartialMatch,
39  ExactMatch
40  };
41  Q_ENUM(MatchType)
42 
43 
46  explicit DispatchType(QObject *parent = nullptr);
47  virtual ~DispatchType();
48 
53  virtual QByteArray list() const = 0;
54 
58  virtual MatchType match(Context *c, const QString &path, const QStringList &args) const = 0;
59 
63  virtual QString uriForAction(Action *action, const QStringList &captures) const = 0;
64 
68  virtual Action *expandAction(const Context *c, Action *action) const;
69 
75  virtual bool registerAction(Action *action);
76 
87  virtual bool inUse() = 0;
88 
94  virtual bool isLowPrecedence() const;
95 
96 protected:
97  friend class Dispatcher;
98  friend class Application;
99 
103  void setupMatchedAction(Context *c, Action *action) const;
104 };
105 
106 }
107 
108 #endif // DISPATCHTYPE_H
Cutelyst::Application
The Cutelyst Application.
Definition: application.h:55
Cutelyst::Dispatcher
The Cutelyst Dispatcher.
Definition: dispatcher.h:40
Cutelyst::Context
The Cutelyst Context.
Definition: context.h:50
Cutelyst::DispatchType
Definition: dispatchtype.h:31
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Cutelyst::DispatchType::MatchType
MatchType
Definition: dispatchtype.h:36
Cutelyst::Action
This class represents a Cutelyst Action.
Definition: action.h:47