PyTestMockPluginWrapper.cpp
86 lines
| 3.0 KiB
| text/x-c
|
CppLexer
r1366 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the SciQLOP Software | ||||
-- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | ||||
-- | ||||
-- This program is free software; you can redistribute it and/or modify | ||||
-- it under the terms of the GNU General Public License as published by | ||||
-- the Free Software Foundation; either version 2 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program 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 General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
#include <memory> | ||||
r1423 | #include <sstream> | |||
#include <string> | ||||
r1366 | ||||
r1423 | #include <pybind11/chrono.h> | |||
r1366 | #include <pybind11/embed.h> | |||
#include <pybind11/numpy.h> | ||||
r1423 | #include <pybind11/operators.h> | |||
#include <pybind11/pybind11.h> | ||||
r1366 | ||||
r1423 | #include <Common/DateUtils.h> | |||
#include <Data/DataSeriesType.h> | ||||
#include <Data/DateTimeRange.h> | ||||
r1366 | #include <SqpApplication.h> | |||
#include <Time/TimeController.h> | ||||
r1423 | #include <Variable/VariableController2.h> | |||
r1366 | ||||
#include <CosinusProvider.h> | ||||
r1423 | #include <MockPlugin.h> | |||
r1366 | ||||
#include <QFile> | ||||
#include <CoreWrappers.h> | ||||
r1423 | #include <pywrappers_common.h> | |||
r1366 | ||||
using namespace std::chrono; | ||||
namespace py = pybind11; | ||||
r1423 | PYBIND11_MODULE(pytestmockplugin, m) | |||
{ | ||||
r1366 | ||||
int argc = 0; | ||||
r1423 | char** argv = nullptr; | |||
r1366 | SqpApplication::setOrganizationName("LPP"); | |||
SqpApplication::setOrganizationDomain("lpp.fr"); | ||||
SqpApplication::setApplicationName("SciQLop"); | ||||
static SqpApplication app(argc, argv); | ||||
auto qtmod = py::module::import("sciqlopqt"); | ||||
auto sciqlopmod = py::module::import("pysciqlopcore"); | ||||
m.doc() = ""; | ||||
r1423 | py::class_<VariableController2>(m, "VariableController2") | |||
.def_static("createVariable", | ||||
[](const QString& name, std::shared_ptr<IDataProvider> provider, | ||||
const DateTimeRange& range) { | ||||
return sqpApp->variableController().createVariable(name, | ||||
{ { "cosinusType", "spectrogram" }, { "cosinusFrequency", "0.1" } }, provider, | ||||
range); | ||||
}); | ||||
py::class_<TimeController>(m, "TimeController").def_static("setTime", [](DateTimeRange range) { | ||||
sqpApp->timeController().setDateTimeRange(range); | ||||
r1366 | }); | |||
auto mock_provider = std::make_shared<CosinusProvider>(); | ||||
r1423 | m.def("mock_provider", [mock_provider]() { return mock_provider; }, | |||
py::return_value_policy::copy); | ||||
r1366 | ||||
r1423 | py::class_<CosinusProvider, std::shared_ptr<CosinusProvider>, IDataProvider>( | |||
m, "CosinusProvider"); | ||||
r1366 | } | |||