Salome HOME
Added the system of reinitialization of attributes instead of re-creation of them...
[modules/shaper.git] / src / Model / Model_AttributeDocRef.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_AttributeDocRef.cxx
4 // Created:     2 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "Model_AttributeDocRef.h"
8 #include "Model_Application.h"
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
11
12 using namespace std;
13
14 void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
15 {
16   if (myID->Get() != theDoc->id()) {
17     myID->Set(theDoc->id());
18     owner()->data()->sendAttributeUpdated(this);
19   }
20 }
21
22 std::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
23 {
24   return Model_Application::getApplication()->document(myID->Get());
25 }
26
27 int Model_AttributeDocRef::docId()
28 {
29   return myID->Get();
30 }
31
32 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
33 {
34   myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myID) == Standard_True;
35   if (!myIsInitialized) {
36     int aNewID = Model_Application::getApplication()->generateDocumentId();
37     myID = TDataStd_Integer::Set(theLabel, aNewID);
38   }
39 }
40
41 void Model_AttributeDocRef::reinit()
42 {
43   // myLab is unknown, nevertheless, lose of attribute DocRef for live feature seems impossible
44 }