Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:20

0001 // Created on: 1997-07-30
0002 // Created by: Jean-Louis Frenkel
0003 // Copyright (c) 1997-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 _CDM_Document_HeaderFile
0018 #define _CDM_Document_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <CDM_ListOfReferences.hxx>
0024 #include <CDM_CanCloseStatus.hxx>
0025 #include <TColStd_SequenceOfExtendedString.hxx>
0026 #include <TCollection_ExtendedString.hxx>
0027 #include <Standard_OStream.hxx>
0028 #include <CDM_ListOfDocument.hxx>
0029 
0030 class CDM_MetaData;
0031 class CDM_Application;
0032 class CDM_Reference;
0033 class Resource_Manager;
0034 
0035 class CDM_Document;
0036 DEFINE_STANDARD_HANDLE(CDM_Document, Standard_Transient)
0037 
0038 //! An applicative document is an instance of a class inheriting CDM_Document.
0039 //! These documents have the following properties:
0040 //! - they can have references to other documents.
0041 //! - the modifications of a document are propagated to the referencing
0042 //! documents.
0043 //! - a  document can be   stored in different formats, with  or
0044 //! without a persistent model.
0045 //! - the drivers  for  storing  and retrieving documents  are
0046 //! plugged in when necessary.
0047 //! - a  document has a modification counter. This counter is
0048 //! incremented when the document is  modified.  When a document
0049 //! is stored,  the current  counter  value is memorized as the
0050 //! last storage  version of the   document.  A document  is
0051 //! considered to be  modified   when the  counter value  is
0052 //! different from the storage version.  Once  the document is
0053 //! saved  the storage  version  and the  counter  value are
0054 //! identical.  The document  is  now  not considered  to  be
0055 //! modified.
0056 //! - a reference is a link between two documents. A reference has two
0057 //! components: the "From Document" and the "To Document". When
0058 //! a reference is created, an identifier of the reference is generated.
0059 //! This identifier is unique in the scope of the From Document and
0060 //! is conserved during storage and retrieval. This means that the
0061 //! referenced document will be always accessible through this
0062 //! identifier.
0063 //! - a reference memorizes the counter value of the To Document when
0064 //! the reference is created. The From Document is considered to
0065 //! be up to date relative to the To Document when the
0066 //! reference counter value is equal to the To Document counter value.
0067 //! -  retrieval of a document  having references does not imply
0068 //! the retrieving of the referenced documents.
0069 class CDM_Document : public Standard_Transient
0070 {
0071 
0072 public:
0073 
0074   
0075   //! The Update  method  will be called  once  for each
0076   //! reference, but it  should not perform any computation,
0077   //! to avoid multiple computation of a same document.
0078   Standard_EXPORT virtual void Update (const Handle(CDM_Document)& aToDocument, const Standard_Integer aReferenceIdentifier, const Standard_Address aModifContext);
0079   
0080   //! This method Update   will be called
0081   //! to signal the end   of the modified references list.
0082   //! The    document     should    be  recomputed     and
0083   //! UpdateFromDocuments  should be called.  Update should
0084   //! returns True in case  of success, false otherwise.  In
0085   //! case of Failure, additional information can be given in
0086   //! ErrorString.
0087   Standard_EXPORT virtual Standard_Boolean Update (TCollection_ExtendedString& ErrorString);
0088   
0089   //! The Storage Format is the key which is used to determine in the
0090   //! application resources the storage driver plugin, the file
0091   //! extension and other data used to store the document.
0092   Standard_EXPORT virtual TCollection_ExtendedString StorageFormat() const = 0;
0093   
0094   //! by default empties the extensions.
0095   Standard_EXPORT virtual void Extensions (TColStd_SequenceOfExtendedString& Extensions) const;
0096   
0097   //! This method can be redefined to extract another document in
0098   //! a different format. For example, to extract a Shape
0099   //! from an applicative document.
0100   Standard_EXPORT virtual Standard_Boolean GetAlternativeDocument (const TCollection_ExtendedString& aFormat, Handle(CDM_Document)& anAlternativeDocument);
0101   
0102   //! Creates a reference from this document to {anOtherDocument}.
0103   //! Returns a reference identifier. This reference identifier
0104   //! is unique in the document and will not be used for the
0105   //! next references, even after the storing of the document.
0106   //! If there is already a reference between the two documents,
0107   //! the reference is not created, but its reference identifier
0108   //! is returned.
0109   Standard_EXPORT Standard_Integer CreateReference (const Handle(CDM_Document)& anOtherDocument);
0110   
0111   //! Removes the reference between the From Document and the
0112   //! To Document identified by a reference identifier.
0113   Standard_EXPORT void RemoveReference (const Standard_Integer aReferenceIdentifier);
0114   
0115   //! Removes all references having this document for From Document.
0116   Standard_EXPORT void RemoveAllReferences();
0117   
0118   //! Returns the To Document  of the reference identified by
0119   //! aReferenceIdentifier. If the ToDocument is stored and
0120   //! has not yet been retrieved, this method will retrieve it.
0121   Standard_EXPORT Handle(CDM_Document) Document (const Standard_Integer aReferenceIdentifier) const;
0122   
0123   //! returns True if   the  To Document of the  reference
0124   //! identified by aReferenceIdentifier is in session,  False
0125   //! if it corresponds to a not yet retrieved document.
0126   Standard_EXPORT Standard_Boolean IsInSession (const Standard_Integer aReferenceIdentifier) const;
0127   
0128   //! returns True if   the  To Document of the  reference
0129   //! identified by aReferenceIdentifier has already been stored,
0130   //! False  otherwise.
0131   Standard_EXPORT Standard_Boolean IsStored (const Standard_Integer aReferenceIdentifier) const;
0132   
0133   //! returns the name of the metadata of the To Document of
0134   //! the reference identified by aReferenceIdentifier.
0135   Standard_EXPORT TCollection_ExtendedString Name (const Standard_Integer aReferenceIdentifier) const;
0136   
0137   //! call  virtual  method   Update  on  all   referencing
0138   //! documents.   This method keeps  the list  of the --
0139   //! documents  to process.It may  be the starting of an
0140   //! update -- cycle. If  not,  the reentrant calls made by
0141   //! Update  method (without argument)  will append the
0142   //! referencing documents to the list and call the Update method
0143   //! (with arguments). Only the first call to UpdateFromDocuments
0144   //! generate call to Update().
0145   Standard_EXPORT void UpdateFromDocuments (const Standard_Address aModifContext) const;
0146   
0147   //! returns the number of references having this document as
0148   //! From Document.
0149   Standard_EXPORT Standard_Integer ToReferencesNumber() const;
0150   
0151   //! returns the number of references having this document as
0152   //! To Document.
0153   Standard_EXPORT Standard_Integer FromReferencesNumber() const;
0154   
0155   //! returns True is this document references aDocument;
0156   Standard_EXPORT Standard_Boolean ShallowReferences (const Handle(CDM_Document)& aDocument) const;
0157   
0158   //! returns True is this document references aDocument;
0159   Standard_EXPORT Standard_Boolean DeepReferences (const Handle(CDM_Document)& aDocument) const;
0160   
0161   //! Copies a  reference  to  this document.   This  method
0162   //! avoid retrieval of referenced document.  The arguments
0163   //! are  the  original  document  and a  valid  reference
0164   //! identifier Returns the  local identifier.
0165   Standard_EXPORT Standard_Integer CopyReference (const Handle(CDM_Document)& aFromDocument, const Standard_Integer aReferenceIdentifier);
0166   
0167   //! indicates  that  this document cannot be   modified.
0168   Standard_EXPORT Standard_Boolean IsReadOnly() const;
0169   
0170   //! indicates that the referenced document cannot be modified,
0171   Standard_EXPORT Standard_Boolean IsReadOnly (const Standard_Integer aReferenceIdentifier) const;
0172   
0173   Standard_EXPORT void SetIsReadOnly();
0174   
0175   Standard_EXPORT void UnsetIsReadOnly();
0176   
0177   //! Indicates that this document has been modified.
0178   //! This method increments the modification counter.
0179   Standard_EXPORT void Modify();
0180   
0181   //! returns the current modification counter.
0182   Standard_EXPORT Standard_Integer Modifications() const;
0183   
0184   Standard_EXPORT void UnModify();
0185   
0186   //! returns true if the modification counter found in the given
0187   //! reference is equal to the actual modification counter of
0188   //! the To Document. This method is able to deal with a reference
0189   //! to a not retrieved document.
0190   Standard_EXPORT Standard_Boolean IsUpToDate (const Standard_Integer aReferenceIdentifier) const;
0191   
0192   //! Resets the modification counter in the given reference
0193   //! to the actual modification counter of its To Document.
0194   //! This method should be called after the application has updated
0195   //! this document.
0196   Standard_EXPORT void SetIsUpToDate (const Standard_Integer aReferenceIdentifier);
0197   
0198   //! associates a comment with this document.
0199   Standard_EXPORT void SetComment (const TCollection_ExtendedString& aComment);
0200   
0201   //! appends a comment into comments of this document.
0202   Standard_EXPORT void AddComment (const TCollection_ExtendedString& aComment);
0203   
0204   //! associates a comments with this document.
0205   Standard_EXPORT void SetComments (const TColStd_SequenceOfExtendedString& aComments);
0206   
0207   //! returns the associated comments through <aComments>.
0208   //! Returns empty sequence if no comments are associated.
0209   Standard_EXPORT void Comments (TColStd_SequenceOfExtendedString& aComments) const;
0210   
0211   //! Returns the first of associated comments.
0212   //! By default the comment is an empty string.
0213   Standard_EXPORT Standard_ExtString Comment() const;
0214   
0215   Standard_EXPORT Standard_Boolean IsStored() const;
0216   
0217   //! returns  the value of  the modification counter at the
0218   //! time of storage. By default returns 0.
0219   Standard_EXPORT Standard_Integer StorageVersion() const;
0220   
0221   //! associates database  information to  a document which
0222   //! has been stored.  The name of the  document is now the
0223   //! name which has beenused to store the data.
0224   Standard_EXPORT void SetMetaData (const Handle(CDM_MetaData)& aMetaData);
0225   
0226   Standard_EXPORT void UnsetIsStored();
0227   
0228   Standard_EXPORT Handle(CDM_MetaData) MetaData() const;
0229   
0230   Standard_EXPORT TCollection_ExtendedString Folder() const;
0231   
0232   //! defines the folder in which the object should be stored.
0233   Standard_EXPORT void SetRequestedFolder (const TCollection_ExtendedString& aFolder);
0234   
0235   Standard_EXPORT TCollection_ExtendedString RequestedFolder() const;
0236   
0237   Standard_EXPORT Standard_Boolean HasRequestedFolder() const;
0238   
0239   //! defines the name under which the object should be stored.
0240   Standard_EXPORT void SetRequestedName (const TCollection_ExtendedString& aName);
0241   
0242   //! Determines under which the document is going to be store.
0243   //! By default the name of the document will be used.
0244   //! If the document has no name its presentation will be used.
0245   Standard_EXPORT TCollection_ExtendedString RequestedName();
0246   
0247   Standard_EXPORT void SetRequestedPreviousVersion (const TCollection_ExtendedString& aPreviousVersion);
0248   
0249   Standard_EXPORT void UnsetRequestedPreviousVersion();
0250   
0251   Standard_EXPORT Standard_Boolean HasRequestedPreviousVersion() const;
0252   
0253   Standard_EXPORT TCollection_ExtendedString RequestedPreviousVersion() const;
0254   
0255   //! defines the Comment with  which the object should be stored.
0256   Standard_EXPORT void SetRequestedComment (const TCollection_ExtendedString& aComment);
0257   
0258   Standard_EXPORT TCollection_ExtendedString RequestedComment() const;
0259   
0260   //! read (or rereads) the following resource.
0261   Standard_EXPORT void LoadResources();
0262   
0263   Standard_EXPORT Standard_Boolean FindFileExtension();
0264   
0265   //! gets the Desktop.Domain.Application.`FileFormat`.FileExtension resource.
0266   Standard_EXPORT TCollection_ExtendedString FileExtension();
0267   
0268   Standard_EXPORT Standard_Boolean FindDescription();
0269   
0270   //! gets the `FileFormat`.Description resource.
0271   Standard_EXPORT TCollection_ExtendedString Description();
0272   
0273   //! returns  true  if the   version is greater  than   the
0274   //! storage version
0275   Standard_EXPORT Standard_Boolean IsModified() const;
0276   
0277   Standard_EXPORT Standard_OStream& Print (Standard_OStream& anOStream) const;
0278 Standard_OStream& operator << (Standard_OStream& anOStream);
0279   
0280   Standard_EXPORT Standard_Boolean IsOpened() const;
0281   
0282   Standard_EXPORT void Open (const Handle(CDM_Application)& anApplication);
0283   
0284   Standard_EXPORT CDM_CanCloseStatus CanClose() const;
0285   
0286   Standard_EXPORT void Close();
0287   
0288   Standard_EXPORT const Handle(CDM_Application)& Application() const;
0289   
0290   //! A  referenced  document  may  indicate   through  this
0291   //! virtual  method that it does  not allow the closing of
0292   //! aDocument  which  it references through  the reference
0293   //! aReferenceIdentifier. By default returns Standard_True.
0294   Standard_EXPORT virtual Standard_Boolean CanCloseReference (const Handle(CDM_Document)& aDocument, const Standard_Integer aReferenceIdentifier) const;
0295   
0296   //! A referenced document may update its internal
0297   //! data structure when {aDocument} which it references
0298   //! through the reference {aReferenceIdentifier} is being closed.
0299   //! By default this method does nothing.
0300   Standard_EXPORT virtual void CloseReference (const Handle(CDM_Document)& aDocument, const Standard_Integer aReferenceIdentifier);
0301   
0302   //! returns true if  the   document corresponding to  the
0303   //! given   reference has    been retrieved  and  opened.
0304   //! Otherwise returns false. This method does not retrieve
0305   //! the referenced document
0306   Standard_EXPORT Standard_Boolean IsOpened (const Standard_Integer aReferenceIdentifier) const;
0307   
0308   Standard_EXPORT void CreateReference (const Handle(CDM_MetaData)& aMetaData, const Standard_Integer aReferenceIdentifier, const Handle(CDM_Application)& anApplication, const Standard_Integer aToDocumentVersion, const Standard_Boolean UseStorageConfiguration);
0309   
0310   Standard_EXPORT Standard_Integer CreateReference (const Handle(CDM_MetaData)& aMetaData, const Handle(CDM_Application)& anApplication, const Standard_Integer aDocumentVersion, const Standard_Boolean UseStorageConfiguration);
0311   
0312   Standard_EXPORT Standard_Integer ReferenceCounter() const;
0313   
0314   //! the following method should be used instead:
0315   //!
0316   //! Update(me:mutable; ErrorString: out ExtendedString from TCollection)
0317   //! returns Boolean from Standard
0318   Standard_EXPORT virtual void Update();
0319 
0320   Standard_EXPORT Handle(CDM_Reference) Reference (const Standard_Integer aReferenceIdentifier) const;
0321 
0322   Standard_EXPORT void SetModifications (const Standard_Integer Modifications);
0323 
0324   Standard_EXPORT void SetReferenceCounter (const Standard_Integer aReferenceCounter);
0325 
0326   //! Dumps the content of me into the stream
0327   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0328 
0329 friend class CDM_Reference;
0330 friend class CDM_ReferenceIterator;
0331 friend class CDM_Application;
0332 
0333 
0334   DEFINE_STANDARD_RTTIEXT(CDM_Document,Standard_Transient)
0335 
0336 protected:
0337 
0338   
0339   Standard_EXPORT CDM_Document();
0340   
0341   Standard_EXPORT ~CDM_Document();
0342 
0343   Standard_Boolean myResourcesAreLoaded;
0344 
0345 private:
0346 
0347   
0348   //! the manager returned by  this method will be
0349   //! used to search for the following resource items.
0350   Standard_EXPORT Handle(Resource_Manager) StorageResource();
0351   
0352   Standard_EXPORT void AddToReference (const Handle(CDM_Reference)& aReference);
0353   
0354   Standard_EXPORT void AddFromReference (const Handle(CDM_Reference)& aReference);
0355   
0356   Standard_EXPORT void RemoveFromReference (const Standard_Integer aReferenceIdentifier);
0357 
0358 
0359   TColStd_SequenceOfExtendedString myComments;
0360   CDM_ListOfReferences myFromReferences;
0361   CDM_ListOfReferences myToReferences;
0362   Standard_Integer myVersion;
0363   Standard_Integer myActualReferenceIdentifier;
0364   Standard_Integer myStorageVersion;
0365   Handle(CDM_MetaData) myMetaData;
0366   TCollection_ExtendedString myRequestedComment;
0367   TCollection_ExtendedString myRequestedFolder;
0368   Standard_Boolean myRequestedFolderIsDefined;
0369   TCollection_ExtendedString myRequestedName;
0370   Standard_Boolean myRequestedNameIsDefined;
0371   Standard_Boolean myRequestedPreviousVersionIsDefined;
0372   TCollection_ExtendedString myRequestedPreviousVersion;
0373   TCollection_ExtendedString myFileExtension;
0374   TCollection_ExtendedString myDescription;
0375   Standard_Boolean myFileExtensionWasFound;
0376   Standard_Boolean myDescriptionWasFound;
0377   Handle(CDM_Application) myApplication;
0378 };
0379 
0380 
0381 
0382 
0383 
0384 
0385 
0386 #endif // _CDM_Document_HeaderFile