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_Feature.h>
12 #include <ModelAPI_Result.h>
13 #include "ModelHighAPI_Interface.h"
14 //--------------------------------------------------------------------------------------
16 //--------------------------------------------------------------------------------------
17 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr()
21 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
22 const std::shared_ptr<ModelAPI_Attribute> & theValue)
27 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
28 const std::shared_ptr<ModelAPI_Object> & theValue)
33 ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
34 const std::shared_ptr<ModelHighAPI_Interface> & theValue)
35 : myValue(std::shared_ptr<ModelAPI_Object>(theValue->feature()->firstResult()))
37 // TODO(spo): make firstResult() a member of ModelHighAPI_Interface and use it
40 ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr()
44 //--------------------------------------------------------------------------------------
45 struct fill_visitor : boost::static_visitor<void>
47 mutable std::shared_ptr<ModelAPI_AttributeRefAttr> myAttribute;
49 fill_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute)
50 : myAttribute(theAttribute) {}
52 void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->setAttr(theValue); }
53 void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->setObject(theValue); }
56 void ModelHighAPI_RefAttr::fillAttribute(
57 const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute) const
59 boost::apply_visitor(fill_visitor(theAttribute), myValue);