Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-14 08:41:40

0001 // Created on: 2004-11-23
0002 // Created by: Pavel TELKOV
0003 // Copyright (c) 2004-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 // The original implementation Copyright: (C) RINA S.p.A
0017 
0018 #ifndef TObj_Partition_HeaderFile
0019 #define TObj_Partition_HeaderFile
0020 
0021 #include <TObj_Object.hxx>
0022 #include <TObj_Persistence.hxx>
0023 
0024 /**
0025  * This class provides tool handling one of partitions (the set of
0026  * homogeneous elements) in the OCAF based model`s data structure
0027  */
0028 
0029 class TObj_Partition : public TObj_Object
0030 {
0031 protected:
0032   enum DataTag
0033   {
0034     DataTag_First = TObj_Object::DataTag_Last,
0035     DataTag_LastIndex,
0036     DataTag_Last = DataTag_First + 100
0037   };
0038 
0039 protected:
0040   /**
0041    * Constructor
0042    */
0043 
0044   //! Constructor is protected;
0045   //! static methods are used for creation of this type of objects
0046   Standard_EXPORT TObj_Partition(const TDF_Label&       theLabel,
0047                                  const Standard_Boolean theSetName = Standard_True);
0048 
0049 public:
0050   /**
0051    * Method for create partition
0052    */
0053 
0054   //! Creates a new partition on given label.
0055   static Standard_EXPORT Handle(TObj_Partition) Create(
0056     const TDF_Label&       theLabel,
0057     const Standard_Boolean theSetName = Standard_True);
0058 
0059 public:
0060   /**
0061    * Methods handling name of the object
0062    */
0063 
0064   //! Sets name of the object. partition does not check unique of own name
0065   virtual Standard_EXPORT Standard_Boolean
0066     SetName(const Handle(TCollection_HExtendedString)& theName) const Standard_OVERRIDE;
0067 
0068 public:
0069   /**
0070    * Method for updating object after restoring
0071    */
0072 
0073   //! Performs updating the links and dependencies of the object which are not
0074   //! stored in persistence. Does not register the partition name
0075   virtual Standard_EXPORT void AfterRetrieval() Standard_OVERRIDE;
0076 
0077 public:
0078   /**
0079    * Methods handling of the objects in partition
0080    */
0081 
0082   //! Creates and Returns label for new object in partition.
0083   Standard_EXPORT TDF_Label NewLabel() const;
0084 
0085   //! Sets prefix for names of the objects in partition.
0086   Standard_EXPORT void SetNamePrefix(const Handle(TCollection_HExtendedString)& thePrefix);
0087 
0088   //! Returns prefix for names of the objects in partition.
0089   Handle(TCollection_HExtendedString) GetNamePrefix() const { return myPrefix; }
0090 
0091   //! Generates and returns name for new object in partition.
0092   //! if theIsToChangeCount is true partition increase own counter
0093   //!  to generate new name next time starting from new counter value
0094   Standard_EXPORT Handle(TCollection_HExtendedString) GetNewName(
0095     const Standard_Boolean theIsToChangeCount = Standard_True);
0096 
0097   //! Return Last index in partition (reserved);
0098   Standard_EXPORT Standard_Integer GetLastIndex() const;
0099 
0100   //! Sets Last index in partition (reserved);
0101   Standard_EXPORT void SetLastIndex(const Standard_Integer theIndex);
0102 
0103 public:
0104   /**
0105    * Methods to define partition by object
0106    */
0107 
0108   //! Returns the partition in which object is stored. Null partition
0109   //! returned if not found
0110   static Standard_EXPORT Handle(TObj_Partition) GetPartition(const Handle(TObj_Object)& theObject);
0111 
0112 public:
0113   /**
0114    * Methods for updating the object
0115    */
0116 
0117   //! Does nothing in the partition.
0118   virtual Standard_Boolean Update() { return Standard_True; }
0119 
0120 protected:
0121   /**
0122    * protected redefined methods
0123    */
0124 
0125   //! Coping the data of me to Target object.
0126   //! return Standard_False is Target object is different type
0127   Standard_EXPORT virtual Standard_Boolean copyData(const Handle(TObj_Object)& theTargetObject)
0128     Standard_OVERRIDE;
0129 
0130 private:
0131   /**
0132    * fields
0133    */
0134 
0135   //! prefix for naming of objects in the partition
0136   Handle(TCollection_HExtendedString) myPrefix;
0137 
0138 protected:
0139   //! Persistence of TObj object
0140   DECLARE_TOBJOCAF_PERSISTENCE(TObj_Partition, TObj_Object)
0141 
0142 public:
0143   //! CASCADE RTTI
0144   DEFINE_STANDARD_RTTIEXT(TObj_Partition, TObj_Object)
0145 
0146 public:
0147   friend class TObj_Model;
0148 };
0149 
0150 //! Define handle class for TObj_Partition
0151 DEFINE_STANDARD_HANDLE(TObj_Partition, TObj_Object)
0152 
0153 #endif
0154 
0155 #ifdef _MSC_VER
0156 #pragma once
0157 #endif