0029902: Data Exchange, XCAF - provide extended Material definition for visualization...
[occt.git] / src / XCAFDoc / XCAFDoc_NoteBinData.hxx
1 // Copyright (c) 2017-2018 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _XCAFDoc_NoteBinData_HeaderFile
15 #define _XCAFDoc_NoteBinData_HeaderFile
16
17 #include <XCAFDoc_Note.hxx>
18 #include <TColStd_HArray1OfByte.hxx>
19 #include <TCollection_AsciiString.hxx>
20 #include <TCollection_ExtendedString.hxx>
21
22 class OSD_File;
23
24 class XCAFDoc_NoteBinData : public XCAFDoc_Note
25 {
26 public:
27
28   DEFINE_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note)
29
30   //! Returns default attribute GUID
31   Standard_EXPORT static const Standard_GUID& GetID();
32
33   //! Finds a binary data attribute on the given label and returns it, if it is found
34   Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Get(const TDF_Label& theLabel);
35
36   //! @name Set attribute functions.
37   //! @{
38
39   //! Create (if not exist) a binary note with data loaded from a binary file.
40   //! \param [in] theLabel     - label to add the attribute.
41   //! \param [in] theUserName  - the name of the user, who created the note.
42   //! \param [in] theTimeStamp - creation timestamp of the note.
43   //! \param [in] theTitle     - file title.
44   //! \param [in] theMIMEtype  - MIME type of the file.
45   //! \param [in] theFile      - input binary file.
46   //! \return A handle to the attribute instance.
47   Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                  theLabel,
48                                                          const TCollection_ExtendedString& theUserName,
49                                                          const TCollection_ExtendedString& theTimeStamp,
50                                                          const TCollection_ExtendedString& theTitle,
51                                                          const TCollection_AsciiString&    theMIMEtype,
52                                                          OSD_File&                         theFile);
53
54   //! Create (if not exist) a binary note byte data array.
55   //! \param [in] theLabel     - label to add the attribute.
56   //! \param [in] theUserName  - the name of the user, who created the note.
57   //! \param [in] theTimeStamp - creation timestamp of the note.
58   //! \param [in] theTitle     - data title.
59   //! \param [in] theMIMEtype  - MIME type of data.
60   //! \param [in] theData      - byte data array.
61   //! \return A handle to the attribute instance.
62   Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label&                     theLabel,
63                                                          const TCollection_ExtendedString&    theUserName,
64                                                          const TCollection_ExtendedString&    theTimeStamp,
65                                                          const TCollection_ExtendedString&    theTitle,
66                                                          const TCollection_AsciiString&       theMIMEtype,
67                                                          const Handle(TColStd_HArray1OfByte)& theData);
68
69   //! @}
70
71   //! Creates an empty binary data note.
72   Standard_EXPORT XCAFDoc_NoteBinData();
73
74   //! @name Set attribute data functions.
75   //! @{
76
77   //! Sets title, MIME type and data from a binary file.
78   //! \param [in] theTitle     - file title.
79   //! \param [in] theMIMEtype  - MIME type of the file.
80   //! \param [in] theFile      - input binary file.
81   Standard_EXPORT Standard_Boolean Set(const TCollection_ExtendedString& theTitle,
82                                        const TCollection_AsciiString&    theMIMEtype,
83                                        OSD_File&                         theFile);
84
85   //! Sets title, MIME type and data from a byte array.
86   //! \param [in] theTitle     - data title.
87   //! \param [in] theMIMEtype  - MIME type of data.
88   //! \param [in] theData      - byte data array.
89   Standard_EXPORT void Set(const TCollection_ExtendedString&    theTitle,
90                            const TCollection_AsciiString&       theMIMEtype,
91                            const Handle(TColStd_HArray1OfByte)& theData);
92
93   //! @}
94
95   //! Returns the note title.
96   const TCollection_ExtendedString& Title() const { return myTitle; }
97
98   //! Returns data MIME type.
99   const TCollection_AsciiString& MIMEtype() const { return myMIMEtype;  }
100
101   //! Size of data in bytes.
102   Standard_Integer Size() const { return (!myData.IsNull() ? myData->Length() : 0); }
103
104   //! Returns byte data array.
105   const Handle(TColStd_HArray1OfByte)& Data() const { return myData; }
106
107 public:
108
109   // Overrides TDF_Attribute virtuals
110   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
111   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
112   Standard_EXPORT void Restore(const Handle(TDF_Attribute)& theAttrFrom) Standard_OVERRIDE;
113   Standard_EXPORT void Paste(const Handle(TDF_Attribute)&       theAttrInto,
114                              const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
115   Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE;
116
117 protected:
118
119   TCollection_ExtendedString    myTitle;    ///< Note title.
120   TCollection_AsciiString       myMIMEtype; ///< MIME type of data.
121   Handle(TColStd_HArray1OfByte) myData;     ///< Byte data array.
122
123 };
124
125 DEFINE_STANDARD_HANDLE(XCAFDoc_NoteBinData, XCAFDoc_Note)
126
127 #endif // _XCAFDoc_NoteBinData_HeaderFile