1 // Created on: 2004-11-23
2 // Created by: Pavel TELKOV
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 // The original implementation Copyright: (C) RINA S.p.A
18 #ifndef TObj_Partition_HeaderFile
19 #define TObj_Partition_HeaderFile
21 #include <TObj_Object.hxx>
22 #include <TObj_Persistence.hxx>
26 * This class privides tool handling one of partitions (the set of
27 * homogenious elements) in the OCAF based model`s data structure
30 class TObj_Partition : public TObj_Object
35 DataTag_First = TObj_Object::DataTag_Last,
37 DataTag_Last = DataTag_First + 100
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);
51 * Method for create partition
54 //! Creates a new partition on given label.
55 static Standard_EXPORT Handle(TObj_Partition) Create
56 (const TDF_Label& theLabel);
60 * Methods hanling name of the object
63 //! Sets name of the object. partition does not check unique of own name
64 virtual Standard_EXPORT Standard_Boolean SetName
65 (const Handle(TCollection_HExtendedString)& theName) const Standard_OVERRIDE;
69 * Method for updating object afrer restoring
72 //! Preforms updating the links and dependances of the object which are not
73 //! stored in persistence. Does not register the partition name
74 virtual Standard_EXPORT void AfterRetrieval() Standard_OVERRIDE;
78 * Methods handling of the objects in partition
81 //! Creates and Returns label for new object in partition.
82 Standard_EXPORT TDF_Label NewLabel() const;
84 //! Sets prefix for names of the objects in partition.
85 Standard_EXPORT void SetNamePrefix
86 (const Handle(TCollection_HExtendedString)& thePrefix);
88 //! Returns prefix for names of the objects in partition.
89 Handle(TCollection_HExtendedString) GetNamePrefix() const
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 );
98 //! Return Last index in partition (reserved);
99 Standard_EXPORT Standard_Integer GetLastIndex() const;
101 //! Sets Last index in partition (reserved);
102 Standard_EXPORT void SetLastIndex(const Standard_Integer theIndex);
106 * Methods to define partition by object
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);
116 * Methods for updating the object
119 //! Does nothing in the partition.
120 virtual Standard_Boolean Update()
121 {return Standard_True;}
125 * protected redefined methods
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
131 (const Handle(TObj_Object)& theTargetObject) Standard_OVERRIDE;
138 //! prefix for naming of objects in the partition
139 Handle(TCollection_HExtendedString) myPrefix;
142 //! Persistence of TObj object
143 DECLARE_TOBJOCAF_PERSISTENCE(TObj_Partition,TObj_Object)
147 DEFINE_STANDARD_RTTIEXT(TObj_Partition,TObj_Object)
150 friend class TObj_Model;
154 //! Define handle class for TObj_Partition
155 DEFINE_STANDARD_HANDLE(TObj_Partition,TObj_Object)