42cf5bc1 |
1 | // Created on: 2007-07-31 |
2 | // Created by: Sergey ZARITCHNY |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _TDataStd_IntPackedMap_HeaderFile |
17 | #define _TDataStd_IntPackedMap_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Type.hxx> |
21 | |
22 | #include <Standard_Boolean.hxx> |
23 | #include <TDF_Attribute.hxx> |
7c1a9a46 |
24 | #include <TColStd_HPackedMapOfInteger.hxx> |
42cf5bc1 |
25 | #include <Standard_Integer.hxx> |
26 | #include <Standard_OStream.hxx> |
7c1a9a46 |
27 | |
42cf5bc1 |
28 | class TDataStd_DeltaOnModificationOfIntPackedMap; |
29 | class Standard_GUID; |
30 | class TDF_Label; |
31 | class TDF_Attribute; |
32 | class TDF_RelocationTable; |
33 | class TDF_DeltaOnModification; |
34 | |
42cf5bc1 |
35 | class TDataStd_IntPackedMap; |
36 | DEFINE_STANDARD_HANDLE(TDataStd_IntPackedMap, TDF_Attribute) |
37 | |
38 | //! Attribute for storing TColStd_PackedMapOfInteger |
39 | class TDataStd_IntPackedMap : public TDF_Attribute |
40 | { |
7c1a9a46 |
41 | friend class TDataStd_DeltaOnModificationOfIntPackedMap; |
42 | DEFINE_STANDARD_RTTIEXT(TDataStd_IntPackedMap, TDF_Attribute) |
42cf5bc1 |
43 | public: |
44 | |
42cf5bc1 |
45 | //! class methods |
46 | //! ============= |
47 | //! Returns the GUID of the attribute. |
48 | Standard_EXPORT static const Standard_GUID& GetID(); |
49 | |
50 | //! Finds or creates an integer map attribute on the given label. |
51 | //! If <isDelta> == False, DefaultDeltaOnModification is used. |
52 | //! If <isDelta> == True, DeltaOnModification of the current attribute is used. |
53 | //! If attribute is already set, input parameter <isDelta> is refused and the found |
54 | //! attribute returned. |
55 | //! Attribute methods |
56 | //! =================== |
57 | Standard_EXPORT static Handle(TDataStd_IntPackedMap) Set (const TDF_Label& label, const Standard_Boolean isDelta = Standard_False); |
58 | |
59 | Standard_EXPORT TDataStd_IntPackedMap(); |
60 | |
61 | Standard_EXPORT Standard_Boolean ChangeMap (const Handle(TColStd_HPackedMapOfInteger)& theMap); |
7c1a9a46 |
62 | |
14abe5dc |
63 | Standard_EXPORT Standard_Boolean ChangeMap (const TColStd_PackedMapOfInteger& theMap); |
64 | |
7c1a9a46 |
65 | const TColStd_PackedMapOfInteger& GetMap() const { return myMap->Map(); } |
66 | |
67 | const Handle(TColStd_HPackedMapOfInteger)& GetHMap() const { return myMap; } |
68 | |
42cf5bc1 |
69 | Standard_EXPORT Standard_Boolean Clear(); |
70 | |
71 | Standard_EXPORT Standard_Boolean Add (const Standard_Integer theKey); |
72 | |
73 | Standard_EXPORT Standard_Boolean Remove (const Standard_Integer theKey); |
74 | |
75 | Standard_EXPORT Standard_Boolean Contains (const Standard_Integer theKey) const; |
7c1a9a46 |
76 | |
77 | Standard_Integer Extent() const { return myMap->Map().Extent(); } |
78 | |
79 | Standard_Boolean IsEmpty() const { return myMap->Map().IsEmpty(); } |
80 | |
81 | Standard_Boolean GetDelta() const { return myIsDelta; } |
82 | |
42cf5bc1 |
83 | //! for internal use only! |
7c1a9a46 |
84 | void SetDelta (const Standard_Boolean isDelta) { myIsDelta = isDelta; } |
85 | |
79104795 |
86 | Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE; |
42cf5bc1 |
87 | |
79104795 |
88 | Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE; |
42cf5bc1 |
89 | |
79104795 |
90 | Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE; |
42cf5bc1 |
91 | |
79104795 |
92 | Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE; |
42cf5bc1 |
93 | |
94 | Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE; |
95 | |
96 | //! Makes a DeltaOnModification between <me> and |
97 | //! <anOldAttribute>. |
98 | Standard_EXPORT virtual Handle(TDF_DeltaOnModification) DeltaOnModification (const Handle(TDF_Attribute)& anOldAttribute) const Standard_OVERRIDE; |
bc73b006 |
99 | |
100 | //! Dumps the content of me into the stream |
101 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
42cf5bc1 |
102 | |
7c1a9a46 |
103 | private: |
42cf5bc1 |
104 | |
7c1a9a46 |
105 | void RemoveMap() { myMap.Nullify(); } |
42cf5bc1 |
106 | |
107 | private: |
108 | |
42cf5bc1 |
109 | Handle(TColStd_HPackedMapOfInteger) myMap; |
110 | Standard_Boolean myIsDelta; |
111 | |
42cf5bc1 |
112 | }; |
113 | |
42cf5bc1 |
114 | #endif // _TDataStd_IntPackedMap_HeaderFile |