Salome HOME
Make all c++ files "cpp"
[modules/shaper.git] / src / Model / Model_AttributeDocRef.cpp
1 // File:        ModelAPI_AttributeDocRef.cxx
2 // Created:     2 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include "Model_AttributeDocRef.h"
6 #include "Model_Application.h"
7
8 using namespace std;
9
10 void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
11 {
12   myComment->Set(TCollection_ExtendedString(theDoc->id().c_str()));
13 }
14
15 std::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
16 {
17   if (myComment->Get().Length())
18     return Model_Application::getApplication()->getDocument(
19       TCollection_AsciiString(myComment->Get()).ToCString());
20   // not initialized
21   return std::shared_ptr<ModelAPI_Document>();
22 }
23
24 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
25 {
26   // check the attribute could be already presented in this doc (after load document)
27   if (!theLabel.FindAttribute(TDataStd_Comment::GetID(), myComment)) {
28     // create attribute: not initialized by value yet, just empty string
29     myComment = TDataStd_Comment::Set(theLabel, "");
30   }
31 }