b311480e |
1 | // Created on: 2004-11-23 |
2 | // Created by: Pavel TELKOV |
973c2be1 |
3 | // Copyright (c) 2004-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
b311480e |
15 | |
7fd59977 |
16 | // The original implementation Copyright: (C) RINA S.p.A |
17 | |
18 | #ifndef TObj_Partition_HeaderFile |
19 | #define TObj_Partition_HeaderFile |
20 | |
21 | #include <TObj_Object.hxx> |
22 | #include <TObj_Persistence.hxx> |
23 | |
7fd59977 |
24 | |
25 | /** |
26 | * This class privides tool handling one of partitions (the set of |
27 | * homogenious elements) in the OCAF based model`s data structure |
28 | */ |
29 | |
30 | class TObj_Partition : public TObj_Object |
31 | { |
32 | protected: |
33 | enum DataTag |
34 | { |
35 | DataTag_First = TObj_Object::DataTag_Last, |
36 | DataTag_LastIndex, |
37 | DataTag_Last = DataTag_First + 100 |
38 | }; |
39 | |
40 | protected: |
41 | /** |
42 | * Constructor |
43 | */ |
44 | |
45 | //! Constructor is protected; |
46 | //! static methods are used for creation of this type of objects |
47 | Standard_EXPORT TObj_Partition (const TDF_Label& theLabel); |
48 | |
49 | public: |
50 | /** |
51 | * Method for create partition |
52 | */ |
53 | |
54 | //! Creates a new partition on given label. |
55 | static Standard_EXPORT Handle(TObj_Partition) Create |
56 | (const TDF_Label& theLabel); |
57 | |
58 | public: |
59 | /** |
60 | * Methods hanling name of the object |
61 | */ |
62 | |
63 | //! Sets name of the object. partition does not check unique of own name |
64 | virtual Standard_EXPORT Standard_Boolean SetName |
79104795 |
65 | (const Handle(TCollection_HExtendedString)& theName) const Standard_OVERRIDE; |
7fd59977 |
66 | |
67 | public: |
68 | /** |
69 | * Method for updating object afrer restoring |
70 | */ |
71 | |
72 | //! Preforms updating the links and dependances of the object which are not |
73 | //! stored in persistence. Does not register the partition name |
79104795 |
74 | virtual Standard_EXPORT void AfterRetrieval() Standard_OVERRIDE; |
7fd59977 |
75 | |
76 | public: |
77 | /** |
78 | * Methods handling of the objects in partition |
79 | */ |
80 | |
81 | //! Creates and Returns label for new object in partition. |
82 | Standard_EXPORT TDF_Label NewLabel() const; |
83 | |
84 | //! Sets prefix for names of the objects in partition. |
85 | Standard_EXPORT void SetNamePrefix |
86 | (const Handle(TCollection_HExtendedString)& thePrefix); |
87 | |
88 | //! Returns prefix for names of the objects in partition. |
be5c3602 |
89 | Handle(TCollection_HExtendedString) GetNamePrefix() const |
7fd59977 |
90 | { return myPrefix; } |
91 | |
92 | //! Generates and returns name for new object in partition. |
93 | //! if theIsToChangeCount is true partition icrease own counter |
94 | //! to generate new name next time starting from new counter value |
95 | Standard_EXPORT Handle(TCollection_HExtendedString) GetNewName |
96 | ( const Standard_Boolean theIsToChangeCount = Standard_True ); |
97 | |
98 | //! Return Last index in partition (reserved); |
99 | Standard_EXPORT Standard_Integer GetLastIndex() const; |
100 | |
101 | //! Sets Last index in partition (reserved); |
102 | Standard_EXPORT void SetLastIndex(const Standard_Integer theIndex); |
103 | |
104 | public: |
105 | /** |
106 | * Methods to define partition by object |
107 | */ |
108 | |
109 | //! Returns the partition in which object is stored. Null partition |
110 | //! returned if not found |
111 | static Standard_EXPORT Handle(TObj_Partition) GetPartition |
112 | (const Handle(TObj_Object)& theObject); |
113 | |
114 | public: |
115 | /** |
116 | * Methods for updating the object |
117 | */ |
118 | |
119 | //! Does nothing in the partition. |
be5c3602 |
120 | virtual Standard_Boolean Update() |
7fd59977 |
121 | {return Standard_True;} |
122 | |
123 | protected: |
124 | /** |
125 | * protected redefined methods |
126 | */ |
127 | |
128 | //! Coping the data of me to Target object. |
129 | //! return Standard_False is Target object is different type |
130 | Standard_EXPORT virtual Standard_Boolean copyData |
79104795 |
131 | (const Handle(TObj_Object)& theTargetObject) Standard_OVERRIDE; |
7fd59977 |
132 | |
133 | private: |
134 | /** |
135 | * fields |
136 | */ |
137 | |
138 | //! prefix for naming of objects in the partition |
139 | Handle(TCollection_HExtendedString) myPrefix; |
140 | |
141 | protected: |
142 | //! Persistence of TObj object |
143 | DECLARE_TOBJOCAF_PERSISTENCE(TObj_Partition,TObj_Object) |
144 | |
145 | public: |
146 | //! CASCADE RTTI |
92efcf78 |
147 | DEFINE_STANDARD_RTTIEXT(TObj_Partition,TObj_Object) |
7fd59977 |
148 | |
149 | public: |
150 | friend class TObj_Model; |
151 | |
152 | }; |
153 | |
154 | //! Define handle class for TObj_Partition |
155 | DEFINE_STANDARD_HANDLE(TObj_Partition,TObj_Object) |
156 | |
157 | #endif |
158 | |
159 | #ifdef _MSC_VER |
160 | #pragma once |
161 | #endif |