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