1 // Copyright (c) 2017-2018 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _XCAFDoc_Note_HeaderFile
15 #define _XCAFDoc_Note_HeaderFile
17 #include <Standard.hxx>
18 #include <TCollection_ExtendedString.hxx>
19 #include <TDF_DerivedAttribute.hxx>
20 #include <TDF_LabelSequence.hxx>
21 #include <XCAFNoteObjects_NoteObject.hxx>
23 class TDF_RelocationTable;
25 //! A base note attribute.
26 //! Any note contains the name of the user created the note
27 //! and the creation timestamp.
28 class XCAFDoc_Note : public TDF_Attribute
32 DEFINE_STANDARD_RTTIEXT(XCAFDoc_Note, TDF_Attribute)
34 //! Checks if the given label represents a note.
35 Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel);
37 //! Finds a reference attribute on the given label and returns it, if it is found
38 Standard_EXPORT static Handle(XCAFDoc_Note) Get(const TDF_Label& theLabel);
40 //! Sets the user name and the timestamp of the note.
41 //! \param [in] theUserName - the user associated with the note.
42 //! \param [in] theTimeStamp - timestamp of the note.
43 //! \return A handle to the attribute instance.
44 Standard_EXPORT void Set(const TCollection_ExtendedString& theUserName,
45 const TCollection_ExtendedString& theTimeStamp);
47 //! Returns the user name, who created the note.
48 const TCollection_ExtendedString& UserName() const { return myUserName; }
50 //! Returns the timestamp of the note.
51 const TCollection_ExtendedString& TimeStamp() const { return myTimeStamp; }
53 //! Checks if the note isn't linked to annotated items.
54 Standard_EXPORT Standard_Boolean IsOrphan() const;
56 //! Returns auxiliary data object
57 Standard_EXPORT Handle(XCAFNoteObjects_NoteObject) GetObject() const;
59 //! Updates auxiliary data
60 Standard_EXPORT void SetObject(const Handle(XCAFNoteObjects_NoteObject)& theObject);
64 // Overrides TDF_Attribute virtuals
65 Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
66 Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theAttrInto,
67 const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
68 Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
70 //! Dumps the content of me into the stream
71 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
75 //! Creates an empty note.
76 Standard_EXPORT XCAFDoc_Note();
80 TCollection_ExtendedString myUserName; ///< Name of the user, who created the note.
81 TCollection_ExtendedString myTimeStamp; ///< Timestamp, when the note was created.
84 DEFINE_STANDARD_HANDLE(XCAFDoc_Note, TDF_Attribute)
86 #endif // _XCAFDoc_Note_HeaderFile