1 // Name : ModelHighAPI_RefAttr.cpp
5 // 08/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_RefAttr.h"
10 #include <ModelAPI_AttributeRefAttr.h>
11 #include <ModelAPI_AttributeRefAttrList.h>
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Result.h>
14 #include "ModelHighAPI_Interface.h"
15 //--------------------------------------------------------------------------------------
16 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr()
20 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
21 const std::shared_ptr<ModelAPI_Attribute> & theValue)
26 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
27 const std::shared_ptr<ModelAPI_Object> & theValue)
32 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
33 const std::shared_ptr<ModelHighAPI_Interface> & theValue)
34 : myValue(std::shared_ptr<ModelAPI_Object>(theValue->defaultResult()))
38 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
42 //--------------------------------------------------------------------------------------
43 struct fill_visitor : boost::static_visitor<void>
45 mutable std::shared_ptr<ModelAPI_AttributeRefAttr> myAttribute;
47 fill_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute)
48 : myAttribute(theAttribute) {}
50 void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->setAttr(theValue); }
51 void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->setObject(theValue); }
54 void ModelHighAPI_RefAttr::fillAttribute(
55 const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const
57 boost::apply_visitor(fill_visitor(theAttribute), myValue);
60 //--------------------------------------------------------------------------------------
61 struct append_visitor : boost::static_visitor<void>
63 mutable std::shared_ptr<ModelAPI_AttributeRefAttrList> myAttribute;
65 append_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute)
66 : myAttribute(theAttribute) {}
68 void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->append(theValue); }
69 void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->append(theValue); }
72 void ModelHighAPI_RefAttr::appendToList(
73 const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const
75 boost::apply_visitor(append_visitor(theAttribute), myValue);