IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
PythonDataItemMacros.h
Go to the documentation of this file.
1 // PythonDataItemMacros.h:
3 // -----------------------
4 //
14 
15 #ifndef __PYIPSDKBASE_PYTHONDATAITEMMACROS_H__
16 #define __PYIPSDKBASE_PYTHONDATAITEMMACROS_H__
17 
20 #include <boost/shared_ptr.hpp>
21 #include <boost/noncopyable.hpp>
22 
25 
29 #if (defined(_MSC_VER) && _MSC_VER == 1900)
30 #define IPSDK_PYTHON_DATAITEM_WRAPPER_BOOST_WORKAROUND(dataItemName) \
31  static_cast<dataItemName const volatile* (*)(class dataItemName const volatile*)>(boost::get_pointer<dataItemName const volatile>);
32 #else
33 #define IPSDK_PYTHON_DATAITEM_WRAPPER_BOOST_WORKAROUND(dataItemName)
34 #endif
35 
37 template <typename DataItemType>
38 boost::shared_ptr<DataItemType>
39 duplicateDataItem(const DataItemType& inputDataItem)
40 {
41  return boost::static_pointer_cast<DataItemType>(inputDataItem.duplicateShared());
42 }
43 
45 namespace std {
46 
47  template <typename DataItemType>
48  typename boost::enable_if_c<boost::is_base_of<ipsdk::BaseDataItem, DataItemType>::value,std::ostream&>::type
49  operator<< (std::ostream& os, const DataItemType& dataItem)
50  {
51  os << ipsdk::python::toString(dataItem);
52 
53  return os;
54  }
55 }
56 
59 #define IPSDK_PYTHON_DATAITEM_WRAPPER(dataItemName) \
60  boost::python::implicitly_convertible<boost::shared_ptr<dataItemName>, \
61  boost::shared_ptr<const dataItemName> >(); \
62  boost::python::implicitly_convertible<boost::shared_ptr<dataItemName>, \
63  ipsdk::DataItemPtr>(); \
64  boost::python::implicitly_convertible<boost::shared_ptr<dataItemName>, \
65  ipsdk::DataItemConstPtr>(); \
66  boost::python::implicitly_convertible<boost::shared_ptr<dataItemName>, \
67  ipsdk::DataItemNodePtr>(); \
68  boost::python::implicitly_convertible<boost::shared_ptr<dataItemName>, \
69  ipsdk::DataItemNodeConstPtr>(); \
70  IPSDK_PYTHON_DATAITEM_WRAPPER_BOOST_WORKAROUND(dataItemName) \
71  typedef boost::python::class_<dataItemName, \
72  bases<ipsdk::BaseDataItem>, \
73  boost::shared_ptr<dataItemName>, \
74  boost::noncopyable> BOOST_PP_CAT(Py, dataItemName); \
75  BOOST_PP_CAT(Py, dataItemName) BOOST_PP_CAT(py, dataItemName)( \
76  BOOST_PP_STRINGIZE(dataItemName), \
77  dataItemName::getToolTipStr().c_str(), \
78  boost::python::no_init); \
79  ipsdk::python::DataItemNodeRegistrator<0, dataItemName>::registerNode(BOOST_PP_CAT(py, dataItemName)); \
80  BOOST_PP_CAT(py, dataItemName) \
81  .def("duplicate", duplicateDataItem<dataItemName>, "duplicate existing data item") \
82  .def(self_ns::str(self_ns::self)) \
83  .add_property("toolTip", \
84  boost::python::make_function(&dataItemName::getToolTip, \
85  boost::python::return_internal_reference<>()), \
86  "retrieve object tool tip")
87 
90 
91 #endif // __PYIPSDKBASE_PYTHONDATAITEMMACROS_H__
Macros allowing to handle ipsdk to python wrapping.
boost::shared_ptr< DataItemType > duplicateDataItem(const DataItemType &inputDataItem)
template function allowing to duplicate a typed dataitem
Definition: PythonDataItemMacros.h:39
PYIPSDKBASE_API std::string toString(const BaseDataItem &dataItem)
function allowing to convert an IPSDK data item to a string representation
Utility functions used for python data item wrapping management.
STL namespace.