Salome HOME
Fix for crash on Debian Squeeze. It is quite tricky and crash is avoided if change...
[modules/shaper.git] / src / Model / Model_AttributeInteger.cpp
1 // File:        Model_AttributeInteger.cpp
2 // Created:     03 sep 2014
3 // Author:      sbh
4
5 #include <Model_AttributeInteger.h>
6
7 #include <ModelAPI_Attribute.h>
8 #include <ModelAPI_Data.h>
9 #include <ModelAPI_Object.h>
10
11 #include <Standard_TypeDef.hxx>
12 #include <TDataStd_Integer.hxx>
13
14 void Model_AttributeInteger::setValue(const int theValue)
15 {
16   if (!myIsInitialized || myInteger->Get() != theValue) {
17     myInteger->Set(theValue);
18     owner()->data()->sendAttributeUpdated(this);
19   }
20 }
21
22 int Model_AttributeInteger::value()
23 {
24   return myInteger->Get();
25 }
26
27 Model_AttributeInteger::Model_AttributeInteger(TDF_Label& theLabel)
28 {
29   // check the attribute could be already presented in this doc (after load document)
30   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myInteger) == Standard_True;
31   if (!myIsInitialized) {
32     // create attribute: not initialized by value yet, just zero
33     myInteger = TDataStd_Integer::Set(theLabel, 0);
34   }
35 }