0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BinMDataStd / BinMDataStd.hxx
1 // Created on: 2002-10-30
2 // Created by: Michael SAZONOV
3 // Copyright (c) 2002-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _BinMDataStd_HeaderFile
17 #define _BinMDataStd_HeaderFile
18
19 #include <Standard_GUID.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <Standard_Integer.hxx>
24 #include <BinObjMgt_Persistent.hxx>
25
26 class BinMDF_ADriverTable;
27 class Message_Messenger;
28
29 //! Storage and Retrieval drivers for modelling attributes.
30 class BinMDataStd 
31 {
32 public:
33
34   DEFINE_STANDARD_ALLOC
35
36   
37   //! Adds the attribute drivers to <theDriverTable>.
38   Standard_EXPORT static void AddDrivers (const Handle(BinMDF_ADriverTable)& theDriverTable, const Handle(Message_Messenger)& aMsgDrv);
39
40 template<class T>
41 static void SetAttributeID(const BinObjMgt_Persistent& theSource, const Handle(T)& anAtt, const Standard_Integer aDocFormatVersion)
42 {
43   Standard_Boolean ok = Standard_True;
44   if(aDocFormatVersion > 9) { // process user defined guid
45     const Standard_Integer& aPos = theSource.Position();
46     Standard_GUID aGuid;
47     ok = theSource >> aGuid;
48     if (!ok) {
49       theSource.SetPosition(aPos);
50       anAtt->SetID(T::GetID());
51       ok = Standard_True;
52     } else {
53       anAtt->SetID(aGuid);
54     }
55   } else
56     anAtt->SetID(T::GetID());
57 }
58
59
60 protected:
61
62
63
64
65
66 private:
67
68
69
70
71 friend class BinMDataStd_NameDriver;
72 friend class BinMDataStd_IntegerDriver;
73 friend class BinMDataStd_RealDriver;
74 friend class BinMDataStd_IntegerArrayDriver;
75 friend class BinMDataStd_RealArrayDriver;
76 friend class BinMDataStd_UAttributeDriver;
77 friend class BinMDataStd_DirectoryDriver;
78 friend class BinMDataStd_CommentDriver;
79 friend class BinMDataStd_VariableDriver;
80 friend class BinMDataStd_ExpressionDriver;
81 friend class BinMDataStd_RelationDriver;
82 friend class BinMDataStd_NoteBookDriver;
83 friend class BinMDataStd_TreeNodeDriver;
84 friend class BinMDataStd_ExtStringArrayDriver;
85 friend class BinMDataStd_TickDriver;
86 friend class BinMDataStd_AsciiStringDriver;
87 friend class BinMDataStd_IntPackedMapDriver;
88 friend class BinMDataStd_IntegerListDriver;
89 friend class BinMDataStd_RealListDriver;
90 friend class BinMDataStd_ExtStringListDriver;
91 friend class BinMDataStd_BooleanListDriver;
92 friend class BinMDataStd_ReferenceListDriver;
93 friend class BinMDataStd_BooleanArrayDriver;
94 friend class BinMDataStd_ReferenceArrayDriver;
95 friend class BinMDataStd_ByteArrayDriver;
96 friend class BinMDataStd_NamedDataDriver;
97
98 };
99
100
101
102
103
104
105
106 #endif // _BinMDataStd_HeaderFile