]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelHighAPI/ModelHighAPI_RefAttr.cpp
Salome HOME
Add support for RefAttr attribute, create setCoincedent constraint
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_RefAttr.cpp
1 // Name   : ModelHighAPI_RefAttr.cpp
2 // Purpose: 
3 //
4 // History:
5 // 08/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_RefAttr.h"
9
10 #include <ModelAPI_AttributeRefAttr.h>
11 //--------------------------------------------------------------------------------------
12 #include <iostream>
13 //--------------------------------------------------------------------------------------
14 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr()
15 {
16 }
17
18 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
19     const std::shared_ptr<ModelAPI_Attribute> & theValue)
20 : myValue(theValue)
21 {
22 }
23
24 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
25     const std::shared_ptr<ModelAPI_Object> & theValue)
26 : myValue(theValue)
27 {
28 }
29
30 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
31 {
32 }
33
34 //--------------------------------------------------------------------------------------
35 struct fill_visitor : boost::static_visitor<void>
36 {
37   mutable std::shared_ptr<ModelAPI_AttributeRefAttr> myAttribute;
38
39   fill_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute)
40   : myAttribute(theAttribute) {}
41
42   void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->setAttr(theValue); }
43   void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->setObject(theValue); }
44 };
45
46 void ModelHighAPI_RefAttr::fillAttribute(
47     const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const
48 {
49   boost::apply_visitor(fill_visitor(theAttribute), myValue);
50 }