]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROData/HYDROData_PriorityQueue.h
Salome HOME
refs #673: Strickler coefficient should be written for Telemac instead of Strickler...
[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_Entity.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_Entity)  Object1;
37   HYDROData_PriorityType    Priority;
38   Handle(HYDROData_Entity)  Object2;
39   HYDROData_Zone::MergeType MergeType;
40 };
41
42 typedef QList<HYDROData_CustomRule> HYDROData_ListOfRules;
43
44 class HYDROData_PriorityQueue
45 {
46 public:
47   HYDROData_PriorityQueue( HYDROData_CalculationCase* theCalcCase,
48                            Standard_Integer aTag );
49   ~HYDROData_PriorityQueue();
50
51   Handle_HYDROData_Entity GetMostPriorityObject( const QStringList& theZoneObjects,
52                                                  HYDROData_Zone::MergeType& theMergeType ) const;
53
54   bool IsMorePriority( const Handle(HYDROData_Entity)& theObj1,
55                        const Handle(HYDROData_Entity)& theObj2,
56                        HYDROData_Zone::MergeType& theMergeType ) const;
57
58   static void ClearRules( TDF_Label& theRulesLabel );
59   static void AddRule( TDF_Label& theRulesLabel,
60                        const Handle(HYDROData_Entity)&    theObject1,
61                        HYDROData_PriorityType             thePriority,
62                        const Handle(HYDROData_Entity)&    theObject2,
63                        HYDROData_Zone::MergeType theMergeType );
64   static HYDROData_ListOfRules GetRules( const TDF_Label& theRulesLabel );
65   static QString DumpRules( const TDF_Label& theRulesLab );
66   static void DumpRulesToPython( const TDF_Label& theRulesLab,
67                                  const QString& theCalcCaseName,
68                                  QStringList& theScript );
69   static bool GetRule( const TDF_Label& theRulesLab,
70                        int theIndex, 
71                        Handle(HYDROData_Entity)&           theObject1,
72                        HYDROData_PriorityType&             thePriority,
73                        Handle(HYDROData_Entity)&           theObject2,
74                        HYDROData_Zone::MergeType& theMergeType );
75 private:
76   typedef QMap<QString, Handle(HYDROData_Entity)> MapNameToObject;
77
78   HYDROData_SequenceOfObjects myObjects;  ///< the ordered list of objects (default priority)
79   MapNameToObject             myNames;    ///< the map of name to object
80   HYDROData_ListOfRules       myRules;    ///< the list of rules
81 };
82
83 #endif
84