1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : ModelHighAPI_RefAttr.cpp
6 // 08/06/16 - Sergey POKHODENKO - Creation of the file
8 //--------------------------------------------------------------------------------------
9 #include "ModelHighAPI_RefAttr.h"
11 #include <ModelAPI_AttributeRefAttr.h>
12 #include <ModelAPI_AttributeRefAttrList.h>
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15 #include "ModelHighAPI_Interface.h"
16 //--------------------------------------------------------------------------------------
17 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr()
18 : myVariantType(VT_ATTRIBUTE)
22 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
23 const std::shared_ptr<ModelAPI_Attribute> & theValue)
24 : myVariantType(VT_ATTRIBUTE)
25 , myAttribute(theValue)
29 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
30 const std::shared_ptr<ModelAPI_Object> & theValue)
31 : myVariantType(VT_OBJECT)
36 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
37 const std::shared_ptr<ModelHighAPI_Interface> & theValue)
38 : myVariantType(VT_OBJECT)
39 , myObject(std::shared_ptr<ModelAPI_Object>(theValue->defaultResult()))
43 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
47 //--------------------------------------------------------------------------------------
48 void ModelHighAPI_RefAttr::fillAttribute(
49 const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const
51 switch(myVariantType) {
52 case VT_ATTRIBUTE: theAttribute->setAttr(myAttribute); return;
53 case VT_OBJECT: theAttribute->setObject(myObject); return;
57 //--------------------------------------------------------------------------------------
58 void ModelHighAPI_RefAttr::appendToList(
59 const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const
61 switch(myVariantType) {
62 case VT_ATTRIBUTE: theAttribute->append(myAttribute); return;
63 case VT_OBJECT: theAttribute->append(myObject); return;
67 //--------------------------------------------------------------------------------------
68 bool ModelHighAPI_RefAttr::isEmpty() const
70 return !(myAttribute && myObject);