diff --git a/CMakeLists.txt b/CMakeLists.txt index 841d967..c10b6db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,9 @@ if(PyWrappers) pybind11_add_module(pysciqlopcore src/pybind11_wrappers/CoreWrappers.cpp) target_link_libraries(pysciqlopcore PUBLIC sciqlopcore) + pybind11_add_module(pysciqlopcatalogs src/pybind11_wrappers/CatalogWrappers.cpp) + target_link_libraries(pysciqlopcatalogs PUBLIC sciqlopcore) + add_library(pysciqlop src/pybind11_wrappers/pywrappers_common.h) target_link_libraries(pysciqlop PUBLIC Qt5::Core) target_include_directories(pysciqlop PUBLIC diff --git a/src/pybind11_wrappers/CatalogWrappers.cpp b/src/pybind11_wrappers/CatalogWrappers.cpp new file mode 100644 index 0000000..1a96506 --- /dev/null +++ b/src/pybind11_wrappers/CatalogWrappers.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include +#include +#include "pywrappers_common.h" +#include +#include + +#include +#include +#include +#include + + +namespace py = pybind11; + +std::ostream &operator <<(std::ostream& os, const DBEvent& e) +{ + os << std::endl; + return os; +} + +#define JAVA_LIKE_PROPERTY(name, className) .def_property("##name", &className::get##name, &className::set##name) + +PYBIND11_MODULE(pysciqlopcatalogs,m){ + + py::class_>(m,"DBEventProduct") + JAVA_LIKE_PROPERTY(TStart, DBEventProduct) + JAVA_LIKE_PROPERTY(TEnd, DBEventProduct) + JAVA_LIKE_PROPERTY(ProductId, DBEventProduct) + JAVA_LIKE_PROPERTY(CreationDateTime, DBEventProduct) + JAVA_LIKE_PROPERTY(ModificationDateTime, DBEventProduct) + JAVA_LIKE_PROPERTY(Event, DBEventProduct) + ; + + py::class_>(m, "DBEvent") + JAVA_LIKE_PROPERTY(Name,DBEvent) + JAVA_LIKE_PROPERTY(UniqId,DBEvent) + JAVA_LIKE_PROPERTY(Author,DBEvent) + JAVA_LIKE_PROPERTY(Repository,DBEvent) + JAVA_LIKE_PROPERTY(CreationDateTime,DBEvent) + JAVA_LIKE_PROPERTY(ModificationDateTime,DBEvent) + JAVA_LIKE_PROPERTY(EventProducts,DBEvent) + .def_property_readonly("TStart", &DBEvent::getTStart) + .def_property_readonly("TEnd", &DBEvent::getTEnd) + .def("__repr__",__repr__); + + py::class_>(m,"DBEventProduct") + JAVA_LIKE_PROPERTY(CatalogueId, DBCatalogue) + JAVA_LIKE_PROPERTY(UniqId, DBCatalogue) + JAVA_LIKE_PROPERTY(Name, DBCatalogue) + JAVA_LIKE_PROPERTY(Author, DBCatalogue) + JAVA_LIKE_PROPERTY(Repository, DBCatalogue) + JAVA_LIKE_PROPERTY(CreationDateTime, DBCatalogue) + JAVA_LIKE_PROPERTY(ModificationDateTime, DBCatalogue) + ; + + py::class_(m, "CatalogueController") + .def("addDB", &CatalogueController::addDB) + .def("saveDB", &CatalogueController::saveDB) + .def("addEvent", &CatalogueController::addEvent) + .def("updateEvent", &CatalogueController::updateEvent) + .def("updateEventProduct", &CatalogueController::updateEventProduct) + .def("removeEvent", &CatalogueController::removeEvent) + .def("saveEvent", &CatalogueController::saveEvent) + .def("discardEvent", &CatalogueController::discardEvent) + .def("eventHasChanges", &CatalogueController::eventHasChanges) + .def("addCatalogue", &CatalogueController::addCatalogue) + .def("updateCatalogue", &CatalogueController::updateCatalogue) + .def("removeCatalogue", &CatalogueController::removeCatalogue) + .def("saveCatalogue", &CatalogueController::saveCatalogue) + .def("discardCatalogue", &CatalogueController::discardCatalogue) + .def("saveAll", &CatalogueController::saveAll) + .def("hasChanges", &CatalogueController::hasChanges) + ; +} +