0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / StdPersistent / StdPersistent_Naming.hxx
1 // Copyright (c) 2015 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
15 #ifndef _StdPersistent_Naming_HeaderFile
16 #define _StdPersistent_Naming_HeaderFile
17
18 #include <StdObjMgt_Attribute.hxx>
19 #include <StdObjMgt_Persistent.hxx>
20 #include <StdPersistent_HArray1.hxx>
21 #include <StdLPersistent_HArray1.hxx>
22 #include <StdLPersistent_HString.hxx>
23
24 #include <TNaming_NamedShape.hxx>
25 #include <TNaming_Naming.hxx>
26
27 class TNaming_Name;
28
29
30 class StdPersistent_Naming
31 {
32 public:
33   class NamedShape : public StdObjMgt_Attribute<TNaming_NamedShape>
34   {
35   public:
36     //! Read persistent data from a file.
37     inline void Read (StdObjMgt_ReadData& theReadData)
38       { theReadData >> myOldShapes >> myNewShapes >> myShapeStatus >> myVersion; }
39     //! Read persistent data from a file.
40     inline void Write (StdObjMgt_WriteData& theWriteData) const
41       { theWriteData << myOldShapes << myNewShapes << myShapeStatus << myVersion; }
42     //! Gets persistent child objects
43     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
44     {
45       if (!myOldShapes.IsNull()) theChildren.Append(myOldShapes);
46       if (!myNewShapes.IsNull()) theChildren.Append(myNewShapes);
47     }
48     //! Returns persistent type name
49     inline Standard_CString PName() const { return "PNaming_NamedShape"; }
50
51     //! Import transient attribuite from the persistent data.
52     void Import (const Handle(TNaming_NamedShape)& theAttribute) const;
53
54   private:
55     Handle(StdPersistent_HArray1::Shape1) myOldShapes;
56     Handle(StdPersistent_HArray1::Shape1) myNewShapes;
57     Standard_Integer                      myShapeStatus;
58     Standard_Integer                      myVersion;
59   };
60
61   class Name : public StdObjMgt_Persistent
62   {
63   public:
64     //! Read persistent data from a file.
65     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
66     //! Read persistent data from a file.
67     Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
68     //! Gets persistent child objects
69     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
70     {
71       if (!myArgs.IsNull()) theChildren.Append(myArgs);
72       if (!myStop.IsNull()) theChildren.Append(myStop);
73     }
74     //! Returns persistent type name
75     inline Standard_CString PName() const { return "PNaming_Name"; }
76
77     //! Import transient object from the persistent data.
78     Standard_EXPORT virtual void Import
79       (TNaming_Name& theName, const Handle(TDF_Data)& theDF) const;
80
81   private:
82     Standard_Integer                           myType;
83     Standard_Integer                           myShapeType;
84     Handle(StdLPersistent_HArray1::Persistent) myArgs;
85     Handle(StdObjMgt_Persistent)               myStop;
86     Standard_Integer                           myIndex;
87   };
88
89   class Name_1 : public Name
90   {
91   public:
92     //! Read persistent data from a file.
93     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
94     //! Read persistent data from a file.
95     Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
96     //! Gets persistent child objects
97     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
98     {
99       Name::PChildren(theChildren);
100       if (!myContextLabel.IsNull()) theChildren.Append(myContextLabel);
101     }
102     //! Returns persistent type name
103     inline Standard_CString PName() const { return "PNaming_Name_1"; }
104
105     //! Import transient object from the persistent data.
106     Standard_EXPORT virtual void Import
107       (TNaming_Name& theName, const Handle(TDF_Data)& theDF) const;
108
109   private:
110     Handle(StdLPersistent_HString::Ascii) myContextLabel;
111   };
112
113   class Name_2 : public Name_1
114   {
115   public:
116     //! Read persistent data from a file.
117     Standard_EXPORT virtual void Read (StdObjMgt_ReadData& theReadData);
118     //! Read persistent data from a file.
119     Standard_EXPORT virtual void Write (StdObjMgt_WriteData& theWriteData) const;
120     //! Gets persistent child objects
121     inline void PChildren(StdObjMgt_Persistent::SequenceOfPersistent& theChildren) const
122       { Name_1::PChildren(theChildren); }
123     //! Returns persistent type name
124     inline Standard_CString PName() const { return "PNaming_Name_2"; }
125
126     //! Import transient object from the persistent data.
127     Standard_EXPORT virtual void Import
128       (TNaming_Name& theName, const Handle(TDF_Data)& theDF) const;
129
130   private:
131     Standard_Integer myOrientation;
132   };
133
134   class Naming : public StdObjMgt_Attribute<TNaming_Naming>::SingleRef
135   {
136   public:
137     //! Import transient attribuite from the persistent data.
138     Standard_EXPORT virtual void ImportAttribute();
139   };
140
141   class Naming_1 : public Naming
142   {
143   public:
144     //! Import transient attribuite from the persistent data.
145     Standard_EXPORT virtual void ImportAttribute();
146   };
147
148   typedef Naming Naming_2;
149 };
150
151 #endif