Salome HOME
Use fillAttribute in *API interfaces
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Double.cpp
1 // Name   : ModelHighAPI_Double.cpp
2 // Purpose: 
3 //
4 // History:
5 // 29/03/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ModelHighAPI_Double.h"
9
10 #include <ModelAPI_AttributeDouble.h>
11 //--------------------------------------------------------------------------------------
12
13 //--------------------------------------------------------------------------------------
14 ModelHighAPI_Double::ModelHighAPI_Double(double theValue)
15 : myValue(theValue)
16 {
17 }
18
19 ModelHighAPI_Double::ModelHighAPI_Double(const std::string & theValue)
20 : myValue(theValue)
21 {
22 }
23
24 ModelHighAPI_Double::ModelHighAPI_Double(const char * theValue)
25 : myValue(theValue)
26 {
27 }
28
29 ModelHighAPI_Double::~ModelHighAPI_Double()
30 {
31 }
32
33 //--------------------------------------------------------------------------------------
34 struct fill_visitor : boost::static_visitor<void>
35 {
36   mutable std::shared_ptr<ModelAPI_AttributeDouble> myAttribute;
37
38   fill_visitor(const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute)
39   : myAttribute(theAttribute) {}
40
41   void operator()(double theValue) const { myAttribute->setValue(theValue); }
42   void operator()(const std::string & theValue) const { myAttribute->setText(theValue); }
43 };
44
45 void ModelHighAPI_Double::fillAttribute(
46     const std::shared_ptr<ModelAPI_AttributeDouble> & theAttribute) const
47 {
48   boost::apply_visitor(fill_visitor(theAttribute), myValue);
49 }