X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_RefAttr.cpp;h=7d2edf482d8166faa14eb85bc84dc2599e4759ac;hb=a13f87935d2a6f52f942790b6abc874f1016c9fc;hp=85b4b7acb1b423bee3159e7d95bb015b3d6418f1;hpb=f1615c22ae84380d8954006a37fcfff9357b7e61;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp index 85b4b7acb..7d2edf482 100644 --- a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp +++ b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp @@ -1,37 +1,54 @@ -// Name : ModelHighAPI_RefAttr.cpp -// Purpose: +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// History: -// 08/06/16 - Sergey POKHODENKO - Creation of the file -//-------------------------------------------------------------------------------------- #include "ModelHighAPI_RefAttr.h" #include #include +#include #include #include #include "ModelHighAPI_Interface.h" //-------------------------------------------------------------------------------------- ModelHighAPI_RefAttr::ModelHighAPI_RefAttr() +: myVariantType(VT_OBJECT) { } 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 +57,37 @@ 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 +void ModelHighAPI_RefAttr::appendToList( + const std::shared_ptr & theAttribute) const { - mutable std::shared_ptr myAttribute; - - append_visitor(const std::shared_ptr & theAttribute) - : myAttribute(theAttribute) {} + switch(myVariantType) { + case VT_ATTRIBUTE: theAttribute->append(myAttribute); return; + case VT_OBJECT: theAttribute->append(myObject); return; + } +} - void operator()(const std::shared_ptr& theValue) const { myAttribute->append(theValue); } - void operator()(const std::shared_ptr& theValue) const { myAttribute->append(theValue); } -}; +//-------------------------------------------------------------------------------------- +bool ModelHighAPI_RefAttr::isEmpty() const +{ + return !(myAttribute || myObject); +} -void ModelHighAPI_RefAttr::appendToList( - const std::shared_ptr & theAttribute) const +//-------------------------------------------------------------------------------------- +void ModelHighAPI_RefAttr::fillMessage( + const std::shared_ptr& theMessage) const { - boost::apply_visitor(append_visitor(theAttribute), myValue); + switch (myVariantType) { + case VT_ATTRIBUTE: theMessage->setMovedAttribute(myAttribute); return; + case VT_OBJECT: theMessage->setMovedObject(myObject); return; + } }