dotherside/lib/include/DOtherSide/DosQObjectImpl.h

72 lines
2.4 KiB
C
Raw Normal View History

/*
Copyright (C) 2019 Filippo Cucchetto.
Contact: https://github.com/filcuc/dotherside
This file is part of the DOtherSide library.
The DOtherSide library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the license, or (at your opinion) any later version.
The DOtherSide library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the DOtherSide library. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// std
#include <vector>
// Qt
#include <QtCore/QMutex>
#include <QtCore/QString>
#include <QtCore/QVariant>
// DOtherSide
#include "DOtherSide/DosQObject.h"
#include "DOtherSide/DOtherSideTypesCpp.h"
2016-02-27 15:07:23 +01:00
namespace DOS {
2016-01-07 17:06:13 +01:00
/// This class implement the interface IDosQObject
/// and it's injected in DosQObject
2016-01-23 18:40:17 +01:00
class DosQObjectImpl : public DosIQObjectImpl
{
public:
2016-01-16 11:29:35 +01:00
using ParentMetaCall = std::function<int(QMetaObject::Call, int, void **)>;
2016-01-07 17:06:13 +01:00
/// Constructor
2018-10-07 17:31:33 +02:00
DosQObjectImpl(ParentMetaCall parentMetaCall,
2016-01-23 18:40:17 +01:00
std::shared_ptr<const DosIQMetaObject> metaObject,
2018-10-07 17:31:33 +02:00
void *dObjectPointer,
DObjectCallback dObjectCallback);
/// @see IDosQObject::emitSignal
2016-03-28 21:36:34 +02:00
bool emitSignal(QObject *emitter, const QString &name, const std::vector<QVariant> &arguments) override;
2016-01-07 17:06:13 +01:00
/// @see IDosQObject::metaObject()
2016-02-27 15:07:23 +01:00
const QMetaObject *metaObject() const override;
/// @see IDosQObject::qt_metacall
int qt_metacall(QMetaObject::Call, int, void **) override;
private:
2016-02-27 15:07:23 +01:00
bool executeSlot(const QMetaMethod &method, void **args, int argumentsOffset = 1);
bool executeSlot(int index, void **args);
2018-10-07 17:31:33 +02:00
QVariant executeSlot(const QString &name, const std::vector<QVariant> &args);
2016-02-27 15:07:23 +01:00
bool readProperty(int index, void **args);
bool writeProperty(int index, void **args);
2016-01-16 11:29:35 +01:00
const ParentMetaCall m_parentMetaCall;
2018-10-07 17:31:33 +02:00
const std::shared_ptr<const DosIQMetaObject> m_metaObject;
void* const m_dObjectPointer = nullptr;
const DObjectCallback m_dObjectCallback;
};
} // namespace DOS