//--------------------------------------------------------------------------------------
ModelHighAPI_Double::ModelHighAPI_Double(double theValue)
-: myValue(theValue)
+: myVariantType(VT_DOUBLE)
+, myDouble(theValue)
{
}
ModelHighAPI_Double::ModelHighAPI_Double(const std::string & theValue)
-: myValue(theValue)
+: myVariantType(VT_STRING)
+, myString(theValue)
{
}
ModelHighAPI_Double::ModelHighAPI_Double(const char * theValue)
-: myValue(theValue)
+: myVariantType(VT_STRING)
+, myString(theValue)
{
}
}
//--------------------------------------------------------------------------------------
-struct fill_visitor : boost::static_visitor<void>
-{
- mutable std::shared_ptr<ModelAPI_AttributeDouble> myAttribute;
-
- fill_visitor(const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
- : myAttribute(theAttribute) {}
-
- void operator()(double theValue) const { myAttribute->setValue(theValue); }
- void operator()(const std::string & theValue) const { myAttribute->setText(theValue); }
-};
-
void ModelHighAPI_Double::fillAttribute(
const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const
{
- boost::apply_visitor(fill_visitor(theAttribute), myValue);
+ switch(myVariantType) {
+ case VT_DOUBLE: theAttribute->setValue(myDouble); return;
+ case VT_STRING: theAttribute->setText(myString); return;
+ }
}
#include <memory>
#include <string>
-
-#include <boost/variant.hpp>
//--------------------------------------------------------------------------------------
class ModelAPI_AttributeDouble;
//--------------------------------------------------------------------------------------
virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const;
private:
- boost::variant<double, std::string> myValue;
+ enum VariantType { VT_DOUBLE, VT_STRING } myVariantType;
+ double myDouble;
+ std::string myString;
};
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
ModelHighAPI_Integer::ModelHighAPI_Integer(int theValue)
-: myValue(theValue)
+: myVariantType(VT_INT)
+, myInt(theValue)
{
}
ModelHighAPI_Integer::ModelHighAPI_Integer(const std::string & theValue)
-: myValue(theValue)
+: myVariantType(VT_STRING)
+, myString(theValue)
{
}
ModelHighAPI_Integer::ModelHighAPI_Integer(const char * theValue)
-: myValue(theValue)
+: myVariantType(VT_STRING)
+, myString(theValue)
{
}
}
//--------------------------------------------------------------------------------------
-struct fill_visitor : boost::static_visitor<void>
-{
- mutable std::shared_ptr<ModelAPI_AttributeInteger> myAttribute;
-
- fill_visitor(const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute)
- : myAttribute(theAttribute) {}
-
- void operator()(int theValue) const { myAttribute->setValue(theValue); }
- void operator()(const std::string & theValue) const { myAttribute->setText(theValue); }
-};
-
void ModelHighAPI_Integer::fillAttribute(
const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute) const
{
- boost::apply_visitor(fill_visitor(theAttribute), myValue);
+ switch(myVariantType) {
+ case VT_INT: theAttribute->setValue(myInt); return;
+ case VT_STRING: theAttribute->setText(myString); return;
+ }
}
#include <memory>
#include <string>
-
-#include <boost/variant.hpp>
//--------------------------------------------------------------------------------------
class ModelAPI_AttributeInteger;
//--------------------------------------------------------------------------------------
virtual void fillAttribute(const std::shared_ptr<ModelAPI_AttributeInteger> & theAttribute) const;
private:
- boost::variant<int, std::string> myValue;
+ enum VariantType { VT_INT, VT_STRING } myVariantType;
+ int myInt;
+ std::string myString;
};
//--------------------------------------------------------------------------------------
#include "ModelHighAPI_Interface.h"
//--------------------------------------------------------------------------------------
ModelHighAPI_RefAttr::ModelHighAPI_RefAttr()
+: myVariantType(VT_ATTRIBUTE)
{
}
ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
const std::shared_ptr<ModelAPI_Attribute> & theValue)
-: myValue(theValue)
+: myVariantType(VT_ATTRIBUTE)
+, myAttribute(theValue)
{
}
ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
const std::shared_ptr<ModelAPI_Object> & theValue)
-: myValue(theValue)
+: myVariantType(VT_OBJECT)
+, myObject(theValue)
{
}
ModelHighAPI_RefAttr::ModelHighAPI_RefAttr(
const std::shared_ptr<ModelHighAPI_Interface> & theValue)
-: myValue(std::shared_ptr<ModelAPI_Object>(theValue->defaultResult()))
+: myVariantType(VT_OBJECT)
+, myObject(std::shared_ptr<ModelAPI_Object>(theValue->defaultResult()))
{
}
}
//--------------------------------------------------------------------------------------
-struct fill_visitor : boost::static_visitor<void>
-{
- mutable std::shared_ptr<ModelAPI_AttributeRefAttr> myAttribute;
-
- fill_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttr> & theAttribute)
- : myAttribute(theAttribute) {}
-
- void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->setAttr(theValue); }
- void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->setObject(theValue); }
-};
-
void ModelHighAPI_RefAttr::fillAttribute(
const std::shared_ptr<ModelAPI_AttributeRefAttr> & 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>
-{
- mutable std::shared_ptr<ModelAPI_AttributeRefAttrList> myAttribute;
-
- append_visitor(const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute)
- : myAttribute(theAttribute) {}
-
- void operator()(const std::shared_ptr<ModelAPI_Attribute>& theValue) const { myAttribute->append(theValue); }
- void operator()(const std::shared_ptr<ModelAPI_Object>& theValue) const { myAttribute->append(theValue); }
-};
-
void ModelHighAPI_RefAttr::appendToList(
const std::shared_ptr<ModelAPI_AttributeRefAttrList> & 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;
+ }
}
#include <memory>
#include <string>
-
-#include <boost/variant.hpp>
//--------------------------------------------------------------------------------------
class ModelAPI_Attribute;
class ModelAPI_AttributeRefAttr;
virtual void appendToList(const std::shared_ptr<ModelAPI_AttributeRefAttrList> & theAttribute) const;
private:
- boost::variant<
- std::shared_ptr<ModelAPI_Attribute>,
- std::shared_ptr<ModelAPI_Object>
- > myValue;
+ enum VariantType { VT_ATTRIBUTE, VT_OBJECT } myVariantType;
+ std::shared_ptr<ModelAPI_Attribute> myAttribute;
+ std::shared_ptr<ModelAPI_Object> myObject;
};
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
ModelHighAPI_Selection::ModelHighAPI_Selection(const std::shared_ptr<ModelAPI_Result>& theContext,
const std::shared_ptr<GeomAPI_Shape>& theSubShape)
-: myValue(ResultSubShapePair(theContext, theSubShape))
+: myVariantType(VT_ResultSubShapePair)
+, myResultSubShapePair(theContext, theSubShape)
{
}
ModelHighAPI_Selection::ModelHighAPI_Selection(const std::string& theType,
const std::string& theSubShapeName)
-: myValue(TypeSubShapeNamePair(theType, theSubShapeName))
+: myVariantType(VT_TypeSubShapeNamePair)
+, myTypeSubShapeNamePair(theType, theSubShapeName)
{
}
}
//--------------------------------------------------------------------------------------
-struct fill_visitor : boost::static_visitor<void>
-{
- mutable std::shared_ptr<ModelAPI_AttributeSelection> myAttribute;
-
- fill_visitor(const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute)
- : myAttribute(theAttribute) {}
-
- void operator()(const ResultSubShapePair & thePair) const { myAttribute->setValue(thePair.first, thePair.second); }
- void operator()(const TypeSubShapeNamePair & thePair) const { myAttribute->selectSubShape(thePair.first, thePair.second); }
-};
-
void ModelHighAPI_Selection::fillAttribute(
const std::shared_ptr<ModelAPI_AttributeSelection> & theAttribute) const
{
- boost::apply_visitor(fill_visitor(theAttribute), myValue);
+ switch(myVariantType) {
+ case VT_ResultSubShapePair: theAttribute->setValue(myResultSubShapePair.first, myResultSubShapePair.second); return;
+ case VT_TypeSubShapeNamePair: theAttribute->selectSubShape(myTypeSubShapeNamePair.first, myTypeSubShapeNamePair.second); return;
+ }
}
//--------------------------------------------------------------------------------------
-struct append_visitor : boost::static_visitor<void>
-{
- mutable std::shared_ptr<ModelAPI_AttributeSelectionList> myAttribute;
-
- append_visitor(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute)
- : myAttribute(theAttribute) {}
-
- void operator()(const ResultSubShapePair & thePair) const { myAttribute->append(thePair.first, thePair.second); }
- void operator()(const TypeSubShapeNamePair & thePair) const {
- // Note: the reverse order (first - type, second - sub-shape name)
- myAttribute->append(thePair.second, thePair.first);
- }
-};
-
void ModelHighAPI_Selection::appendToList(
const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const
{
- boost::apply_visitor(append_visitor(theAttribute), myValue);
+ switch(myVariantType) {
+ case VT_ResultSubShapePair: theAttribute->append(myResultSubShapePair.first, myResultSubShapePair.second); return;
+ case VT_TypeSubShapeNamePair:
+ // Note: the reverse order (first - type, second - sub-shape name)
+ theAttribute->append(myTypeSubShapeNamePair.second, myTypeSubShapeNamePair.first);
+ return;
+ }
}
#include <memory>
#include <string>
#include <utility>
-
-#include <boost/variant.hpp>
//--------------------------------------------------------------------------------------
class GeomAPI_Shape;
class ModelAPI_AttributeSelection;
virtual void appendToList(const std::shared_ptr<ModelAPI_AttributeSelectionList> & theAttribute) const;
private:
- boost::variant<ResultSubShapePair, TypeSubShapeNamePair> myValue;
+ enum VariantType { VT_ResultSubShapePair, VT_TypeSubShapeNamePair } myVariantType;
+ ResultSubShapePair myResultSubShapePair;
+ TypeSubShapeNamePair myTypeSubShapeNamePair;
};
//--------------------------------------------------------------------------------------