X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_RefAttr.cpp;h=6bb6aeb3b2597aedc5ccd7e8e52c48dd9582e94e;hb=4c9aced7d9d388cb02806dccf83f99dd9604f31d;hp=85b4b7acb1b423bee3159e7d95bb015b3d6418f1;hpb=f1615c22ae84380d8954006a37fcfff9357b7e61;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp index 85b4b7acb..6bb6aeb3b 100644 --- a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp +++ b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp @@ -14,24 +14,28 @@ #include "ModelHighAPI_Interface.h" //-------------------------------------------------------------------------------------- ModelHighAPI_RefAttr::ModelHighAPI_RefAttr() +: myVariantType(VT_ATTRIBUTE) { } ModelHighAPI_RefAttr::ModelHighAPI_RefAttr( const std::shared_ptr & theValue) -: myValue(theValue) +: myVariantType(VT_ATTRIBUTE) +, myAttribute(theValue) { } ModelHighAPI_RefAttr::ModelHighAPI_RefAttr( const std::shared_ptr & theValue) -: myValue(theValue) +: myVariantType(VT_OBJECT) +, myObject(theValue) { } ModelHighAPI_RefAttr::ModelHighAPI_RefAttr( const std::shared_ptr & theValue) -: myValue(std::shared_ptr(theValue->defaultResult())) +: myVariantType(VT_OBJECT) +, myObject(std::shared_ptr(theValue->defaultResult())) { } @@ -40,37 +44,27 @@ ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr() } //-------------------------------------------------------------------------------------- -struct fill_visitor : boost::static_visitor -{ - mutable std::shared_ptr myAttribute; - - fill_visitor(const std::shared_ptr & theAttribute) - : myAttribute(theAttribute) {} - - void operator()(const std::shared_ptr& theValue) const { myAttribute->setAttr(theValue); } - void operator()(const std::shared_ptr& theValue) const { myAttribute->setObject(theValue); } -}; - void ModelHighAPI_RefAttr::fillAttribute( const std::shared_ptr & theAttribute) const { - boost::apply_visitor(fill_visitor(theAttribute), myValue); + switch(myVariantType) { + case VT_ATTRIBUTE: theAttribute->setAttr(myAttribute); return; + case VT_OBJECT: theAttribute->setObject(myObject); return; + } } //-------------------------------------------------------------------------------------- -struct append_visitor : boost::static_visitor -{ - mutable std::shared_ptr myAttribute; - - append_visitor(const std::shared_ptr & theAttribute) - : myAttribute(theAttribute) {} - - void operator()(const std::shared_ptr& theValue) const { myAttribute->append(theValue); } - void operator()(const std::shared_ptr& theValue) const { myAttribute->append(theValue); } -}; - void ModelHighAPI_RefAttr::appendToList( const std::shared_ptr & theAttribute) const { - boost::apply_visitor(append_visitor(theAttribute), myValue); + switch(myVariantType) { + case VT_ATTRIBUTE: theAttribute->append(myAttribute); return; + case VT_OBJECT: theAttribute->append(myObject); return; + } +} + +//-------------------------------------------------------------------------------------- +bool ModelHighAPI_RefAttr::isEmpty() const +{ + return !(myAttribute && myObject); }