1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeString.cpp
4 // Created: 25 august 2014
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>
13 #include <Standard_TypeDef.hxx>
14 #include <TCollection_AsciiString.hxx>
15 #include <TCollection_ExtendedString.hxx>
19 void Model_AttributeString::setValue(const std::string& theValue)
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);
30 std::string Model_AttributeString::value()
32 if (myString.IsNull())
33 return ""; // not initialized
34 return TCollection_AsciiString(myString->Get()).ToCString();
37 Model_AttributeString::Model_AttributeString(TDF_Label& theLabel)
43 void Model_AttributeString::reinit()
45 // check the attribute could be already presented in this doc (after load document)
46 myIsInitialized = myLab.FindAttribute(TDataStd_Name::GetID(), myString) == Standard_True;