MythTV master
service.h
Go to the documentation of this file.
1
2// Program Name: service.h
3// Created : Jan. 19, 2010
4//
5// Purpose : Base class for all Web Services
6//
7// Copyright (c) 2010 David Blain <dblain@mythtv.org>
8//
9// Licensed under the GPL v2 or later, see LICENSE for details
10//
12
13#ifndef SERVICE_H_
14#define SERVICE_H_
15
16#include <QObject>
17#include <QMetaType>
18#include <QVariant>
19#include <QFileInfo>
20#include <QDateTime>
21#include <QString>
22
25//
26// Notes for derived classes -
27//
28// * This implementation can't handle declared default parameters
29//
30// * When called, any missing params are sent default values for its datatype
31//
32// * Q_CLASSINFO( "<methodName>_Method", "BOTH" )
33// is used to determine HTTP method type.
34// Defaults to "BOTH", available values:
35// "GET", "POST" or "BOTH"
36//
39
40class Service : public QObject
41{
42 Q_OBJECT
43
44 public:
45
46 explicit inline Service( QObject *parent = nullptr );
47
48 public:
49
51 // This method should be overridden to handle non-QObject based custom types
53
54 virtual QVariant ConvertToVariant ( int nType, void *pValue );
55
56 virtual void* ConvertToParameterPtr( int nTypeId,
57 const QString &sParamType,
58 void* pParam,
59 const QString &sValue );
60
61 static bool ToBool( const QString &sVal );
62
63 public:
64
65 bool HAS_PARAM(const QString& p) const { return m_parsedParams.contains(p); }
66 QList<QString> m_parsedParams; // lowercased
67};
68
70//
72
73inline Service::Service(QObject *parent) : QObject(parent)
74{
75 qRegisterMetaType< QFileInfo >();
76}
77
78#endif
QList< QString > m_parsedParams
Definition: service.h:66
bool HAS_PARAM(const QString &p) const
Definition: service.h:65
virtual void * ConvertToParameterPtr(int nTypeId, const QString &sParamType, void *pParam, const QString &sValue)
Definition: service.cpp:49
static bool ToBool(const QString &sVal)
Definition: service.cpp:169
Service(QObject *parent=nullptr)
Definition: service.h:73
virtual QVariant ConvertToVariant(int nType, void *pValue)
Definition: service.cpp:22