File: WADORSResponse.cpp

package info (click to toggle)
odil 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,476 kB
  • sloc: cpp: 55,982; python: 3,947; javascript: 460; xml: 182; makefile: 99; sh: 36
file content (78 lines) | stat: -rw-r--r-- 2,743 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*************************************************************************
 * odil - Copyright (C) Universite de Strasbourg
 * Distributed under the terms of the CeCILL-B license, as published by
 * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 * for details.
 ************************************************************************/

#include <algorithm>
#include <vector>

#include <pybind11/pybind11.h>
#include <pybind11/operators.h>
#include <pybind11/stl.h>

#include "odil/DataSet.h"
#include "odil/webservices/BulkData.h"
#include "odil/webservices/WADORSResponse.h"
#include "odil/Value.h"

void
set_data_sets(
    odil::webservices::WADORSResponse& self, pybind11::sequence data_sets)
{
    odil::Value::DataSets cpp_val(pybind11::len(data_sets));
    std::transform(
        data_sets.begin(), data_sets.end(), cpp_val.begin(), 
        [](pybind11::handle const & h) 
        { return h.cast<std::shared_ptr<odil::DataSet>>(); });
    self.set_data_sets(cpp_val);
}

void
set_bulk_data(
    odil::webservices::WADORSResponse& self, pybind11::sequence bulk_data)
{
    std::vector<odil::webservices::BulkData> cpp_val(pybind11::len(bulk_data));
    std::transform(
        bulk_data.begin(), bulk_data.end(), cpp_val.begin(), 
        [](pybind11::handle const & h) 
        { return h.cast<odil::webservices::BulkData>(); });
    self.set_bulk_data(cpp_val);
}

void
wrap_webservices_WADORSResponse(pybind11::module & m)
{
    using namespace pybind11;
    using namespace odil;
    using namespace odil::webservices;

    class_<WADORSResponse>(m, "WADORSResponse")
        .def(init<>())
        .def(init<HTTPResponse>())
        .def(
            "get_data_sets",
            static_cast<
                Value::DataSets const &(WADORSResponse::*)() const
            >(&WADORSResponse::get_data_sets))
        .def("set_data_sets", &set_data_sets)
        .def(
            "get_bulk_data",
            static_cast<
                std::vector<BulkData> const &(WADORSResponse::*)() const
            >(&WADORSResponse::get_bulk_data))
        .def("set_bulk_data", set_bulk_data)
        .def("is_partial", &WADORSResponse::is_partial)
        .def("set_partial", &WADORSResponse::set_partial)
        .def("get_type", &WADORSResponse::get_type)
        .def("get_representation", &WADORSResponse::get_representation)
        .def("respond_dicom", &WADORSResponse::respond_dicom)
        .def("respond_bulk_data", &WADORSResponse::respond_bulk_data)
        .def("respond_pixel_data", &WADORSResponse::respond_pixel_data)
        .def("get_http_response", &WADORSResponse::get_http_response)
        .def(self == self)
        .def(self != self)
    ;
}