##// END OF EJS Templates
Some work on the catalog classes wrapper...
jeandet -
r82:39bf3ff40b41
parent child
Show More
@@ -1,1 +1,1
1 Subproject commit 9c518f27796798fda36a1495b329808177c4c150
1 Subproject commit d0c3ee3acc18bc73c955df31eb55e0af1d67dc29
@@ -1,81 +1,102
1 #include "pywrappers_common.h"
1 #include "pywrappers_common.h"
2
3 #include <Catalogue.hpp>
4 #include <Catalogue/CatalogueController.h>
5 #include <Event.hpp>
2 #include <QDate>
6 #include <QDate>
3 #include <QString>
7 #include <QString>
4 #include <QTime>
8 #include <QTime>
5 #include <QUuid>
9 #include <QUuid>
6 #include <QVector>
10 #include <QVector>
11 #include <Repository.hpp>
7 #include <pybind11/operators.h>
12 #include <pybind11/operators.h>
8 #include <pybind11/pybind11.h>
13 #include <pybind11/pybind11.h>
9 #include <sstream>
14 #include <sstream>
10 #include <string>
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 namespace py = pybind11;
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 // os << std::endl;
21 // os << std::endl;
23 // return os;
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 PYBIND11_MODULE(pysciqlopcatalogs, m)
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")
32 py::class_<CatalogueController::Event_t, CatalogueController::Event_ptr>(
33 // JAVA_LIKE_PROPERTY(TStart, DBEventProduct)
33 m, "Event")
34 // JAVA_LIKE_PROPERTY(TEnd, DBEventProduct)
34 .def_readwrite("name", &CatalogueController::Event_t::name)
35 // JAVA_LIKE_PROPERTY(ProductId, DBEventProduct)
35 .def_readwrite("tags", &CatalogueController::Event_t::tags)
36 // JAVA_LIKE_PROPERTY(CreationDateTime, DBEventProduct)
36 .def_readwrite("products", &CatalogueController::Event_t::products)
37 // JAVA_LIKE_PROPERTY(ModificationDateTime, DBEventProduct)
37 .def_readonly("uuid", &CatalogueController::Event_t::uuid)
38 // JAVA_LIKE_PROPERTY(Event, DBEventProduct)
38 .def_property_readonly("start_time",
39 // ;
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")
45 py::class_<CatalogueController::Catalogue_t,
42 // JAVA_LIKE_PROPERTY(Name,DBEvent)
46 CatalogueController::Catalogue_ptr>(m, "Catalogue")
43 // JAVA_LIKE_PROPERTY(UniqId,DBEvent)
47 .def_readwrite("name", &CatalogueController::Catalogue_t::name)
44 // JAVA_LIKE_PROPERTY(Author,DBEvent)
48 .def_readonly("uuid", &CatalogueController::Catalogue_t::uuid)
45 // JAVA_LIKE_PROPERTY(Repository,DBEvent)
49 .def_property_readonly("start_time",
46 // JAVA_LIKE_PROPERTY(CreationDateTime,DBEvent)
50 &CatalogueController::Catalogue_t::startTime)
47 // JAVA_LIKE_PROPERTY(ModificationDateTime,DBEvent)
51 .def_property_readonly("stop_time",
48 // JAVA_LIKE_PROPERTY(EventProducts,DBEvent)
52 &CatalogueController::Catalogue_t::stopTime)
49 // .def_property_readonly("TStart", &DBEvent::getTStart)
53 .def("add", &CatalogueController::Catalogue_t::add)
50 // .def_property_readonly("TEnd", &DBEvent::getTEnd)
54 .def("remove", py::overload_cast<CatalogueController::Event_ptr&>(
51 // .def("__repr__",__repr__<DBEvent>);
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")
65 py::class_<CatalogueController>(m, "CatalogueController")
54 // JAVA_LIKE_PROPERTY(CatalogueId, DBCatalogue)
66 .def("load_repository", &CatalogueController::loadRepository)
55 // JAVA_LIKE_PROPERTY(UniqId, DBCatalogue)
67 .def("save_repository", &CatalogueController::saveRepository)
56 // JAVA_LIKE_PROPERTY(Name, DBCatalogue)
68 .def("events", py::overload_cast<>(&CatalogueController::events))
57 // JAVA_LIKE_PROPERTY(Author, DBCatalogue)
69 .def("events",
58 // JAVA_LIKE_PROPERTY(Repository, DBCatalogue)
70 py::overload_cast<const QString&>(&CatalogueController::events))
59 // JAVA_LIKE_PROPERTY(CreationDateTime, DBCatalogue)
71 .def("events",
60 // JAVA_LIKE_PROPERTY(ModificationDateTime, DBCatalogue)
72 py::overload_cast<const CatalogueController::Catalogue_ptr&>(
61 // ;
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")
89 .def("add", py::overload_cast<const QString&>(&CatalogueController::add))
64 // .def("addDB", &CatalogueController::addDB)
90 .def("add", py::overload_cast<const QString&, const QString&>(
65 // .def("saveDB", &CatalogueController::saveDB)
91 &CatalogueController::add))
66 // .def("addEvent", &CatalogueController::addEvent)
92 .def("add", py::overload_cast<CatalogueController::Event_ptr,
67 // .def("updateEvent", &CatalogueController::updateEvent)
93 CatalogueController::Catalogue_ptr>(
68 // .def("updateEventProduct", &CatalogueController::updateEventProduct)
94 &CatalogueController::add))
69 // .def("removeEvent", &CatalogueController::removeEvent)
95 .def("add",
70 // .def("saveEvent", &CatalogueController::saveEvent)
96 py::overload_cast<CatalogueController::Event_ptr, const QString&>(
71 // .def("discardEvent", &CatalogueController::discardEvent)
97 &CatalogueController::add))
72 // .def("eventHasChanges", &CatalogueController::eventHasChanges)
98 .def("add", [](CatalogueController& ctrlr,
73 // .def("addCatalogue", &CatalogueController::addCatalogue)
99 CatalogueController::Event_ptr event) {
74 // .def("updateCatalogue", &CatalogueController::updateCatalogue)
100 return ctrlr.add(event);
75 // .def("removeCatalogue", &CatalogueController::removeCatalogue)
101 });
76 // .def("saveCatalogue", &CatalogueController::saveCatalogue)
77 // .def("discardCatalogue", &CatalogueController::discardCatalogue)
78 // .def("saveAll", &CatalogueController::saveAll)
79 // .def("hasChanges", &CatalogueController::hasChanges)
80 // ;
81 }
102 }
General Comments 0
You need to be logged in to leave comments. Login now