From: spo Date: Tue, 14 Jun 2016 10:18:53 +0000 (+0300) Subject: ModelHighAPI_RefAttr can use ModelHighAPI_Interface X-Git-Tag: V_2.4.0~91^2~56 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e013113325e1e9b049d21582ed80a7131e1e2c22;hp=95ec95cbfbf47d7f292939097fc09458f86ec182;p=modules%2Fshaper.git ModelHighAPI_RefAttr can use ModelHighAPI_Interface --- diff --git a/src/ModelHighAPI/ModelHighAPI.i b/src/ModelHighAPI/ModelHighAPI.i index 153f64f8e..522ed48de 100644 --- a/src/ModelHighAPI/ModelHighAPI.i +++ b/src/ModelHighAPI/ModelHighAPI.i @@ -62,10 +62,11 @@ %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) { std::shared_ptr * temp_attribute; std::shared_ptr * temp_object; + std::shared_ptr * temp_interface; int newmem = 0; if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { if (!temp_attribute) { - PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object."); + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } temp = ModelHighAPI_RefAttr(*temp_attribute); @@ -76,7 +77,7 @@ } else if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_object, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { if (!temp_object) { - PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object."); + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } temp = ModelHighAPI_RefAttr(*temp_object); @@ -85,9 +86,20 @@ } $1 = &temp; } else + if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr *), SWIG_POINTER_EXCEPTION, &newmem)) == 0) { + if (!temp_interface) { + PyErr_SetString(PyExc_TypeError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); + return NULL; + } + temp = ModelHighAPI_RefAttr(*temp_interface); + if (newmem & SWIG_CAST_NEW_MEMORY) { + delete temp_interface; + } + $1 = &temp; + } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) { } else { - PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelAPI_Attribute, int or ModelAPI_Object."); + PyErr_SetString(PyExc_ValueError, "argument must be ModelHighAPI_RefAttr, ModelHighAPI_Interface, ModelAPI_Attribute or ModelAPI_Object."); return NULL; } } diff --git a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp index 098308b5d..cb6574668 100644 --- a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp +++ b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp @@ -8,6 +8,9 @@ #include "ModelHighAPI_RefAttr.h" #include +#include +#include +#include "ModelHighAPI_Interface.h" //-------------------------------------------------------------------------------------- #include //-------------------------------------------------------------------------------------- @@ -27,6 +30,13 @@ ModelHighAPI_RefAttr::ModelHighAPI_RefAttr( { } +ModelHighAPI_RefAttr::ModelHighAPI_RefAttr( + const std::shared_ptr & theValue) +: myValue(std::shared_ptr(theValue->feature()->firstResult())) +{ + // TODO(spo): make firstResult() a member of ModelHighAPI_Interface and use it +} + ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr() { } diff --git a/src/ModelHighAPI/ModelHighAPI_RefAttr.h b/src/ModelHighAPI/ModelHighAPI_RefAttr.h index 14fcc5563..6f2648e42 100644 --- a/src/ModelHighAPI/ModelHighAPI_RefAttr.h +++ b/src/ModelHighAPI/ModelHighAPI_RefAttr.h @@ -18,6 +18,7 @@ class ModelAPI_Attribute; class ModelAPI_AttributeRefAttr; class ModelAPI_Object; +class ModelHighAPI_Interface; //-------------------------------------------------------------------------------------- /**\class ModelHighAPI_RefAttr * \ingroup CPPHighAPI @@ -31,10 +32,13 @@ public: ModelHighAPI_RefAttr(); /// Constructor for attribute MODELHIGHAPI_EXPORT - explicit ModelHighAPI_RefAttr(const std::shared_ptr & theValue); + ModelHighAPI_RefAttr(const std::shared_ptr & theValue); /// Constructor for object MODELHIGHAPI_EXPORT - explicit ModelHighAPI_RefAttr(const std::shared_ptr & theValue); + ModelHighAPI_RefAttr(const std::shared_ptr & theValue); + /// Constructor for Interface (use result() for object) + MODELHIGHAPI_EXPORT + ModelHighAPI_RefAttr(const std::shared_ptr & theValue); /// Destructor MODELHIGHAPI_EXPORT virtual ~ModelHighAPI_RefAttr();