///////////////////////////////////////////////////////////////////////////////
// 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_ATTRIBUTE_H_
#define _DAI_EXPLICIT_ATTRIBUTE_H_
#include "daiAttribute.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 Entity;
class ExplicitAttribute;
/** \details
A data type that represents a smart pointer to an object.
*/
typedef OdSmartPtr ExplicitAttributePtr;
/** \details
A class that implements the functionality for storing and manipulating of attributes.
*/
class DAI_EXPORT ExplicitAttribute : public Attribute
{
public:
//DOM-IGNORE-BEGIN
ODRX_DECLARE_MEMBERS(ExplicitAttribute);
//DOM-IGNORE-END
/** \details
Creates a new explicit attribute definition for an entity with a specified name.
\param name [in] A pointer to a null-terminated string that the contains the attribute name.
\param parentEntity [in] A pointer to an entity definition that contains the attribute.
\param domain [in] A pointer to the data type definition referenced by the attribute.
\param optional [in] A flag that determines whether the value of the created attribute is optional (equal to true) or mandatory (equal to false).
\returns A smart pointer to the created instance.
*/
static OdSmartPtr createObject(
const char *name,
Entity *parentEntity,
DictionaryInstance *domain = NULL,
// redeclaring
bool optional = false);
/** \details
Creates a new attribute object with default parameters.
The value of the created attribute is mandatory by default.
*/
ExplicitAttribute()
: m_optional(false)
{};
/** \details
Retrieves the data type referenced by the attribute.
\returns A smart pointer to the data type.
*/
const BaseTypePtr domain() const { return m_domain; };
/** \details
Determines whether the attribute is optional.
\returns true if the attribute is optional; otherwise, the method returns false.
*/
bool optional() const { return m_optional; };
/** \details
Retrieves definition of redeclared explicit attribute.
\returns Returns a smart pointer to the container with definition of redeclared explicit attribute.
*/
const ExplicitAttributePtr redeclaring() const { return m_redeclaring; };
/** \details
Retrieves the current value of an attribute specified by its name.
\param attrName [in] An ANSI string that contains the attribute name.
\returns An OdRxValue object that contains the current value of the attribute.
\remarks
The method provides the late binding access to the attribute value by its name.
Attributes of select and aggregate data types are also supported.
*/
virtual OdRxValue getAttr(const char * attrName) const ODRX_OVERRIDE;
/** \details
Retrieves the current attribute's type.
\returns An value that contains the attribute's type.
*/
AttributeType getAttributeType() const override
{
return AttributeType::Explicit;
}
/** \details
Retrieves an array of entity definitions, which attributes re-declare the explicit attribute.
\returns An array of raw pointers to objects.
*/
const OdArray& redeclaredIn() const { return m_redeclaredIn; };
/** \details
Determines if the attribute is re-declared by a derived attribute of a specified entity.
\param entity [in] A raw pointer to the .
\returns true if the attribute is re-declared by a derived attribute of the specified entity; otherwise, the method returns false.
*/
bool isRedeclaredIn(const OdDAI::Entity *entity) const;
//DOM-IGNORE-BEGIN
protected:
bool m_optional;
BaseTypePtr m_domain;
ExplicitAttributePtr m_redeclaring;
OdArray m_redeclaredIn;
void setDomain(const BaseTypePtr &domain) { m_domain = domain; }
void setOptional(bool optional) { m_optional = optional; };
void setRedeclaring(const ExplicitAttribute *redeclared);
friend class SchemaFiller;
//DOM-IGNORE-END
};
}
#include "TD_PackPop.h"
#endif // _DAI_EXPLICIT_ATTRIBUTE_H_