1 // Copyright (c) 2015 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 _StdObjMgt_ContentTypes_HeaderFile
15 #define _StdObjMgt_ContentTypes_HeaderFile
18 #include <StdObjMgt_ReadData.hxx>
20 class StdObjMgt_Persistent;
23 //! Root class for an object containing other obects.
24 class StdObjMgt_ContentTypes
26 template <typename Type>
31 operator Type() const { return myValue; }
37 template <typename Type>
38 struct enum_ : holder<Type>
40 //! Read the value from a file.
41 void Read (StdObjMgt_ReadData& theReadData)
42 { theReadData.ReadEnum (this->myValue); }
45 template <typename Type>
46 struct value : holder<Type>
48 //! Read the value from a file.
49 void Read (StdObjMgt_ReadData& theReadData)
50 { theReadData.ReadValue (this->myValue); }
53 template <class Class>
56 //! Read object data from a file.
57 void Read (StdObjMgt_ReadData& theReadData)
58 { theReadData.ReadObject ((Class&)*this); }
61 template <class Persistent>
62 struct referenceT : Handle(Persistent)
64 //! Read object data from a file.
65 void Read (StdObjMgt_ReadData& theReadData)
66 { theReadData.ReadReference (*this); }
69 struct reference : Handle(StdObjMgt_Persistent)
71 //! Read object data from a file.
72 void Read (StdObjMgt_ReadData& theReadData)
73 { Handle(StdObjMgt_Persistent)::operator= (theReadData.ReadReference()); }
75 //! Cast the reference to a target type.
76 template <class Persistent>
77 bool Cast (Handle(Persistent)& theTarget) const
79 theTarget = Handle(Persistent)::DownCast(*this);
80 return ! theTarget.IsNull();
86 struct Enum : StdObjMgt_ReadData::Content <enum_<Type> > {};
89 struct Value : StdObjMgt_ReadData::Content <value<Type> > {};
91 template <class Class>
92 struct Object : StdObjMgt_ReadData::Content <object<Class> > {};
94 template <class Persistent = StdObjMgt_Persistent>
95 struct Reference : StdObjMgt_ReadData::Content <referenceT<Persistent> > {};
99 struct StdObjMgt_ContentTypes::Reference<StdObjMgt_Persistent>
100 : StdObjMgt_ReadData::Content <reference> {};
102 #endif // _StdObjMgt_ContentTypes_HeaderFile