///////////////////////////////////////////////////////////////////////////////
// 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.
///////////////////////////////////////////////////////////////////////////////
#if !defined(ODA_ODMVDXMLATTRIBUTERULE_H_INCLUDED_)
#define ODA_ODMVDXMLATTRIBUTERULE_H_INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "IfcEntity.h"
#include "MvdXmlRule.h"
/** \details
Contains declarations related to Model View Definition (MVD) functionality.
*/
namespace OdMvdXml
{
SMARTPTR(OdMvdXmlAttributeRule);
SMARTPTR(OdMvdXmlEntityRule);
SMARTPTR(OdMvdXmlConceptTemplate);
/** \details
A class that implements the storing and handling of the attribute rule.
*/
class MVDXML_EXPORT OdMvdXmlAttributeRule : public OdMvdXmlRule
{
ODRX_DECLARE_MEMBERS(OdMvdXmlAttributeRule);
public:
/** \details
Retrieves the attribute name.
\returns An ANSI string that contains the attribute name.
*/
const OdAnsiString& getAttributeName() const { return m_attributeName; };
/** \details
Sets the attribute name for the attribute rule instance.
\param value [in] An ANSI string that contains the new attribute name.
*/
void setAttributeName(const OdAnsiString &value) { m_attributeName = value; };
/** \details
Retrieves the rule identifier for the attribute rule instance.
\returns An ANSI string that contains the rule identifier.
*/
const OdAnsiString& getRuleID() const { return m_ruleID; };
/** \details
Sets the new identifier of the rule assigned to the attribute rule instance.
\param value [in] An ANSI string that contains the new identifier of the attribute rule.
*/
void setRuleID(const OdAnsiString &value) { m_ruleID = value; };
/** \details
Retrieves the attribute rule description.
\returns An ANSI string that contains the description.
*/
const OdString& getDescription() const { return m_description; };
/** \details
Sets the description of the attribute rule instance.
\param value [in] An ANSI string that contains the description of the attribute rule.
*/
void setDescription(const OdString &value) { m_description = value; };
/** \details
Retrieves the set of entity rules associated with the attribute rule.
\returns An array of smart pointers to entity rule objects.
*/
const OdMvdXmlEntityRulePtrArray& getEntityRules() const { return m_rules; };
/** \details
Retrieves the attribute rule by its identifier.
\param ruleId [in] A null-terminated string that contains the rule identifier.
\returns A raw pointer to the attribute rule object. If the attribute rule is not found, the method returns the NULL pointer.
*/
OdMvdXmlAttributeRule* getAttributeRuleByID(const char* ruleId);
/** \details
Retrieves the entity rule associated with the attribute rule object by its entity rule's identifier.
\param ruleId [in] A null-terminated string that contains the entity rule identifier.
\returns A raw pointer to the entity rule object. If the entity rule is not found, the method returns the NULL pointer.
*/
OdMvdXmlEntityRule* getEntityRuleByID(const char* ruleId);
/** \details
Retrieves a rule (either attribute rule or entity rule) by its identifier.
\param ruleId [in] A null-terminated string that contains the rule identifier.
\returns A raw pointer to the OdMvdXmlRule object. If the rule is not found, the method returns the NULL pointer.
*/
OdMvdXmlRule* getRuleByID(const char* ruleId);
/** \details
Executes the check-up of the attribute rule for a specified Concept Template object.
\param pTemplate [in] A raw pointer to the Concept Template object.
\param result [out] A placeholder for the check-up result, represented with a boolean value.
\returns eOk if the rule check-up execution was successful; otherwise, the method returns an appropriate error code.
*/
OdResult execute(const OdMvdXmlConceptTemplate* pTemplate, bool& result) const;
/** \details
The assignment operator for attribute rule objects.
\param other [in] Another OdMvdXmlAttributeRule object to be assigned (right-hand operand of the assignment operation).
\returns The attribute rule object modified by the assignment operation.
*/
OdMvdXmlAttributeRule& operator=(const OdMvdXmlAttributeRule& other);
protected:
void assign(const OdMvdXmlAttributeRule* other);
/** \details
Reads attributes from a xml element.
\param pItem [in] Pointer to a xml element containing attributes.
\returns eOk if the data was successfully read; otherwise, the method returns an appropriate error code.
*/
virtual OdResult inAttributes(TiXmlElement* pItem) override;
/** \details
Reads child element from a xml element.
\param nodeName [in] The node name of the xml element containing the child data.
\param pChild [in] Pointer to a xml element containing child data.
\returns eOk if the data was successfully read; otherwise, the method returns an appropriate error code.
*/
virtual OdResult inChildNode(const char *nodeName, TiXmlElement* pChild) override;
virtual OdResult outAttributes(TiXmlElement* pItem) override;
virtual OdResult outChildNodes(TiXmlNode* pParent) override;
/** \details
Checks whether a specified ApplicationInstance meets all constraints defined within the exchange requirements.
\param pInstance [in] A raw pointer to the application instance to check up.
\param result [out] A placeholder for the checkup result, represented with a boolean value.
\returns eOk if the instance was successfully checked; otherwise, the method returns an appropriate error code.
\remarks
If any of the required data is missing or violates any of the constraints, the checkup fails, and the output result parameter value equals false.
If the checkup procedure fails itself, the value of the output parameter with the checkup result has an undefined value.
*/
virtual OdResult doCheckInstance(const OdDAI::ApplicationInstance* pInstance, bool& result) override;
/** \details
Clean the entities assigned to the EntityRules.
*/
virtual void doCleanInstance() override;
private:
/** \details
The case-sensitive name of the attribute relative to the enclosing
EntityRule (if exists) or the enclosing applicableEntity of the
ConceptTemplate.
*/
OdAnsiString m_attributeName;
/** \details
An empty list indicates that any type may be used according to the
schema.If one or more entities or types are defined, then instances must
match one of the entries.The list of entries is expanded by each
referencing TemplateRule defined at a Concept, where downstream rules
apply according to the matching entity rule.
*/
OdMvdXmlEntityRulePtrArray m_rules;
};
}
#endif // !defined(ODA_ODMVDXMLATTRIBUTERULE_H_INCLUDED_)