Salome HOME
301b1783e0f63737e4de060e3aeb4379e6c32116
[modules/shaper.git] / src / GeomAPI / GeomAPI_DataMapOfShapeMapOfShapes.h
1 // Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef GeomAPI_DataMapOfShapeMapOfShapes_H_
21 #define GeomAPI_DataMapOfShapeMapOfShapes_H_
22
23 #include "GeomAPI_Interface.h"
24
25 #include "GeomAPI_Shape.h"
26
27 /// \class GeomAPI_DataMapOfShapeMapOfShapes
28 /// \ingroup DataModel
29 /// \brief DataMap of Shape - Map of Shapes defined by TopoDS_Shapes
30 class GeomAPI_DataMapOfShapeMapOfShapes : public GeomAPI_Interface
31 {
32 public:
33   /// Constructor.Creates empty map.
34   GEOMAPI_EXPORT GeomAPI_DataMapOfShapeMapOfShapes();
35
36   /// \brief Binds list of shapes to the key shape.
37   /// \param[in] theKey key shape.
38   /// \param[in] theItems list of shapes.
39   ///                     If shapes have duplications in list only one will be stored.
40   /// \returns true if items bound successfully.
41   GEOMAPI_EXPORT bool bind(const std::shared_ptr<GeomAPI_Shape> theKey,
42                            const ListOfShape& theItems);
43
44   /// \brief Adds item to the map bounded to the key.
45   /// \param[in] theKey key shape.
46   /// \param[in] theItem item shape.
47   /// \returns true if item bounded successfully. False if it is already bound.
48   GEOMAPI_EXPORT bool add(const std::shared_ptr<GeomAPI_Shape> theKey,
49                           const std::shared_ptr<GeomAPI_Shape> theItem);
50
51   /// \return true if theKey is stored  in the map.
52   GEOMAPI_EXPORT bool isBound(const std::shared_ptr<GeomAPI_Shape> theKey) const;
53
54   /// \return list of shapes bounded to theKey.
55   GEOMAPI_EXPORT bool find(const std::shared_ptr<GeomAPI_Shape> theKey,
56                            ListOfShape& theItems) const;
57
58   /// Undinds shapes from theKey.
59   GEOMAPI_EXPORT bool unBind(const std::shared_ptr<GeomAPI_Shape> theKey);
60
61   /// Clears map.
62   GEOMAPI_EXPORT void clear();
63
64   /// \return size of map.
65   GEOMAPI_EXPORT int size() const;
66
67 public:
68   class iterator
69   {
70   public:
71     typedef GeomShapePtr key_type;
72     typedef ListOfShape  mapped_type;
73     typedef std::pair<GeomShapePtr, ListOfShape> value_type;
74
75   public:
76     GEOMAPI_EXPORT iterator();
77     GEOMAPI_EXPORT iterator(const iterator&);
78     GEOMAPI_EXPORT const iterator& operator=(const iterator&);
79
80     GEOMAPI_EXPORT bool operator==(const iterator&) const;
81     GEOMAPI_EXPORT bool operator!=(const iterator&) const;
82
83     GEOMAPI_EXPORT virtual iterator& operator++();
84     GEOMAPI_EXPORT virtual iterator  operator++(int);
85
86     GEOMAPI_EXPORT virtual key_type first() const;
87     GEOMAPI_EXPORT virtual mapped_type second() const;
88
89   protected:
90     std::shared_ptr<iterator> mySelf;
91   };
92
93   typedef iterator const_iterator;
94
95   GEOMAPI_EXPORT iterator begin();
96   GEOMAPI_EXPORT const_iterator begin() const;
97
98   GEOMAPI_EXPORT iterator end();
99   GEOMAPI_EXPORT const_iterator end() const;
100 };
101
102 #endif