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