Salome HOME
[EDF30062] : Forward of current directory mecanism
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTreeNode.cxx
index 56c045bffe4bc6400ac97c9868192e74d0ada631..1b4d5167f784da2761f7ac87aef03b52c8458c79 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -64,8 +64,9 @@ const std::string& SALOMEDSImpl_AttributeTreeNode::ID() const
 //=======================================================================
 //function : Append
 //purpose  : Add <TN> as last child of me
+//return   : index of TN under this, in C mode
 //=======================================================================
-bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN)
+bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN, int* childIndex)
 {
   CheckLocked();
 
@@ -76,6 +77,7 @@ bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN)
   TN->SetNext(NULL); // Deconnects from next.
 
   // Find the last
+  int index = 0;
   if (!HasFirst()) {
     SetFirst(TN);
     TN->SetPrevious(NULL); // Deconnects from previous.
@@ -84,15 +86,20 @@ bool SALOMEDSImpl_AttributeTreeNode::Append (SALOMEDSImpl_AttributeTreeNode* TN)
     SALOMEDSImpl_AttributeTreeNode* Last = GetFirst();
     while (Last && Last->HasNext()) {
       Last = Last->GetNext();
+      ++index;
     }
     Last->SetNext(TN);
     TN->SetPrevious(Last);
+    ++index;
   }
   // Set Father
   TN->SetFather(this);
   
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
-  
+
+  if ( childIndex )
+    *childIndex = index;
+
   return (TN);
 }
 
@@ -457,7 +464,7 @@ std::string SALOMEDSImpl_AttributeTreeNode::Save()
   if (HasFirst()) aFirst = GetFirst()->Label().Entry(); else aFirst = "!";
 
   int aLength = 4;
-  aLength += aFather.size() + aPrevious.size() + aNext.size() + aFirst.size();
+  aLength += (int)(aFather.size() + aPrevious.size() + aNext.size() + aFirst.size()); //!< TODO: conversion from size_t to int
   char* aResult = new char[aLength];
   sprintf(aResult, "%s %s %s %s", aFather.c_str(), aPrevious.c_str(), aNext.c_str(), aFirst.c_str());
   std::string ret(aResult);