- Standard_GUID aBasicGUID(USE_CASE_GUID);
-
- //Create a use cases structure if it not exists
-
- Handle(TDataStd_TreeNode) aFatherNode, aNode;
- Handle(TDataStd_Integer) anInteger;
- Handle(TDF_Reference) aRef;
-
- TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG);
-
- if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) {
- aRef = TDF_Reference::Set(aLabel, aLabel);
- }
-
- if(!aRef->Get().FindAttribute(aBasicGUID, aFatherNode)) {
- aFatherNode = TDataStd_TreeNode::Set(aRef->Get());
- }
-
- if(!_root->FindAttribute(TDataStd_Integer::GetID(), anInteger)) {
- anInteger = TDataStd_Integer::Set(aLabel, 0);
- }
-
- //Create a new use case
- anInteger->Set(anInteger->Get()+1);
- TDF_Label aChild = aLabel.FindChild(anInteger->Get());
- aNode = TDataStd_TreeNode::Set(aChild, aBasicGUID);
- aFatherNode->Append(aNode);
- TDataStd_Name::Set(aChild, TCollection_ExtendedString(strdup(theName)));
-
- SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aChild, _orb);
- SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this());
-
+ SALOMEDS::Locker lock;
+
+ if(!_impl) return SALOMEDS::SObject::_nil();
+ SALOMEDSImpl_SObject aSO = _impl->AddUseCase((char*)theName);
+ SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (aSO, _orb);