X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModelHighAPI%2FModelHighAPI_RefAttr.cpp;h=7d2edf482d8166faa14eb85bc84dc2599e4759ac;hb=a13f87935d2a6f52f942790b6abc874f1016c9fc;hp=cb6574668e3df6a33ccfa8cebc8f7c7aacb6449b;hpb=e013113325e1e9b049d21582ed80a7131e1e2c22;p=modules%2Fshaper.git diff --git a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp index cb6574668..7d2edf482 100644 --- a/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp +++ b/src/ModelHighAPI/ModelHighAPI_RefAttr.cpp @@ -1,40 +1,55 @@ -// 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" //-------------------------------------------------------------------------------------- -#include -//-------------------------------------------------------------------------------------- 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->feature()->firstResult())) +: myVariantType(VT_OBJECT) +, myObject(std::shared_ptr(theValue->defaultResult())) { - // TODO(spo): make firstResult() a member of ModelHighAPI_Interface and use it } ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr() @@ -42,19 +57,37 @@ ModelHighAPI_RefAttr::~ModelHighAPI_RefAttr() } //-------------------------------------------------------------------------------------- -struct fill_visitor : boost::static_visitor +void ModelHighAPI_RefAttr::fillAttribute( + const std::shared_ptr & theAttribute) const { - mutable std::shared_ptr myAttribute; + switch(myVariantType) { + case VT_ATTRIBUTE: theAttribute->setAttr(myAttribute); return; + case VT_OBJECT: theAttribute->setObject(myObject); return; + } +} - fill_visitor(const std::shared_ptr & theAttribute) - : myAttribute(theAttribute) {} +//-------------------------------------------------------------------------------------- +void ModelHighAPI_RefAttr::appendToList( + const std::shared_ptr & theAttribute) const +{ + 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->setAttr(theValue); } - void operator()(const std::shared_ptr& theValue) const { myAttribute->setObject(theValue); } -}; +//-------------------------------------------------------------------------------------- +bool ModelHighAPI_RefAttr::isEmpty() const +{ + return !(myAttribute || myObject); +} -void ModelHighAPI_RefAttr::fillAttribute( - const std::shared_ptr & theAttribute) const +//-------------------------------------------------------------------------------------- +void ModelHighAPI_RefAttr::fillMessage( + const std::shared_ptr& theMessage) const { - boost::apply_visitor(fill_visitor(theAttribute), myValue); + switch (myVariantType) { + case VT_ATTRIBUTE: theMessage->setMovedAttribute(myAttribute); return; + case VT_OBJECT: theMessage->setMovedObject(myObject); return; + } }