Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_RefAttr.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name   : ModelHighAPI_RefAttr.cpp
3 // Purpose: 
4 //
5 // History:
6 // 08/06/16 - Sergey POKHODENKO - Creation of the file
7
8 //--------------------------------------------------------------------------------------
9 #include "ModelHighAPI_RefAttr.h"
10
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)
19 {
20 }
21
22 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
23     const std::shared_ptr<ModelAPI_Attribute> & theValue)
24 : myVariantType(VT_ATTRIBUTE)
25 , myAttribute(theValue)
26 {
27 }
28
29 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
30     const std::shared_ptr<ModelAPI_Object> & theValue)
31 : myVariantType(VT_OBJECT)
32 , myObject(theValue)
33 {
34 }
35
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()))
40 {
41 }
42
43 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
44 {
45 }
46
47 //--------------------------------------------------------------------------------------
48 void ModelHighAPI_RefAttr::fillAttribute(
49     const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const
50 {
51   switch(myVariantType) {
52     case VT_ATTRIBUTE: theAttribute->setAttr(myAttribute); return;
53     case VT_OBJECT: theAttribute->setObject(myObject); return;
54   }
55 }
56
57 //--------------------------------------------------------------------------------------
58 void ModelHighAPI_RefAttr::appendToList(
59     const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const
60 {
61   switch(myVariantType) {
62     case VT_ATTRIBUTE: theAttribute->append(myAttribute); return;
63     case VT_OBJECT: theAttribute->append(myObject); return;
64   }
65 }
66
67 //--------------------------------------------------------------------------------------
68 bool ModelHighAPI_RefAttr::isEmpty() const
69 {
70   return !(myAttribute && myObject);
71 }