Salome HOME
eee63a47da4019d1fa17ade2af68ebf6648a3a35
[modules/geom.git] / src / ShHealOper / ShHealOper_ModifStats.hxx
1 // Copyright (C) 2007-2023  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 // File      : ShHealOper_ModifStats.hxx
24 // Created   : Mon Dec  1 15:29:48 2014
25
26 #ifndef __ShHealOper_ModifStats_HXX__
27 #define __ShHealOper_ModifStats_HXX__
28
29 #include <string>
30 #include <set>
31
32 /*!
33  * \brief Structure describing modifications done in a shape
34  */
35 class Standard_EXPORT ShHealOper_ModifStats
36 {
37  public:
38
39   struct Standard_EXPORT Datum
40   {
41     std::string myModif; // what is done
42     mutable int myCount; // how many times (in how many sub-shapes)
43
44     Datum( const std::string& txt, int cnt=0 ): myModif( txt ), myCount(cnt) {}
45     bool operator< ( const Datum& o ) const { return myModif < o.myModif; }
46   };
47
48   // record a modification
49   void AddModif( const std::string& modifText, int nb=1 )
50   {
51     std::set< Datum >::iterator d = myData.insert( Datum( modifText )).first;
52     d->myCount += nb;
53   }
54
55   // add data from another ShHealOper_ModifStats
56   void Add( const ShHealOper_ModifStats& stats )
57   {
58     if ( myData.empty() ) myData = stats.myData;
59     else {
60       std::set< Datum >::const_iterator d = stats.myData.begin();
61       for ( ; d != stats.myData.end(); ++d )
62         AddModif( d->myModif, d->myCount );
63     }
64   }
65
66   // return all recorder modifications
67   const std::set< Datum >& GetData() const { return myData; }
68
69   // clear all statistics
70   void Clear() { myData.clear(); }
71
72  protected:
73
74   std::set< Datum > myData;
75
76 };
77
78 #endif