Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-20 09:19:22

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 occ::handle<TDF_Attribute> NewEmpty() const override;
0028 
0029 //! @def IMPLEMENT_DERIVED_ATTRIBUTE
0030 //! Defines implementation of Handle method, serialization methods and registers the derived
0031 //! attribute
0032 #define IMPLEMENT_DERIVED_ATTRIBUTE(Class, Base)                                                   \
0033   IMPLEMENT_STANDARD_RTTIEXT(Class, Base)                                                          \
0034   static occ::handle<TDF_Attribute> TDF_DERIVED_New##Class()                                       \
0035   {                                                                                                \
0036     return new Class();                                                                            \
0037   }                                                                                                \
0038   static TDF_DerivedAttribute::NewDerived TDF_DERIVED_##Class(                                     \
0039     TDF_DerivedAttribute::Register(TDF_DERIVED_New##Class));                                       \
0040   occ::handle<TDF_Attribute> Class::NewEmpty() const                                               \
0041   {                                                                                                \
0042     return TDF_DERIVED_##Class();                                                                  \
0043   }
0044 
0045 //! @def IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE
0046 //! Defines implementation of Handle method and registers the derived attribute
0047 #define IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(Class, Base, NameSpace, TypeName)                    \
0048   IMPLEMENT_STANDARD_RTTIEXT(Class, Base)                                                          \
0049   static occ::handle<TDF_Attribute> TDF_DERIVED_New##Class()                                       \
0050   {                                                                                                \
0051     return new Class();                                                                            \
0052   }                                                                                                \
0053   static TDF_DerivedAttribute::NewDerived TDF_DERIVED_##Class(                                     \
0054     TDF_DerivedAttribute::Register(TDF_DERIVED_New##Class, NameSpace, TypeName));                  \
0055   occ::handle<TDF_Attribute> Class::NewEmpty() const                                               \
0056   {                                                                                                \
0057     return TDF_DERIVED_##Class();                                                                  \
0058   }
0059 
0060 //! Class provides global access (through static methods) to all derived attributes information.
0061 //! It is used internally by macros for registration of derived attributes and driver-tables
0062 //! for getting this data.
0063 class TDF_DerivedAttribute
0064 {
0065 public:
0066   /// A function of derived attribute that returns a new attribute instance
0067   typedef occ::handle<TDF_Attribute> (*NewDerived)();
0068 
0069   //! Registers a derived by the pointer to a method that creates a new derived attribute instance
0070   Standard_EXPORT static NewDerived Register(NewDerived  theNewAttributeFunction,
0071                                              const char* theNameSpace = nullptr,
0072                                              const char* theTypeName  = nullptr);
0073 
0074   //! Returns the derived registered attribute by its type.
0075   Standard_EXPORT static occ::handle<TDF_Attribute> Attribute(const char* theType);
0076 
0077   //! Returns the type name of the registered attribute by its type.
0078   Standard_EXPORT static const TCollection_AsciiString& TypeName(const char* theType);
0079 
0080   //! Returns all the derived registered attributes list.
0081   Standard_EXPORT static void Attributes(NCollection_List<occ::handle<TDF_Attribute>>& theList);
0082 };
0083 
0084 #endif // _TDF_DerivedAttribute_HeaderFile