PDI 1.10.0

the PDI data interface

python_ref_wrapper.h
1/*******************************************************************************
2* Copyright (C) 2020 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of CEA nor the names of its contributors may be used to
13* endorse or promote products derived from this software without specific
14* prior written permission.
15*
16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22* THE SOFTWARE.
23******************************************************************************/
24
25#ifndef PDI_PYTHON_REF_WRAPPER
26#define PDI_PYTHON_REF_WRAPPER
27
28#include <cstddef>
29#include <string>
30
31#include <pybind11/pybind11.h>
32
33#include <pdi/ref_any.h>
34
35namespace PDI {
36
37class PDI_EXPORT Python_ref_wrapper
38{
40 Ref m_ref;
41
42public:
47
52 pybind11::object getattribute(std::string member_name);
53
58 void setattribute(std::string member_name, const pybind11::object value);
59
64 pybind11::object getitem(size_t index);
65};
66
67} // namespace PDI
68
69#endif // PDI_PYTHON_REF_WRAPPER
pybind11::object getattribute(std::string member_name)
Gets a member if ref has a record datatype.
pybind11::object getitem(size_t index)
Gets element of the array if ref has a array datatype.
Python_ref_wrapper(Ref ref)
Creates python reference wrapper.
void setattribute(std::string member_name, const pybind11::object value)
Sets a member value if ref has a record datatype.
Definition array_datatype.h:38
Ref_any< false, false > Ref
Definition pdi_fwd.h:94