///////////////////////////////////////////////////////////////////////////////
// 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_ODMVDXMLCONCEPTTEMPLATE_H_INCLUDED_)
#define ODA_ODMVDXMLCONCEPTTEMPLATE_H_INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "StringArray.h"
#include "IfcEntity.h"
#include "MvdXmlRule.h"
#include "MvdXmlIdentity.h"
/** \details
Contains declarations related to Model View Definition (MVD) functionality.
*/
namespace OdMvdXml
{
SMARTPTR(OdMvdXmlConceptTemplate);
SMARTPTR(OdMvdXmlAttributeRule);
SMARTPTR(OdMvdXmlEntityRule);
/** \details
A class that implements handling of an MVDXML Concept Template.
A Concept Template represents entities and their attributes used for the support of a functional unit defined within the Concept.
*/
class MVDXML_EXPORT OdMvdXmlConceptTemplate : public OdMvdXmlIdentityDefinitions
{
ODRX_DECLARE_MEMBERS(OdMvdXmlConceptTemplate);
public:
/** \details
Creates a new instance of the Concept Template with default parameters.
*/
OdMvdXmlConceptTemplate();
/** \details
Retrieves the name of the applicable schema the Concept Template object is assigned with (for example, "IFC2X3" or "IFC4").
\returns An ANSI string that contains the name of the applicable schema.
*/
const OdAnsiString& getApplicableSchema() const { return m_applicableSchema; };
/** \details
Sets the name of the applicable schema the Concept Template object is assigned with (for example, "IFC2X3" or "IFC4").
\param value [in] An ANSI string that contains the name of the applicable schema.
*/
void setApplicableSchema(const OdAnsiString &value) { m_applicableSchema = value; };
/** \details
Retrieves the name of the applicable entity for the Concept Template object.
The applicable entity is the Concept Template's root entity (often the IfcObject entity or its sub-entity, for example, an IfcProduct entity).
\returns An ANSI string that contains the name of the applicable entity.
*/
OdAnsiString& getApplicableEntity() { return m_applicableEntities; };
/** \details
Sets the name of the applicable entity for the Concept Template object.
The applicable entity is the Concept Template's root entity (often the IfcObject entity or its sub-entity, for example, an IfcProduct entity).
\param value [in] An ANSI string that contains the name of the applicable entity.
*/
void setApplicableEntity(const OdAnsiString& value) { m_applicableEntities = value; };
/** \details
Retrieves the current value of the partial flag.
The partial flag determines whether the Concept Template is partial (equals true) or not (equals false).
\returns true if the Concept Template is partial; otherwise, the method returns false.
*/
const bool getIsPartial() const { return m_isPartial; };
/** \details
Sets a new value of the partial flag.
The partial flag determines whether the Concept Template is partial (equals true) or not (equals false).
\param value [in] A boolean value that contains the new value of the partial flag.
*/
void setIsPartial(const bool value) { m_isPartial = value; };
/** \details
Retrieves the set of attribute rules associated with the Concept Template object.
\returns An array of smart pointers to OdMvdXmlAttributeRule objects that represents the set of attribute rules.
*/
const OdMvdXmlAttributeRulePtrArray& getRules() const { return m_rules; };
/** \details
Retrieves the set of sub-templates for the Concept Template object.
\returns An array of smart pointers to OdMvdXmlConceptTemplate objects that represents the set of sub-templates.
*/
const OdMvdXmlConceptTemplatePtrArray& getSubTemplates() const { return m_subTemplates; };
/** \details
Retrieves the attribute rule associated with the Concept Template object by its identifier.
\param ruleId [in] An ANSI string that contains the attribute rule identifier.
\returns A raw pointer to the OdMvdXmlAttributeRule object. If no attribute rule with the specified identifier is found, the method returns the NULL pointer value.
*/
OdMvdXmlAttributeRule* getAttributeRuleByID(const char* ruleId);
/** \details
Retrieves the entity rule associated with the Concept Template object by its identifier.
\param ruleId [in] An ANSI string that contains the entity rule identifier.
\returns A raw pointer to the OdMvdXmlEntityRule object. If no entity rule with the specified identifier is found, the method returns the NULL pointer value.
*/
OdMvdXmlEntityRule* getEntityRuleByID(const char* ruleId);
/** \details
Retrieves the OdMvdXmlRule associated with the Concept Template object by its identifier.
\param ruleId [in] An ANSI string that contains the rule identifier.
\returns A raw pointer to the OdMvdXmlRule object. If no rule with the specified identifier is found, the method returns the NULL pointer value.
*/
OdMvdXmlRule* getRuleByID(const char* ruleId);
/** \details
Checks whether a specified ApplicationInstance meets all constraints defined within the Concept Template 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.
*/
OdResult checkInstance(const OdDAI::ApplicationInstance* pInstance, bool& result) const;
/** \details
Cleans the list of entities assigned to the Concept Template's entity rules.
The method also cleans the lists of entity rules instances in sub-templates.
*/
void cleanInstance();
/** \details
The assignment operator for Concept Template objects.
\param other [in] Another OdMvdXmlConceptTemplate object to be assigned (the right-hand operand of the assignment operation).
\returns A reference to the Concept Template object modified with the assignment operation.
*/
OdMvdXmlConceptTemplate& operator=(const OdMvdXmlConceptTemplate& other);
protected:
/** \details
Copy data from the other object.
\param other [in] Object to copy from.
*/
void assign(const OdMvdXmlConceptTemplate* 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;
private:
// TODO: In future change to OdStringArray
/** \details
Identifies the default schema for which the template applies, such as
IFC2X_FINAL, IFC2X2_FINAL, IFC2X3, or IFC4.The template may be
used for model views of other schemas, if all enclosed rules resolve to
available attributes and types.
NOTE: In future versions it might be of interest to support more than one
IFC release. This can be supported by using a semicolon as schema
name delimiter.
*/
OdAnsiString m_applicableSchema;
/** \details
Indicates the IfcRoot-based entities, including all derived entities, for
which the concept applies. It is recommended to use a single base class
(e.g. IfcElement). This value provides the context for any attribute rules
and is used within MVD tools to filter the list of available templates for
particular entities. For a sub-template, the applicable entity must be the
same type or a subtype of the outer template. This value may be blank to
indicate an abstract template that cannot be instantiated,
containing subtemplates for specific entities.
*/
OdAnsiString m_applicableEntities;
/** \details
A flag, indicating whether the concept template is a partial template,
which shall only be used inside another concept template, or not.
*/
bool m_isPartial;
/** \details
Set of sub-templates, having a subset of applicable entities, which further
define a concept template for particular usage. For example, a template
for material usage may have sub-templates for material layer sets,
material profile sets, and material constituent sets.
*/
OdMvdXmlConceptTemplatePtrArray m_subTemplates;
/** \details
Set of attributes defined at applicableEntity, where each attribute may
have value constraints and/or graphs of object instances defined.If an
attribute is not defined, then the requirements are the same as indicated
for the schema.
*/
OdMvdXmlAttributeRulePtrArray m_rules;
};
}
#endif // !defined(ODA_ODMVDXMLCONCEPTTEMPLATE_H_INCLUDED_)