1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEDS_GenericAttribute_i.hxx
25 // Author : Yves FRICAUD
29 #ifndef _GENERIC_ATTRIBUTE_I_HXX_
30 #define _GENERIC_ATTRIBUTE_I_HXX_
32 #include <TDF_Attribute.hxx>
33 #include <Standard_GUID.hxx>
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(SALOMEDS)
39 class SALOMEDS_SObject_i;
41 class SALOMEDS_GenericAttribute_i:
42 public virtual POA_SALOMEDS::GenericAttribute,
43 public virtual PortableServer::RefCountServantBase
46 friend class SALOMEDS_SObject_i;
48 SALOMEDS_GenericAttribute_i(); // Not implemented
49 void operator=(const SALOMEDS_GenericAttribute_i&); //Not implemented
52 SALOMEDS_SObject_i* _mySObject;
53 Handle(TDF_Attribute) _myBasicAttr;
55 SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
56 SALOMEDS_SObject_i* theSObject);
58 virtual ~SALOMEDS_GenericAttribute_i();
60 void SetBasicAttribute(const Handle(TDF_Attribute)& theAttr){
61 _myBasicAttr = theAttr;
65 void Restore(const char*);
71 SALOMEDS::SObject_ptr GetSObject();
74 throw (SALOMEDS::GenericAttribute::LockProtection);
76 virtual void SetAttribute(const Handle(TDF_Attribute)& theAttr) = 0;
78 virtual const Handle(TDF_Attribute)& GetAttribute() const = 0;
83 template<class TDFAttribute, class TStoreTDFAttribute, bool TIsCheckLockedStudy = true>
84 class SALOMEDS_TGenericAttribute_i:
85 public virtual SALOMEDS_GenericAttribute_i
88 typedef TDFAttribute TAttr;
89 typedef TStoreTDFAttribute TStoreAttr;
91 virtual void SetAttribute(const Handle(TDF_Attribute)& theAttr){
92 _myAttr = TStoreAttr::DownCast(theAttr);
93 SetBasicAttribute(theAttr);
95 virtual const Handle(TDF_Attribute)& GetAttribute() const{
98 static bool IsCheckLockedStudy(){
99 return TIsCheckLockedStudy;
101 static Handle(TDF_Attribute) NewAttribute(){
108 SALOMEDS_TGenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
109 SALOMEDS_SObject_i* theSObject):
110 SALOMEDS_GenericAttribute_i(theAttr,theSObject),
111 _myAttr(TStoreAttr::DownCast(theAttr))
116 friend class SALOMEDS_SObject_i;
118 SALOMEDS_TGenericAttribute_i(); //Not implemented
119 void operator=(const SALOMEDS_TGenericAttribute_i&); //Not implemented
124 #define DEFINE_DERIVED_ATTR(TName,TAttr,TCheck) \
125 typedef SALOMEDS_TGenericAttribute_i<TAttr,Handle_##TAttr,TCheck> \
126 SALOMEDS_T##TName##_i
129 #define DEFINE_DERIVED_ATTR_METH_BASE(TName) \
131 friend class SALOMEDS_SObject_i; \
132 static SALOMEDS_GenericAttribute_i* \
133 NewInstance(const Handle(TDF_Attribute)& theAttr, \
134 SALOMEDS_SObject_i* theSObject) \
135 { return new SALOMEDS_##TName##_i(theAttr,theSObject);} \
137 SALOMEDS_##TName##_i(const Handle(TDF_Attribute)& theAttr, \
138 SALOMEDS_SObject_i* theSObject): \
139 SALOMEDS_GenericAttribute_i(theAttr,theSObject), \
140 SALOMEDS_T##TName##_i(theAttr,theSObject) \
142 void operator=(const SALOMEDS_##TName##_i&); \
143 SALOMEDS_##TName##_i()
146 #define DEFINE_DERIVED_ATTR_METH_DEFAULT(TName,TAttr) \
147 DEFINE_DERIVED_ATTR_METH_BASE(TName); \
149 static Standard_GUID GetGUID(){ return TAttr::GetID(); } \
153 #define DEFINE_DERIVED_ATTR_METH(TName,theGUID) \
154 DEFINE_DERIVED_ATTR_METH_BASE(TName); \
156 static Standard_GUID GetGUID(){ return theGUID; } \