Salome HOME
ModelHighAPI_RefAttr can use ModelHighAPI_Interface
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 14 Jun 2016 10:18:53 +0000 (13:18 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:07 +0000 (14:41 +0300)
src/ModelHighAPI/ModelHighAPI.i
src/ModelHighAPI/ModelHighAPI_RefAttr.cpp
src/ModelHighAPI/ModelHighAPI_RefAttr.h

index 153f64f8e6548fb2dcf511ca572077fd307b73b1..522ed48deea48e106c76b9829928623f79ee6955 100644 (file)
 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
   std::shared_ptr<ModelAPI_Attribute> * temp_attribute;
   std::shared_ptr<ModelAPI_Object> * temp_object;
+  std::shared_ptr<ModelHighAPI_Interface> * temp_interface;
   int newmem = 0;
   if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_attribute, $descriptor(std::shared_ptr<ModelAPI_Attribute> *), 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<ModelAPI_Object> *), 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);
     }
     $1 = &temp;
   } else
+  if ((SWIG_ConvertPtrAndOwn($input, (void **)&temp_interface, $descriptor(std::shared_ptr<ModelHighAPI_Interface> *), 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;
   }
 }
index 098308b5d429b966952d168e53a5ecee7bffa448..cb6574668e3df6a33ccfa8cebc8f7c7aacb6449b 100644 (file)
@@ -8,6 +8,9 @@
 #include "ModelHighAPI_RefAttr.h"
 
 #include <ModelAPI_AttributeRefAttr.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Result.h>
+#include "ModelHighAPI_Interface.h"
 //--------------------------------------------------------------------------------------
 #include <iostream>
 //--------------------------------------------------------------------------------------
@@ -27,6 +30,13 @@ ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
 {
 }
 
+ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
+    const std::shared_ptr<ModelHighAPI_Interface> & theValue)
+: myValue(std::shared_ptr<ModelAPI_Object>(theValue->feature()->firstResult()))
+{
+  // TODO(spo): make firstResult() a member of ModelHighAPI_Interface and use it
+}
+
 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
 {
 }
index 14fcc5563020ccd4e631d8235347018994938a2d..6f2648e427bd439ea4da4c45758ac697ca5f3330 100644 (file)
@@ -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<ModelAPI_Attribute> & theValue);
+  ModelHighAPI_RefAttr(const std::shared_ptr<ModelAPI_Attribute> & theValue);
   /// Constructor for object
   MODELHIGHAPI_EXPORT
-  explicit ModelHighAPI_RefAttr(const std::shared_ptr<ModelAPI_Object> & theValue);
+  ModelHighAPI_RefAttr(const std::shared_ptr<ModelAPI_Object> & theValue);
+  /// Constructor for Interface (use result() for object)
+  MODELHIGHAPI_EXPORT
+  ModelHighAPI_RefAttr(const std::shared_ptr<ModelHighAPI_Interface> & theValue);
   /// Destructor
   MODELHIGHAPI_EXPORT
   virtual ~ModelHighAPI_RefAttr();