1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef GeomAPI_DataMapOfShapeMapOfShapes_H_
22 #define GeomAPI_DataMapOfShapeMapOfShapes_H_
24 #include "GeomAPI_Interface.h"
26 #include "GeomAPI_Shape.h"
28 /// \class GeomAPI_DataMapOfShapeMapOfShapes
29 /// \ingroup DataModel
30 /// \brief DataMap of Shape - Map of Shapes defined by TopoDS_Shapes
31 class GeomAPI_DataMapOfShapeMapOfShapes : public GeomAPI_Interface
34 /// Constructor.Creates empty map.
35 GEOMAPI_EXPORT GeomAPI_DataMapOfShapeMapOfShapes();
37 /// \brief Binds list of shapes to the key shape.
38 /// \param[in] theKey key shape.
39 /// \param[in] theItems list of shapes.
40 /// If shapes have duplications in list only one will be stored.
41 /// \returns true if items bound successfully.
42 GEOMAPI_EXPORT bool bind(const std::shared_ptr<GeomAPI_Shape> theKey,
43 const ListOfShape& theItems);
45 /// \brief Adds item to the map bounded to the key.
46 /// \param[in] theKey key shape.
47 /// \param[in] theItem item shape.
48 /// \returns true if item bounded successfully. False if it is already bound.
49 GEOMAPI_EXPORT bool add(const std::shared_ptr<GeomAPI_Shape> theKey,
50 const std::shared_ptr<GeomAPI_Shape> theItem);
52 /// \return true if theKey is stored in the map.
53 GEOMAPI_EXPORT bool isBound(const std::shared_ptr<GeomAPI_Shape> theKey) const;
55 /// \return list of shapes bounded to theKey.
56 GEOMAPI_EXPORT bool find(const std::shared_ptr<GeomAPI_Shape> theKey,
57 ListOfShape& theItems) const;
59 /// Undinds shapes from theKey.
60 GEOMAPI_EXPORT bool unBind(const std::shared_ptr<GeomAPI_Shape> theKey);
63 GEOMAPI_EXPORT void clear();
65 /// \return size of map.
66 GEOMAPI_EXPORT int size() const;
72 typedef GeomShapePtr key_type;
73 typedef ListOfShape mapped_type;
74 typedef std::pair<GeomShapePtr, ListOfShape> value_type;
77 GEOMAPI_EXPORT iterator();
78 GEOMAPI_EXPORT iterator(const iterator&);
79 GEOMAPI_EXPORT const iterator& operator=(const iterator&);
81 GEOMAPI_EXPORT bool operator==(const iterator&) const;
82 GEOMAPI_EXPORT bool operator!=(const iterator&) const;
84 GEOMAPI_EXPORT virtual iterator& operator++();
85 GEOMAPI_EXPORT virtual iterator operator++(int);
87 GEOMAPI_EXPORT virtual key_type first() const;
88 GEOMAPI_EXPORT virtual mapped_type second() const;
91 std::shared_ptr<iterator> mySelf;
94 typedef iterator const_iterator;
96 GEOMAPI_EXPORT iterator begin();
97 GEOMAPI_EXPORT const_iterator begin() const;
99 GEOMAPI_EXPORT iterator end();
100 GEOMAPI_EXPORT const_iterator end() const;