Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-27 09:43:13

0001 // Created on: 1992-11-17
0002 // Created by: Christian CAILLET
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _IFSelect_ShareOut_HeaderFile
0018 #define _IFSelect_ShareOut_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <IFSelect_TSeqOfDispatch.hxx>
0024 #include <IFSelect_SequenceOfGeneralModifier.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_Transient.hxx>
0027 class TCollection_HAsciiString;
0028 class IFSelect_Dispatch;
0029 class IFSelect_GeneralModifier;
0030 class IFSelect_Modifier;
0031 class TCollection_AsciiString;
0032 
0033 class IFSelect_ShareOut;
0034 DEFINE_STANDARD_HANDLE(IFSelect_ShareOut, Standard_Transient)
0035 
0036 //! This class gathers the information required to produce one or
0037 //! several file(s) from the content of an InterfaceModel (passing
0038 //! through the creation of intermediate Models).
0039 //!
0040 //! It can correspond to a complete Divide up of a set of Entities
0041 //! intended to be exhaustive and to limit duplications. Or to a
0042 //! simple Extraction of some Entities, in order to work on them.
0043 //!
0044 //! A ShareOut is composed of a list of Dispatches.
0045 //! To Each Dispatch in the ShareOut, is bound an Id. Number
0046 //! This Id. Number allows to identify a Display inside the
0047 //! ShareOut in a stable way (for instance, to attach file names)
0048 //!
0049 //! ShareOut can be seen as a "passive" description, activated
0050 //! through a ShareOutResult, which gives the InterfaceModel on
0051 //! which to work, as a unique source. Thus it is easy to change
0052 //! it without coherence problems
0053 //!
0054 //! Services about it are provided by the class ShareOutResult
0055 //! which is a service class : simulation (list of files and of
0056 //! entities per file; "forgotten" entities; duplicated entities),
0057 //! exploitation (generation of derivated Models, each of them
0058 //! generating an output file)
0059 class IFSelect_ShareOut : public Standard_Transient
0060 {
0061 
0062 public:
0063   //! Creates an empty ShareOut
0064   Standard_EXPORT IFSelect_ShareOut();
0065 
0066   //! Removes in one operation all the Dispatches with their Idents
0067   //! Also clears all information about Names, and all Results but
0068   //! naming information which are :
0069   //! - kept if <onlydisp> is True.
0070   //! - cleared if <onlydisp> is False (complete clearing)
0071   //! If <onlydisp> is True, that's all. Else, clears also Modifiers
0072   Standard_EXPORT void Clear(const Standard_Boolean onlydisp);
0073 
0074   //! Clears all data produced (apart from Dispatches, etc...)
0075   //! if <alsoname> is True, all is cleared. Else, information
0076   //! about produced Names are kept (to maintain unicity of naming
0077   //! across clearings)
0078   Standard_EXPORT void ClearResult(const Standard_Boolean alsoname);
0079 
0080   //! Removes an item, which can be, either a Dispatch (removed from
0081   //! the list of Dispatches), or a GeneralModifier (removed from
0082   //! the list of Model Modifiers or from the list of File Modifiers
0083   //! according to its type).
0084   //! Returns True if done, False if has not been found or if it is
0085   //! neither a Dispatch, nor a Modifier.
0086   Standard_EXPORT Standard_Boolean RemoveItem(const Handle(Standard_Transient)& item);
0087 
0088   //! Returns the rank of last run item (ClearResult resets it to 0)
0089   Standard_EXPORT Standard_Integer LastRun() const;
0090 
0091   //! Records a new value for the rank of last run item
0092   Standard_EXPORT void SetLastRun(const Standard_Integer last);
0093 
0094   //! Returns the count of Dispatches
0095   Standard_EXPORT Standard_Integer NbDispatches() const;
0096 
0097   //! Returns the Rank of a Dispatch, given its Value (Handle).
0098   //! Returns 0 if the Dispatch is unknown in the ShareOut
0099   Standard_EXPORT Standard_Integer DispatchRank(const Handle(IFSelect_Dispatch)& disp) const;
0100 
0101   //! Returns a Dispatch, given its rank in the list
0102   Standard_EXPORT const Handle(IFSelect_Dispatch)& Dispatch(const Standard_Integer num) const;
0103 
0104   //! Adds a Dispatch to the list
0105   Standard_EXPORT void AddDispatch(const Handle(IFSelect_Dispatch)& disp);
0106 
0107   //! Removes a Dispatch, given its rank in the list
0108   //! Returns True if done, False if rank is not between
0109   //! (LastRun + 1) and (NbDispatches)
0110   Standard_EXPORT Standard_Boolean RemoveDispatch(const Standard_Integer rank);
0111 
0112   //! Sets a Modifier to be applied on all Dispatches to be run
0113   //! If <modifier> is a ModelModifier, adds it to the list of
0114   //! Model Modifiers; else to the list of File Modifiers
0115   //! By default (atnum = 0) at the end of the list, else at <atnum>
0116   //! Each Modifier is used, after each copy of a packet of Entities
0117   //! into a Model : its criteria are checked and if they are OK,
0118   //! the method Perform of this Modifier is run.
0119   Standard_EXPORT void AddModifier(const Handle(IFSelect_GeneralModifier)& modifier,
0120                                    const Standard_Integer                  atnum);
0121 
0122   //! Sets a Modifier to be applied on the Dispatch <dispnum>
0123   //! If <modifier> is a ModelModifier, adds it to the list of
0124   //! Model Modifiers; else to the list of File Modifiers
0125   //! This is the same list as for all Dispatches, but the
0126   //! Modifier is qualified to be applied to one Dispatch only
0127   //! Then, <atnum> refers to the entire list
0128   //! By default (atnum = 0) at the end of the list, else at <atnum>
0129   //! Remark : if the Modifier was already in the list and if
0130   //! <atnum> = 0, the Modifier is not moved, but only qualified
0131   //! for a Dispatch
0132   Standard_EXPORT void AddModifier(const Handle(IFSelect_GeneralModifier)& modifier,
0133                                    const Standard_Integer                  dispnum,
0134                                    const Standard_Integer                  atnum);
0135 
0136   //! Adds a Modifier to the list of Modifiers : Model Modifiers if
0137   //! <formodel> is True, File Modifiers else (internal).
0138   Standard_EXPORT void AddModif(const Handle(IFSelect_GeneralModifier)& modifier,
0139                                 const Standard_Boolean                  formodel,
0140                                 const Standard_Integer                  atnum = 0);
0141 
0142   //! Returns count of Modifiers (which apply to complete Models) :
0143   //! Model Modifiers if <formodel> is True, File Modifiers else
0144   Standard_EXPORT Standard_Integer NbModifiers(const Standard_Boolean formodel) const;
0145 
0146   //! Returns a Modifier of the list, given its rank :
0147   //! Model Modifiers if <formodel> is True, File Modifiers else
0148   Standard_EXPORT Handle(IFSelect_GeneralModifier) GeneralModifier(
0149     const Standard_Boolean formodel,
0150     const Standard_Integer num) const;
0151 
0152   //! Returns a Modifier of the list of Model Modifiers, duely casted
0153   Standard_EXPORT Handle(IFSelect_Modifier) ModelModifier(const Standard_Integer num) const;
0154 
0155   //! Gives the rank of a Modifier in the list, 0 if not in the list
0156   //! Model Modifiers if <modifier> is kind of ModelModifer,
0157   //! File Modifiers else
0158   Standard_EXPORT Standard_Integer
0159     ModifierRank(const Handle(IFSelect_GeneralModifier)& modifier) const;
0160 
0161   //! Removes a Modifier, given it rank in the list :
0162   //! Model Modifiers if <formodel> is True, File Modifiers else
0163   //! Returns True if done, False if <num> is out of range
0164   Standard_EXPORT Standard_Boolean RemoveModifier(const Standard_Boolean formodel,
0165                                                   const Standard_Integer num);
0166 
0167   //! Changes the rank of a modifier in the list :
0168   //! Model Modifiers if <formodel> is True, File Modifiers else
0169   //! from <before> to <after>
0170   //! Returns True if done, False else (before or after out of range)
0171   Standard_EXPORT Standard_Boolean ChangeModifierRank(const Standard_Boolean formodel,
0172                                                       const Standard_Integer befor,
0173                                                       const Standard_Integer after);
0174 
0175   //! Attaches a Root Name to a Dispatch given its rank, as an
0176   //! HAsciiString (standard form). A Null Handle resets this name.
0177   //! Returns True if OK, False if this Name is already attached,
0178   //! for a Dispatch or for Default, or <num> out of range
0179   Standard_EXPORT Standard_Boolean SetRootName(const Standard_Integer                  num,
0180                                                const Handle(TCollection_HAsciiString)& name);
0181 
0182   //! Returns True if the Dispatch of rank <num> has an attached
0183   //! Root Name. False else, or if num is out of range
0184   Standard_EXPORT Standard_Boolean HasRootName(const Standard_Integer num) const;
0185 
0186   //! Returns the Root bound to a Dispatch, given its rank
0187   //! Returns a Null Handle if not defined
0188   Standard_EXPORT Handle(TCollection_HAsciiString) RootName(const Standard_Integer num) const;
0189 
0190   //! Returns an integer value about a given root name :
0191   //! - positive : it's the rank of the Dispatch which has this name
0192   //! - null : this root name is unknown
0193   //! - negative (-1) : this root name is the default root name
0194   Standard_EXPORT Standard_Integer RootNumber(const Handle(TCollection_HAsciiString)& name) const;
0195 
0196   //! Defines or Changes the general Prefix (which is prepended to
0197   //! complete file name generated). If this method is not call,
0198   //! Prefix remains empty
0199   Standard_EXPORT void SetPrefix(const Handle(TCollection_HAsciiString)& pref);
0200 
0201   //! Defines or Changes the Default Root Name to a new value (which
0202   //! is used for dispatches which have no attached root name).
0203   //! If this method is not called, DefaultRootName remains empty
0204   //! Returns True if OK, False if this Name is already attached,
0205   //! for a Dispatch or for Default
0206   Standard_EXPORT Standard_Boolean
0207     SetDefaultRootName(const Handle(TCollection_HAsciiString)& defrt);
0208 
0209   //! Defines or Changes the general Extension (which is appended to
0210   //! complete file name generated). If this method is not call,
0211   //! Extension remains empty
0212   Standard_EXPORT void SetExtension(const Handle(TCollection_HAsciiString)& ext);
0213 
0214   //! Returns the general Prefix. Can be empty.
0215   Standard_EXPORT Handle(TCollection_HAsciiString) Prefix() const;
0216 
0217   //! Returns the Default Root Name. Can be empty.
0218   Standard_EXPORT Handle(TCollection_HAsciiString) DefaultRootName() const;
0219 
0220   //! Returns the general Extension. Can be empty (not recommended)
0221   Standard_EXPORT Handle(TCollection_HAsciiString) Extension() const;
0222 
0223   //! Computes the complete file name for a Packet of a Dispatch,
0224   //! given Dispatch Number (Rank), Packet Number, and Count of
0225   //! Packets generated by this Dispatch (0 if unknown)
0226   //!
0227   //! File Name is made of following strings, concatenated :
0228   //! General Prefix, Root Name for Dispatch, Packet Suffix, and
0229   //! General Extension. If no Root Name is specified for a
0230   //! Dispatch, DefaultRootName is considered (and pnum is not used,
0231   //! but <thenbdefs> is incremented and used
0232   //! Error if no Root is defined for this <idnum>
0233   Standard_EXPORT TCollection_AsciiString FileName(const Standard_Integer dnum,
0234                                                    const Standard_Integer pnum,
0235                                                    const Standard_Integer nbpack = 0);
0236 
0237   DEFINE_STANDARD_RTTIEXT(IFSelect_ShareOut, Standard_Transient)
0238 
0239 private:
0240   IFSelect_TSeqOfDispatch            thedisps;
0241   IFSelect_SequenceOfGeneralModifier themodelmodifiers;
0242   IFSelect_SequenceOfGeneralModifier thefilemodifiers;
0243   Handle(TCollection_HAsciiString)   thepref;
0244   Handle(TCollection_HAsciiString)   thedefrt;
0245   Handle(TCollection_HAsciiString)   theext;
0246   Standard_Integer                   thenbdefs;
0247   Standard_Integer                   thelastrun;
0248 };
0249 
0250 #endif // _IFSelect_ShareOut_HeaderFile