/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _DAI_EXPLICIT_OR_DERIVED_H #define _DAI_EXPLICIT_OR_DERIVED_H #include "daiDictionaryInstance.h" #include "daiBaseType.h" #include "TD_PackPush.h" /** \details Implements the Data Access Interface (DAI) that provides functionality for manipulating data that is defined within the EXPRESS SCHEMA format. */ namespace OdDAI { class ExplicitAttribute; class DerivedAttribute; /** \details Container for selection between Explicit Attribute or Derived Attribute. */ class DAI_EXPORT ExplicitOrDerived : public DictionaryInstance { public: ODRX_DECLARE_MEMBERS(ExplicitOrDerived); typedef enum { kUnset = 0, // Unset kExplicitAttribute = 1, // Explicit attribute kDerivedAttribute = 2 // Derived attribute } OdExplicitOrDerivedKind; /** \details Creates a new ExplicitOrDerived object from the specified ExplicitAttribute object. \param explicitAttribute [in] Pointer to ExplicitAttribute object to create from. \returns A smart pointer to the created object. */ static OdSmartPtr createObject(ExplicitAttribute *explicitAttribute); /** \details Creates a new ExplicitOrDerived object from the specified DerivedAttribute object. \param derivedAttribute [in] Pointer to DerivedAttribute object to create from. \returns A smart pointer to the created object. */ static OdSmartPtr createObject(DerivedAttribute *derivedAttribute); /** \details Default constructor for the ExplicitOrDerived class. */ ExplicitOrDerived() : m_kind(kUnset) {}; /** \details Checks whether an explicit or derived attribute exists within this object. \returns 0 if attribute is unset; otherwise the method returns 1. */ int exists() const { return m_kind == kUnset ? 0 : 1; }; /** \details Unsets the type of an attribute associated with this object. */ void unset() { m_kind = kUnset; }; /** \details Gets kind of an attribute in this container. \returns a value from OdExplicitOrDerivedKind enumeration representing kind of the attribute. */ OdExplicitOrDerivedKind kind() const { return m_kind; }; /** \details Checks whether this container contains an explicit attribute. \returns true if kind of the contained attribute is kExplicitAttribute; otherwise the method returns false; */ bool isExplicitAttribute() const { return m_kind == kExplicitAttribute; }; /** \details Sets an explicit attribute for this container. \param explicitAttribute [in] Explicit attribute to set. */ void setExplicitAttribute(ExplicitAttribute *explicitAttribute); /** \details Gets an explicit attribute for this container. \returns pointer to an explicit attribute or NULL if declared or real kind of contained attribute is not explicit. */ const ExplicitAttribute* explicitAttribute() const; /** \details Checks whether this container contains a derived attribute. \returns true if kind of the contained attribute is kDerivedAttribute; otherwise the method returns false; */ bool isDerivedAttribute() const { return m_kind == kDerivedAttribute; }; /** \details Sets a derived attribute for this container. \param derivedAttribute [in] Derived attribute to set. */ void setDerivedAttribute(DerivedAttribute *derivedAttribute); /** \details Gets a derived attribute for this container. \returns pointer to a derived attribute or NULL if declared or real kind of contained attribute is not derived. */ const DerivedAttribute* derivedAttribute() const; /** \details Retrieves the data type referenced by the attribute. \returns A smart pointer to the data type. */ const BaseTypePtr domain() const; /** \details Checks whether the attribute is optional. \returns true if the attribute is optional; otherwise, the method returns false. */ bool optional() const; private: OdExplicitOrDerivedKind m_kind; AttributePtr m_pAttribute; friend class Schema; }; /** \details A data type that represents a smart pointer to a object. */ typedef OdSmartPtr ExplicitOrDerivedPtr; } #include "TD_PackPop.h" #endif // _DAI_EXPLICIT_OR_DERIVED_H