Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
Converters.h
Go to the documentation of this file.
1#ifndef CPYCPPYY_CONVERTERS_H
2#define CPYCPPYY_CONVERTERS_H
3
4// Bindings
5#include "Dimensions.h"
6
7// Standard
8#include <string>
9
10
11namespace CPyCppyy {
12
13struct Parameter;
14struct CallContext;
15
16class CPYCPPYY_CLASS_EXPORT Converter {
17public:
18 virtual ~Converter();
19
20 Converter() = default;
21
22 Converter(Converter const& other) = delete;
23 Converter(Converter && other) = delete;
24 Converter& operator=(Converter const& other) = delete;
25 Converter& operator=(Converter && other) = delete;
26
27public:
28 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr) = 0;
29 virtual PyObject* FromMemory(void* address);
30 virtual bool ToMemory(PyObject* value, void* address, PyObject* ctxt = nullptr);
31 virtual bool HasState() { return false; }
32};
33
34// create/destroy converter from fully qualified type (public API)
35CPYCPPYY_EXPORT Converter* CreateConverter(const std::string& fullType, cdims_t dims = 0);
36CPYCPPYY_EXPORT void DestroyConverter(Converter* p);
37typedef Converter* (*cf_t)(cdims_t d);
38CPYCPPYY_EXPORT bool RegisterConverter(const std::string& name, cf_t fac);
39CPYCPPYY_EXPORT bool UnregisterConverter(const std::string& name);
40
41
42// converters for special cases (only here b/c of external use of StrictInstancePtrConverter)
44public:
45 VoidArrayConverter(bool keepControl = true) { fKeepControl = keepControl; }
46
47public:
48 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr);
49 virtual PyObject* FromMemory(void* address);
50 virtual bool ToMemory(PyObject* value, void* address, PyObject* ctxt = nullptr);
51 virtual bool HasState() { return true; }
52
53protected:
54 virtual bool GetAddressSpecialCase(PyObject* pyobject, void*& address);
55 bool KeepControl() { return fKeepControl; }
56
57private:
59};
60
61template <bool ISCONST>
63public:
64 InstancePtrConverter(Cppyy::TCppType_t klass, bool keepControl = false) :
65 VoidArrayConverter(keepControl), fClass(klass) {}
66
67public:
68 virtual bool SetArg(PyObject*, Parameter&, CallContext* = nullptr);
69 virtual PyObject* FromMemory(void* address);
70 virtual bool ToMemory(PyObject* value, void* address, PyObject* ctxt = nullptr);
71
72protected:
74};
75
77public:
78 using InstancePtrConverter<false>::InstancePtrConverter;
79
80protected:
81 virtual bool GetAddressSpecialCase(PyObject*, void*&) { return false; }
82};
83
84} // namespace CPyCppyy
85
86#endif // !CPYCPPYY_CONVERTERS_H
_object PyObject
#define d(i)
Definition RSha256.hxx:102
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
#define CPYCPPYY_CLASS_EXPORT
Definition CommonDefs.h:27
#define CPYCPPYY_EXPORT
Definition CommonDefs.h:25
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)=0
Converter & operator=(Converter &&other)=delete
virtual bool HasState()
Definition Converters.h:31
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
Converter(Converter &&other)=delete
Converter & operator=(Converter const &other)=delete
Converter(Converter const &other)=delete
virtual PyObject * FromMemory(void *address)
InstancePtrConverter(Cppyy::TCppType_t klass, bool keepControl=false)
Definition Converters.h:64
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual bool GetAddressSpecialCase(PyObject *, void *&)
Definition Converters.h:81
VoidArrayConverter(bool keepControl=true)
Definition Converters.h:45
virtual bool GetAddressSpecialCase(PyObject *pyobject, void *&address)
virtual bool ToMemory(PyObject *value, void *address, PyObject *ctxt=nullptr)
virtual PyObject * FromMemory(void *address)
virtual bool SetArg(PyObject *, Parameter &, CallContext *=nullptr)
Converter *(* cf_t)(cdims_t d)
Definition Converters.h:37
CPYCPPYY_EXTERN bool RegisterConverter(const std::string &name, ConverterFactory_t)
const dims_t & cdims_t
Definition API.h:104
CPYCPPYY_EXTERN Converter * CreateConverter(const std::string &name, cdims_t=0)
CPYCPPYY_EXTERN void DestroyConverter(Converter *p)
CPYCPPYY_EXTERN bool UnregisterConverter(const std::string &name)
TCppScope_t TCppType_t
Definition cpp_cppyy.h:19