/////////////////////////////////////////////////////////////////////////////// // 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_ODMVDXMLENTITYRULE_H_INCLUDED_) #define ODA_ODMVDXMLENTITYRULE_H_INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "IfcEntity.h" #include "MvdXmlRule.h" #include "MvdXmlTemplateRef.h" /** \details Contains declarations related to Model View Definition (MVD) functionality. */ namespace OdMvdXml { SMARTPTR(OdMvdXmlEntityRule); SMARTPTR(OdMvdXmlAttributeRule); SMARTPTR(OdMvdXmlConceptTemplate); /** \details A class that implements the representation of an entity or a data type referenced by an attribute. */ class MVDXML_EXPORT OdMvdXmlEntityRule : public OdMvdXmlRule { ODRX_DECLARE_MEMBERS(OdMvdXmlEntityRule); public: /** \details Retrieves the name of the entity that is assigned with an attribute rule (an entity subtype or a value of the SELECT data type). \returns An ANSI string that contains the entity name. \remarks The returned entity name is a case-sensitive ANSI string. */ const OdAnsiString& getEntityName() const { return m_entityName; }; /** \details Sets the name of the entity that is assigned with an attribute rule. \param value [in] An ANSI string that contains the entity name. */ void setEntityName(const OdAnsiString &value) { m_entityName = value; }; /** \details Retrieves the rule identifier. \returns An ANSI string that contains the rule identifier. */ const OdAnsiString& getRuleID() const { return m_ruleID; }; /** \details Sets the rule identifier. \param value [in] An ANSI string that contains the rule identifier. */ void setRuleID(const OdAnsiString &value) { m_ruleID = value; }; /** \details Retrieves the rule description. \returns A string that contains the rule description. */ const OdString& getDescription() const { return m_description; }; /** \details Sets the rule description. \param value [in] A string that contains the rule description. */ void setDescription(const OdString &value) { m_description = value; }; /** \details Retrieves the template reference. \returns A smart pointer to an OdMvdXmlTemplateRef object. */ const OdMvdXmlTemplateRefPtr getTemplateRef() { return m_pTemplateRef; }; /** \details Sets the template reference for the entity rule object. \param value [in] A smart pointer to an OdMvdXmlTemplateRef object. */ void setTemplateRef(OdMvdXmlTemplateRefPtr value) { m_pTemplateRef = value; }; /** \details Retrieves the list of attribute rules associated with the entity rule object. \returns An array of smart pointers to OdMvdXmlAttributeRule objects. */ const OdMvdXmlAttributeRulePtrArray& getEntityRules() const { return m_rules; }; /** \details Retrieves an attribute rule associated with the entity rule object by its identifier. \param ruleId [in] A pointer to the string that contains the attribute rule identifier. \returns A raw pointer to the found OdMvdXmlAttributeRule object. If the attribute rule is not found, a NULL pointer is returned. */ OdMvdXmlAttributeRule* getAttributeRuleByID(const char* ruleId); /** \details Retrieves the entity rule object by its identifier. \param ruleId [in] A pointer to the string that contains the entity rule identifier. \returns A raw pointer to the found OdMvdXmlEntityRule object. If the entity rule is not found, a NULL pointer is returned. */ OdMvdXmlEntityRule* getEntityRuleByID(const char* ruleId); /** \details Retrieves the rule object by its identifier. \param ruleId [in] A pointer to the string that contains the rule identifier. \returns A raw pointer to the found OdMvdXmlRule object. If the rule is not found, a NULL pointer is returned. */ OdMvdXmlRule* getRuleByID(const char* ruleId); /** \details Runs the entity rule check. \param pTemplate [in] A raw pointer to the OdMvdXmlConceptTemplate object. \param result [out] A placeholder that contains the boolean result of the entity rule check. \returns eOk if the checking process was successfully finished; otherwise, the method returns an appropriate error code. */ OdResult execute(const OdMvdXmlConceptTemplate* pTemplate, bool& result) const; /** \details Assignment operator for entity rules. \param other [in] Another OdMvdXmlEntityRule object to be assigned (right-hand operand of the assignment operation). \returns The entity rule object modified by the assignment operation. */ OdMvdXmlEntityRule& operator=(const OdMvdXmlEntityRule& other); protected: /** \details Copy data from the other element. \param other [in] Object to copy from. */ void assign(const OdMvdXmlEntityRule* other); /** \details Retrieves the name of the element. This name is used to write the element to a file. \returns The name of the element. */ virtual OdAnsiString getElementName(); /** \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; /** \details Writing attributes to the xml element. \param pItem [in] Pointer to the xml element to which you want to add attributes. \returns eOk if the data was written successfully; otherwise, the method returns an appropriate error code. */ virtual OdResult outAttributes(TiXmlElement* pItem) override; /** \details Writing child elements to the xml element. \param pParent [in] Pointer to the xml element to which you want to add children. \returns eOk if the data was written successfully; otherwise, the method returns an appropriate error code. */ virtual OdResult outChildNodes(TiXmlNode* pParent) override; /** \details Checks whether a specified ApplicationInstance meets all constraints defined within the Entity Rule object. \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 entity(e.g.“IfcBeam”) which must be assignable to the enclosing AttributeRule (i.e.entity subtype or select member). */ OdAnsiString m_entityName; /** \details Optional reference to a partial template. An optional attribute “IdPrefix” can be given to ensure that RuleIDs of partial templates are unique within the scope of its usage. This attribute is used as a prefix for all referenced RuleIDs. */ OdMvdXmlTemplateRefPtr m_pTemplateRef; /** \details Indicates a list of attributes included in the concept template and potentially constrained on the referenced entity. */ OdMvdXmlAttributeRulePtrArray m_rules; }; } #endif // !defined(ODA_ODMVDXMLENTITYRULE_H_INCLUDED_)