Salome HOME
refs #561: the draft data model for Strickler table
[modules/hydro.git] / src / HYDROData / HYDROData_PriorityQueue.cxx
index 76b475d1d421225a7f8bfdba221b9528316b4a56..3e85dfd223f34002d161a43dbae78502281bd3ea 100644 (file)
@@ -1,3 +1,20 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include <HYDROData_PriorityQueue.h>
 #include <HYDROData_CalculationCase.h>
@@ -121,7 +138,14 @@ void HYDROData_PriorityQueue::AddRule( TDF_Label&                         theRul
                                        const Handle(HYDROData_Object)&    theObject2,
                                        HYDROData_Zone::MergeAltitudesType theMergeType )
 {
-  TDF_Label aNewRuleLab = theRulesLabel.NewChild();
+  // Get the last rule index
+  Standard_Integer aRuleIndex = 0;
+  Handle(TDataStd_Integer) anIntVal;
+  if ( theRulesLabel.FindAttribute( TDataStd_Integer::GetID(), anIntVal ) ) {
+    aRuleIndex = anIntVal->Get();
+  }
+
+  TDF_Label aNewRuleLab = theRulesLabel.FindChild( aRuleIndex );
 
   TDF_Label anObj1Lab = aNewRuleLab.FindChild( Object1_Tag );
   Handle(TDataStd_ReferenceList) aRefs = TDataStd_ReferenceList::Set( anObj1Lab );
@@ -136,6 +160,9 @@ void HYDROData_PriorityQueue::AddRule( TDF_Label&                         theRul
 
   TDF_Label aMergeLab = aNewRuleLab.FindChild( Merge_Tag );
   TDataStd_Integer::Set( aMergeLab, theMergeType );
+
+  // Increment the last rule index
+  TDataStd_Integer::Set( theRulesLabel, aRuleIndex + 1 );
 }
 
 HYDROData_ListOfRules HYDROData_PriorityQueue::GetRules( const TDF_Label& theRulesLabel )
@@ -236,11 +263,6 @@ void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
   }
 }
 
-int HYDROData_PriorityQueue::GetRulesCount( const TDF_Label& theRulesLab )
-{
-  return theRulesLab.NbChildren();
-}
-
 bool HYDROData_PriorityQueue::GetRule( const TDF_Label& theRulesLab,
                                        int theIndex, 
                                        Handle(HYDROData_Object)&           theObject1,