]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_PriorityQueue.h
Salome HOME
Merge remote-tracking branch 'origin/BR_IMPROVEMENTS' into BR_v14_rc
[modules/hydro.git] / src / HYDROData / HYDROData_PriorityQueue.h
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #ifndef HYDROData_PriorityQueue_HeaderFile
20 #define HYDROData_PriorityQueue_HeaderFile
21
22 #include <QMap>
23 #include <HYDROData_Object.h>
24 #include <HYDROData_Zone.h>
25
26 class HYDROData_CalculationCase;
27
28 enum HYDROData_PriorityType
29 {
30   LESS,
31   GREATER,
32 };
33
34 struct HYDROData_CustomRule
35 {
36   Handle(HYDROData_Object)           Object1;
37   HYDROData_PriorityType             Priority;
38   Handle(HYDROData_Object)           Object2;
39   HYDROData_Zone::MergeAltitudesType MergeType;
40 };
41
42 typedef QList<HYDROData_CustomRule> HYDROData_ListOfRules;
43
44 class HYDROData_PriorityQueue
45 {
46 public:
47   HYDROData_PriorityQueue( HYDROData_CalculationCase* );
48   ~HYDROData_PriorityQueue();
49
50   Handle_HYDROData_Object GetMostPriorityObject( const QStringList& theZoneObjects,
51                                                  HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
52
53   bool IsMorePriority( const Handle(HYDROData_Object)& theObj1,
54                        const Handle(HYDROData_Object)& theObj2,
55                        HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
56
57   static void ClearRules( TDF_Label& theRulesLabel );
58   static void AddRule( TDF_Label& theRulesLabel,
59                        const Handle(HYDROData_Object)&    theObject1,
60                        HYDROData_PriorityType             thePriority,
61                        const Handle(HYDROData_Object)&    theObject2,
62                        HYDROData_Zone::MergeAltitudesType theMergeType );
63   static HYDROData_ListOfRules GetRules( const TDF_Label& theRulesLabel );
64   static QString DumpRules( const TDF_Label& theRulesLab );
65   static void DumpRulesToPython( const TDF_Label& theRulesLab,
66                                  const QString& theCalcCaseName,
67                                  QStringList& theScript );
68   static bool GetRule( const TDF_Label& theRulesLab,
69                        int theIndex, 
70                        Handle(HYDROData_Object)&           theObject1,
71                        HYDROData_PriorityType&             thePriority,
72                        Handle(HYDROData_Object)&           theObject2,
73                        HYDROData_Zone::MergeAltitudesType& theMergeType );
74 private:
75   typedef QMap<QString, Handle(HYDROData_Object)> MapNameToObject;
76
77   HYDROData_SequenceOfObjects myGeomObjects;  ///< the ordered list of objects (default priority)
78   MapNameToObject             myNames;        ///< the map of name to object
79   HYDROData_ListOfRules       myRules;        ///< the list of rules
80 };
81
82 #endif
83