Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:20

0001 // Copyright (c) 2020 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _TDF_DerivedAttribute_HeaderFile
0015 #define _TDF_DerivedAttribute_HeaderFile
0016 
0017 #include <NCollection_List.hxx>
0018 #include <TDF_Attribute.hxx>
0019 
0020 class TCollection_AsciiString;
0021 
0022 //! @def DEFINE_DERIVED_ATTRIBUTE
0023 //! Defines declaration of Handle method and declares methods for serialization
0024 //! of derived attribute
0025 #define DEFINE_DERIVED_ATTRIBUTE(Class, Base) \
0026   DEFINE_STANDARD_RTTIEXT(Class, Base); \
0027   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
0028 
0029 //! @def IMPLEMENT_DERIVED_ATTRIBUTE
0030 //! Defines implementation of Handle method, serialization methods and registers the derived attribute
0031 #define IMPLEMENT_DERIVED_ATTRIBUTE(Class, Base) \
0032   IMPLEMENT_STANDARD_RTTIEXT(Class, Base) \
0033   static Handle(TDF_Attribute) TDF_DERIVED_New##Class() { return new Class(); } \
0034   static TDF_DerivedAttribute::NewDerived TDF_DERIVED_##Class( \
0035     TDF_DerivedAttribute::Register(TDF_DERIVED_New##Class)); \
0036   Handle(TDF_Attribute) Class::NewEmpty() const { return TDF_DERIVED_##Class(); } \
0037 
0038 
0039 //! @def IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE
0040 //! Defines implementation of Handle method and registers the derived attribute
0041 #define IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(Class, Base, NameSpace, TypeName) \
0042   IMPLEMENT_STANDARD_RTTIEXT(Class, Base) \
0043   static Handle(TDF_Attribute) TDF_DERIVED_New##Class() { return new Class(); } \
0044   static TDF_DerivedAttribute::NewDerived TDF_DERIVED_##Class( \
0045     TDF_DerivedAttribute::Register(TDF_DERIVED_New##Class, NameSpace, TypeName)); \
0046   Handle(TDF_Attribute) Class::NewEmpty() const { return TDF_DERIVED_##Class(); } \
0047 
0048 //! Class provides global access (through static methods) to all derived attributres information.
0049 //! It is used internally by macros for registration of derived attributes and driver-tables
0050 //! for getting this data.
0051 class TDF_DerivedAttribute
0052 {
0053 public:
0054   /// A function of derived attribute that returns a new attribute instance
0055   typedef Handle(TDF_Attribute) (*NewDerived) ();
0056 
0057   //! Registers a derived by the pointer to a method that creates a new derived attribute instance
0058   Standard_EXPORT static NewDerived Register (NewDerived       theNewAttributeFunction,
0059                                               Standard_CString theNameSpace = NULL,
0060                                               Standard_CString theTypeName  = NULL);
0061 
0062   //! Returns the derived registered attribute by its type.
0063   Standard_EXPORT static Handle(TDF_Attribute) Attribute (Standard_CString theType);
0064 
0065   //! Returns the type name of the registered attribute by its type.
0066   Standard_EXPORT static const TCollection_AsciiString& TypeName (Standard_CString theType);
0067 
0068   //! Returns all the derived registered attributes list.
0069   Standard_EXPORT static void Attributes (NCollection_List<Handle(TDF_Attribute)>& theList);
0070 
0071 };
0072 
0073 #endif // _TDF_DerivedAttribute_HeaderFile