Salome HOME
Issue #1648: Dump Python in the High Level Parameterized Geometry API. Debug of unit...
[modules/shaper.git] / src / Model / Model_AttributeString.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeString.cpp
4 // Created:     25 august 2014
5 // Author:      sbh
6
7 #include <Model_AttributeString.h>
8 #include <ModelAPI_AttributeString.h>
9 #include <ModelAPI_Attribute.h>
10 #include <ModelAPI_Data.h>
11 #include <ModelAPI_Object.h>
12
13 #include <Standard_TypeDef.hxx>
14 #include <TCollection_AsciiString.hxx>
15 #include <TCollection_ExtendedString.hxx>
16
17 #include <string>
18
19 void Model_AttributeString::setValue(const std::string& theValue)
20 {
21   TCollection_ExtendedString aValue(theValue.c_str());
22   if (!myIsInitialized || myString->Get() != aValue) {
23     if (myString.IsNull())
24       myString = TDataStd_Name::Set(myLab, TCollection_ExtendedString());
25     myString->Set(aValue);
26     owner()->data()->sendAttributeUpdated(this);
27   }
28 }
29
30 std::string Model_AttributeString::value()
31 {
32   if (myString.IsNull())
33     return "";  // not initialized
34   return TCollection_AsciiString(myString->Get()).ToCString();
35 }
36
37 Model_AttributeString::Model_AttributeString(TDF_Label& theLabel)
38 {
39   myLab = theLabel;
40   // check the attribute could be already presented in this doc (after load document)
41   myIsInitialized = theLabel.FindAttribute(TDataStd_Name::GetID(), myString) == Standard_True;
42 }