@@ -1,1 +1,1 | |||
|
1 | Subproject commit 9c518f27796798fda36a1495b329808177c4c150 | |
|
1 | Subproject commit d0c3ee3acc18bc73c955df31eb55e0af1d67dc29 |
@@ -1,81 +1,102 | |||
|
1 | 1 | #include "pywrappers_common.h" |
|
2 | ||
|
3 | #include <Catalogue.hpp> | |
|
4 | #include <Catalogue/CatalogueController.h> | |
|
5 | #include <Event.hpp> | |
|
2 | 6 | #include <QDate> |
|
3 | 7 | #include <QString> |
|
4 | 8 | #include <QTime> |
|
5 | 9 | #include <QUuid> |
|
6 | 10 | #include <QVector> |
|
11 | #include <Repository.hpp> | |
|
7 | 12 | #include <pybind11/operators.h> |
|
8 | 13 | #include <pybind11/pybind11.h> |
|
9 | 14 | #include <sstream> |
|
10 | 15 | #include <string> |
|
11 | 16 | |
|
12 | #include <Catalogue/CatalogueController.h> | |
|
13 | //#include <DBCatalogue.h> | |
|
14 | //#include <DBEvent.h> | |
|
15 | //#include <DBEventProduct.h> | |
|
16 | ||
|
17 | ||
|
18 | 17 | namespace py = pybind11; |
|
19 | 18 | |
|
20 | //std::ostream& operator<<(std::ostream& os, const DBEvent& e) | |
|
19 | // std::ostream& operator<<(std::ostream& os, const DBEvent& e) | |
|
21 | 20 | //{ |
|
22 | 21 | // os << std::endl; |
|
23 | 22 | // return os; |
|
24 | 23 | //} |
|
25 | 24 | |
|
26 | #define JAVA_LIKE_PROPERTY(name, className) \ | |
|
27 | .def_property("##name", &className::get##name, &className::set##name) | |
|
28 | ||
|
29 | 25 | PYBIND11_MODULE(pysciqlopcatalogs, m) |
|
30 | 26 | { |
|
27 | py::class_<CatalogueController::Product_t>(m, "Product") | |
|
28 | .def_readwrite("name", &CatalogueController::Product_t::name) | |
|
29 | .def_readwrite("start_time", &CatalogueController::Product_t::startTime) | |
|
30 | .def_readwrite("stop_time", &CatalogueController::Product_t::stopTime); | |
|
31 | 31 | |
|
32 | // py::class_<DBEventProduct, std::shared_ptr<DBEventProduct>>(m,"DBEventProduct") | |
|
33 | // JAVA_LIKE_PROPERTY(TStart, DBEventProduct) | |
|
34 | // JAVA_LIKE_PROPERTY(TEnd, DBEventProduct) | |
|
35 | // JAVA_LIKE_PROPERTY(ProductId, DBEventProduct) | |
|
36 | // JAVA_LIKE_PROPERTY(CreationDateTime, DBEventProduct) | |
|
37 | // JAVA_LIKE_PROPERTY(ModificationDateTime, DBEventProduct) | |
|
38 | // JAVA_LIKE_PROPERTY(Event, DBEventProduct) | |
|
39 | // ; | |
|
32 | py::class_<CatalogueController::Event_t, CatalogueController::Event_ptr>( | |
|
33 | m, "Event") | |
|
34 | .def_readwrite("name", &CatalogueController::Event_t::name) | |
|
35 | .def_readwrite("tags", &CatalogueController::Event_t::tags) | |
|
36 | .def_readwrite("products", &CatalogueController::Event_t::products) | |
|
37 | .def_readonly("uuid", &CatalogueController::Event_t::uuid) | |
|
38 | .def_property_readonly("start_time", | |
|
39 | &CatalogueController::Event_t::startTime) | |
|
40 | .def_property_readonly("stop_time", | |
|
41 | &CatalogueController::Event_t::stopTime) | |
|
42 | .def(py::self == py::self) | |
|
43 | .def(py::self != py::self); | |
|
40 | 44 | |
|
41 | // py::class_<DBEvent, std::shared_ptr<DBEvent>>(m, "DBEvent") | |
|
42 | // JAVA_LIKE_PROPERTY(Name,DBEvent) | |
|
43 | // JAVA_LIKE_PROPERTY(UniqId,DBEvent) | |
|
44 | // JAVA_LIKE_PROPERTY(Author,DBEvent) | |
|
45 | // JAVA_LIKE_PROPERTY(Repository,DBEvent) | |
|
46 | // JAVA_LIKE_PROPERTY(CreationDateTime,DBEvent) | |
|
47 | // JAVA_LIKE_PROPERTY(ModificationDateTime,DBEvent) | |
|
48 | // JAVA_LIKE_PROPERTY(EventProducts,DBEvent) | |
|
49 | // .def_property_readonly("TStart", &DBEvent::getTStart) | |
|
50 | // .def_property_readonly("TEnd", &DBEvent::getTEnd) | |
|
51 | // .def("__repr__",__repr__<DBEvent>); | |
|
45 | py::class_<CatalogueController::Catalogue_t, | |
|
46 | CatalogueController::Catalogue_ptr>(m, "Catalogue") | |
|
47 | .def_readwrite("name", &CatalogueController::Catalogue_t::name) | |
|
48 | .def_readonly("uuid", &CatalogueController::Catalogue_t::uuid) | |
|
49 | .def_property_readonly("start_time", | |
|
50 | &CatalogueController::Catalogue_t::startTime) | |
|
51 | .def_property_readonly("stop_time", | |
|
52 | &CatalogueController::Catalogue_t::stopTime) | |
|
53 | .def("add", &CatalogueController::Catalogue_t::add) | |
|
54 | .def("remove", py::overload_cast<CatalogueController::Event_ptr&>( | |
|
55 | &CatalogueController::Catalogue_t::remove)) | |
|
56 | .def("remove", py::overload_cast<const CatalogueController::uuid_t&>( | |
|
57 | &CatalogueController::Catalogue_t::remove)) | |
|
58 | .def("event", | |
|
59 | [](const CatalogueController::Catalogue_t& catalogue, | |
|
60 | const CatalogueController::uuid_t& uuid) { | |
|
61 | return catalogue.event(uuid); | |
|
62 | }) | |
|
63 | .def("__contains__", &CatalogueController::Catalogue_t::contains); | |
|
52 | 64 | |
|
53 | // py::class_<DBCatalogue, std::shared_ptr<DBCatalogue>>(m,"DBEventProduct") | |
|
54 | // JAVA_LIKE_PROPERTY(CatalogueId, DBCatalogue) | |
|
55 | // JAVA_LIKE_PROPERTY(UniqId, DBCatalogue) | |
|
56 | // JAVA_LIKE_PROPERTY(Name, DBCatalogue) | |
|
57 | // JAVA_LIKE_PROPERTY(Author, DBCatalogue) | |
|
58 | // JAVA_LIKE_PROPERTY(Repository, DBCatalogue) | |
|
59 | // JAVA_LIKE_PROPERTY(CreationDateTime, DBCatalogue) | |
|
60 | // JAVA_LIKE_PROPERTY(ModificationDateTime, DBCatalogue) | |
|
61 | // ; | |
|
65 | py::class_<CatalogueController>(m, "CatalogueController") | |
|
66 | .def("load_repository", &CatalogueController::loadRepository) | |
|
67 | .def("save_repository", &CatalogueController::saveRepository) | |
|
68 | .def("events", py::overload_cast<>(&CatalogueController::events)) | |
|
69 | .def("events", | |
|
70 | py::overload_cast<const QString&>(&CatalogueController::events)) | |
|
71 | .def("events", | |
|
72 | py::overload_cast<const CatalogueController::Catalogue_ptr&>( | |
|
73 | &CatalogueController::events)) | |
|
74 | .def("catalogues", py::overload_cast<>(&CatalogueController::catalogues)) | |
|
75 | .def("catalogues", | |
|
76 | py::overload_cast<const QString&>(&CatalogueController::catalogues)) | |
|
77 | .def("has_unsaved_changes", &CatalogueController::hasUnsavedChanges) | |
|
78 | .def("repository", py::overload_cast<CatalogueController::Event_ptr>( | |
|
79 | &CatalogueController::repository)) | |
|
80 | .def("repository", py::overload_cast<CatalogueController::Catalogue_ptr>( | |
|
81 | &CatalogueController::repository)) | |
|
82 | .def("save", py::overload_cast<CatalogueController::Event_ptr>( | |
|
83 | &CatalogueController::save)) | |
|
84 | .def("save", py::overload_cast<CatalogueController::Catalogue_ptr>( | |
|
85 | &CatalogueController::save)) | |
|
86 | .def("save", | |
|
87 | py::overload_cast<const QString&>(&CatalogueController::save)) | |
|
62 | 88 | |
|
63 | // py::class_<CatalogueController>(m, "CatalogueController") | |
|
64 | // .def("addDB", &CatalogueController::addDB) | |
|
65 |
|
|
|
66 |
|
|
|
67 | // .def("updateEvent", &CatalogueController::updateEvent) | |
|
68 | // .def("updateEventProduct", &CatalogueController::updateEventProduct) | |
|
69 | // .def("removeEvent", &CatalogueController::removeEvent) | |
|
70 | // .def("saveEvent", &CatalogueController::saveEvent) | |
|
71 |
|
|
|
72 | // .def("eventHasChanges", &CatalogueController::eventHasChanges) | |
|
73 | // .def("addCatalogue", &CatalogueController::addCatalogue) | |
|
74 | // .def("updateCatalogue", &CatalogueController::updateCatalogue) | |
|
75 | // .def("removeCatalogue", &CatalogueController::removeCatalogue) | |
|
76 | // .def("saveCatalogue", &CatalogueController::saveCatalogue) | |
|
77 | // .def("discardCatalogue", &CatalogueController::discardCatalogue) | |
|
78 | // .def("saveAll", &CatalogueController::saveAll) | |
|
79 | // .def("hasChanges", &CatalogueController::hasChanges) | |
|
80 | // ; | |
|
89 | .def("add", py::overload_cast<const QString&>(&CatalogueController::add)) | |
|
90 | .def("add", py::overload_cast<const QString&, const QString&>( | |
|
91 | &CatalogueController::add)) | |
|
92 | .def("add", py::overload_cast<CatalogueController::Event_ptr, | |
|
93 | CatalogueController::Catalogue_ptr>( | |
|
94 | &CatalogueController::add)) | |
|
95 | .def("add", | |
|
96 | py::overload_cast<CatalogueController::Event_ptr, const QString&>( | |
|
97 | &CatalogueController::add)) | |
|
98 | .def("add", [](CatalogueController& ctrlr, | |
|
99 | CatalogueController::Event_ptr event) { | |
|
100 | return ctrlr.add(event); | |
|
101 | }); | |
|
81 | 102 | } |
General Comments 0
You need to be logged in to leave comments.
Login now