QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches
IxFunction.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** https://www.qxorm.com/
4** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
5**
6** This file is part of the QxOrm library
7**
8** This software is provided 'as-is', without any express or implied
9** warranty. In no event will the authors be held liable for any
10** damages arising from the use of this software
11**
12** Commercial Usage
13** Licensees holding valid commercial QxOrm licenses may use this file in
14** accordance with the commercial license agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Lionel Marty
17**
18** GNU General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU
20** General Public License version 3.0 as published by the Free Software
21** Foundation and appearing in the file 'license.gpl3.txt' included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU General Public License version 3.0 requirements will be
24** met : http://www.gnu.org/copyleft/gpl.html
25**
26** If you are unsure which license is appropriate for your use, or
27** if you have questions regarding the use of this file, please contact :
28** contact@qxorm.com
29**
30****************************************************************************/
31
32#ifndef _IX_FUNCTION_H_
33#define _IX_FUNCTION_H_
34
35#ifdef _MSC_VER
36#pragma once
37#endif
38
46#include <QxCommon/QxAny.h>
47#include <QxCommon/QxBool.h>
49
51
54
56
57namespace qx {
58
64{
65
66protected:
67
68 QString m_sKey;
69 QString m_sSeparator;
71
72public:
73
74 typedef std::vector<qx::any> type_any_params;
75
77 virtual ~IxFunction() { ; }
78
79 QString getKey() const { return m_sKey; }
80 QString getSeparator() const { return m_sSeparator; }
81 QString getDescription() const { return m_sDescription; }
82
83 void setKey(const QString & s) { m_sKey = s; }
84 void setSeparator(const QString & s) { m_sSeparator = s; }
85 void setDescription(const QString & s) { m_sDescription = s; }
86
87 virtual int getParamCount() const = 0;
88
89 virtual qx_bool invoke(const QString & params = QString(), qx::any * ret = NULL) const = 0;
90 virtual qx_bool invoke(const type_any_params & params, qx::any * ret = NULL) const = 0;
91 virtual qx_bool invoke(void * pOwner, const QString & params = QString(), qx::any * ret = NULL) const = 0;
92 virtual qx_bool invoke(void * pOwner, const type_any_params & params, qx::any * ret = NULL) const = 0;
93
94 virtual qx_bool isValidFct() const = 0;
95 virtual qx_bool isValidParams(const QString & params) const = 0;
96 virtual qx_bool isValidParams(const type_any_params & params) const = 0;
97
98 template <class T>
99 qx_bool isValidOwner(void * pOwner, T * dummy) const
100 {
101 Q_UNUSED(dummy);
102 typedef std::is_same<T, void> qx_verify_owner_tmp;
103 static_assert(! qx_verify_owner_tmp::value, "! qx_verify_owner_tmp::value");
104 if (! pOwner) { return qx_bool(false, 0, QX_FUNCTION_ERR_NULL_OWNER); }
105#ifndef _QX_NO_RTTI
106 if (! dynamic_cast<T *>(static_cast<T *>(pOwner))) { return qx_bool(false, 0, QX_FUNCTION_ERR_INVALID_OWNER); }
107#endif // _QX_NO_RTTI
108 return true;
109 }
110
111 template <class T>
112 qx_bool isValid(const T & params) const
113 {
114 qx_bool bValid = isValidFct(); if (! bValid) { return bValid; };
115 bValid = isValidParams(params); if (! bValid) { return bValid; };
116 return true;
117 }
118
119 template <class T, class U>
120 qx_bool isValid(void * pOwner, const T & params, U * dummy) const
121 {
122 Q_UNUSED(dummy);
123 qx_bool bValid = isValidFct(); if (! bValid) { return bValid; };
124 bValid = isValidParams(params); if (! bValid) { return bValid; };
125 bValid = isValidOwner<U>(pOwner, NULL); if (! bValid) { return bValid; };
126 return true;
127 }
128
129};
130
131typedef std::shared_ptr<IxFunction> IxFunction_ptr;
133typedef std::shared_ptr<IxFunctionX> IxFunctionX_ptr;
134
135} // namespace qx
136
137#endif // _IX_FUNCTION_H_
qx::any : basic implementation of boost::any (written by Kevlin Henney) when boost dependency is not ...
qx_bool : QxOrm library boolean type with code and description message when an error occured
qx::QxBool qx_bool
Definition QxBool.h:150
QxOrm thread-safe container (keep insertion order + quick access by index + quick access by key)
Define all messages when an error occured using QxFunction module of QxOrm library.
#define QX_FUNCTION_ERR_NULL_OWNER
#define QX_FUNCTION_ERR_INVALID_OWNER
Used by introspection engine (IxClass, IxDataMember, IxFunction, etc.) to add meta-data (property bag...
qx::IxFunction : common interface for all functions registered into QxOrm context (used by introspect...
Definition IxFunction.h:64
virtual qx_bool invoke(const QString &params=QString(), qx::any *ret=NULL) const =0
void setDescription(const QString &s)
Definition IxFunction.h:85
virtual qx_bool invoke(const type_any_params &params, qx::any *ret=NULL) const =0
void setKey(const QString &s)
Definition IxFunction.h:83
virtual qx_bool isValidFct() const =0
QString getSeparator() const
Definition IxFunction.h:80
QString m_sKey
Function key.
Definition IxFunction.h:68
virtual qx_bool invoke(void *pOwner, const type_any_params &params, qx::any *ret=NULL) const =0
virtual ~IxFunction()
Definition IxFunction.h:77
virtual qx_bool invoke(void *pOwner, const QString &params=QString(), qx::any *ret=NULL) const =0
virtual int getParamCount() const =0
virtual qx_bool isValidParams(const type_any_params &params) const =0
qx_bool isValidOwner(void *pOwner, T *dummy) const
Definition IxFunction.h:99
void setSeparator(const QString &s)
Definition IxFunction.h:84
virtual qx_bool isValidParams(const QString &params) const =0
qx_bool isValid(void *pOwner, const T &params, U *dummy) const
Definition IxFunction.h:120
QString m_sDescription
Function description.
Definition IxFunction.h:70
QString getKey() const
Definition IxFunction.h:79
qx_bool isValid(const T &params) const
Definition IxFunction.h:112
QString getDescription() const
Definition IxFunction.h:81
QString m_sSeparator
Separator character(s) for 'QString' parameters type.
Definition IxFunction.h:69
std::vector< qx::any > type_any_params
Definition IxFunction.h:74
qx_bool : boolean type with code and description message when an error occured
Definition QxBool.h:71
qx::QxCollection<Key, Value> : QxOrm thread-safe container (keep insertion order + quick access by in...
qx::QxPropertyBag : used by introspection engine (IxClass, IxDataMember, IxFunction,...
Root namespace for all QxOrm library features.
QxCollection< QString, IxFunction_ptr > IxFunctionX
Definition IxFunction.h:132
std::shared_ptr< IxFunctionX > IxFunctionX_ptr
Definition IxFunction.h:133
std::shared_ptr< IxFunction > IxFunction_ptr
Definition IxFunction.h:131
qx::trait::remove_attr<T>::type : return a type without pointer, const, reference and/or volatile att...