1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeDocRef.cxx
5 // Author: Mikhail PONIKAROV
7 #include "Model_AttributeDocRef.h"
8 #include "Model_Application.h"
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
12 void Model_AttributeDocRef::setValue(std::shared_ptr<ModelAPI_Document> theDoc)
14 if (myID->Get() != theDoc->id()) {
15 myID->Set(theDoc->id());
16 owner()->data()->sendAttributeUpdated(this);
20 std::shared_ptr<ModelAPI_Document> Model_AttributeDocRef::value()
22 return Model_Application::getApplication()->document(myID->Get());
25 int Model_AttributeDocRef::docId()
30 Model_AttributeDocRef::Model_AttributeDocRef(TDF_Label& theLabel)
32 myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myID) == Standard_True;
33 if (!myIsInitialized) {
34 int aNewID = Model_Application::getApplication()->generateDocumentId();
35 myID = TDataStd_Integer::Set(theLabel, aNewID);
39 void Model_AttributeDocRef::reinit()
41 // myLab is unknown, nevertheless, lose of attribute DocRef for live feature seems impossible