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_Events.h>
14 #include <ModelAPI_Feature.h>
15 #include <ModelAPI_Result.h>
16 #include "ModelHighAPI_Interface.h"
17 //--------------------------------------------------------------------------------------
18 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr()
19 : myVariantType(VT_ATTRIBUTE)
23 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
24 const std::shared_ptr<ModelAPI_Attribute> & theValue)
25 : myVariantType(VT_ATTRIBUTE)
26 , myAttribute(theValue)
30 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
31 const std::shared_ptr<ModelAPI_Object> & theValue)
32 : myVariantType(VT_OBJECT)
37 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
38 const std::shared_ptr<ModelHighAPI_Interface> & theValue)
39 : myVariantType(VT_OBJECT)
40 , myObject(std::shared_ptr<ModelAPI_Object>(theValue->defaultResult()))
44 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
48 //--------------------------------------------------------------------------------------
49 void ModelHighAPI_RefAttr::fillAttribute(
50 const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const
52 switch(myVariantType) {
53 case VT_ATTRIBUTE: theAttribute->setAttr(myAttribute); return;
54 case VT_OBJECT: theAttribute->setObject(myObject); return;
58 //--------------------------------------------------------------------------------------
59 void ModelHighAPI_RefAttr::appendToList(
60 const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const
62 switch(myVariantType) {
63 case VT_ATTRIBUTE: theAttribute->append(myAttribute); return;
64 case VT_OBJECT: theAttribute->append(myObject); return;
68 //--------------------------------------------------------------------------------------
69 bool ModelHighAPI_RefAttr::isEmpty() const
71 return !(myAttribute && myObject);
74 //--------------------------------------------------------------------------------------
75 void ModelHighAPI_RefAttr::fillMessage(
76 const std::shared_ptr<ModelAPI_ObjectMovedMessage>& theMessage) const
78 switch (myVariantType) {
79 case VT_ATTRIBUTE: theMessage->setMovedAttribute(myAttribute); return;
80 case VT_OBJECT: theMessage->setMovedObject(myObject); return;