///////////////////////////////////////////////////////////////////////////////
// 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_ODMVDXMLCOMMON_H_INCLUDED_)
#define ODA_ODMVDXMLCOMMON_H_INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "OdaCommon.h"
#include "IfcCommon.h"
#include "RxObject.h"
#include "RxObjectImpl.h"
#include "OdArray.h"
#include "OdAnsiString.h"
// Generate error if item more than one.
// #define MORE_THAN_ONE_ERROR
#ifdef MVDXM_MORE_THAN_ONE_ERROR
#define MVDXM_MORE_THAN_ONE(parent, text, caption) appendXmlErrorMessage(parent, text, caption); return eSyntaxError;
#else
#define MVDXM_MORE_THAN_ONE(parent, text, caption) appendXmlWarningMessage(parent, text, caption)
#endif
#define RETURNNOTOK(expr) {OdResult odResult;if ((odResult=expr)) return odResult;};
#define RETURNNOTCHECK(expr) {OdResult odResult;if ((odResult=expr)) return odResult;};
/** \details
Contains declarations related to Model View Definition (MVD) functionality.
*/
namespace OdMvdXml
{
/** \details
Contains declarations of statuses of an element of model view definition element.
*/
enum OdMvdStatus
{
/**The status value is not set.*/
OdMvdStatusUnset = -1,
/**The definition element is a sample.*/
OdMvdSample = 0,
/**The definition element is a proposal.*/
OdMvdProposal,
/**The definition element is a draft.*/
OdMvdDraft,
/**The definition element is a candidate.*/
OdMvdCandidate,
/**The definition element is final.*/
OdMvdFinal,
/**The definition element is deprecated.*/
OdMvdDeprecated
};
/** \details
A class that implements a logical operator functionality.
*/
class OdMvdOperator
{
public:
/** \details
Logical operations supported by the OdMvdOperator class.
*/
enum Operator
{
/**Operation is not set.*/
kUnset = -1,
/**Logical AND operation:
| X | Y | X AND Y |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
*/
kAND = 0,
/**Logical OR operation:
*/
kOR,
/**Logical NOT operation.
*/
kNOT,
/**Logical NAND operation.
| X | Y | X NAND Y |
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
*/
kNAND,
/**Logical NOR operation.
| X | Y | X NOR Y |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
*/
kNOR,
/**Logical XOR operation.
| X | Y | X XOR Y |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
*/
kXOR,
/**Logical NXOR operation.
| X | Y | X NXOR Y |
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
*/
kNXOR
};
/** \details
Creates a new operator object with unset operation.
*/
OdMvdOperator()
:m_operator(kUnset)
{
}
/** \details
Retrieves the operation associated with the operator object.
\returns A value of the OdMvdOperator::Operator enumeration that represents the logical operation performed by the operator object.
*/
const Operator get() const
{
return m_operator;
}
/** \details
Checks whether the operation that the operator performs is not set.
\returns true if the operation is NOT specified; otherwise, the method returns false.
*/
const bool IsUnset() const
{
return (m_operator == kUnset);
}
/** \details
Performs the logical operation associated with the operator object.
\param first [in] The value of the first operand of the operation.
\param second [in] The value of the second operand of the operation.
\returns A boolean value that contains the result of the operation.
*/
const bool performBoolean(const bool first, const bool second) const
{
switch (m_operator) {
case kAND: return first && second;
case kOR: return first || second;
case kNOT: return !first;
case kNAND: return !(first && second);
case kNOR: return !(first || second);
case kXOR: return first != second;
case kNXOR: return first == second;
default: return false;
}
}
/** \details
Retrieves the textual representation of the logical operation associated with the operator object.
\returns An ANSI string that contains the textual representation of the logical operation.
*/
OdAnsiString toString()
{
switch (m_operator) {
case kAND: return "AND";
case kOR: return "OR";
case kNOT: return "NOT";
case kNAND: return "NAND";
case kNOR: return "NOR";
case kXOR: return "XOR";
case kNXOR: return "NXOR";
default: return "";
}
}
/** \details
The equality operator that compares two MVD operator objects.
\param other [in] An operator object to be compared with (right-hand operand of the comparison operation).
\returns true if the operator object equals to another specified operator object; otherwise, the result equals to the false value.
*/
bool operator==(const OdMvdOperator& other) const
{
return (*this).m_operator == other.m_operator;
}
/** \details
The equality operator that checks whether the MVD operator object performs a specified logical operation.
\param other [in] An Operator enumeration value that contains the logical operation.
\returns true if the operator object performs the specified logical operation; otherwise, the result equals to the false value.
*/
bool operator==(const Operator other) const
{
return (*this).m_operator == other;
}
/** \details
The assignment operator for operator objects.
\param other [in] Another operator object to be assigned (right-hand operand of the assignment operation).
\returns A reference to the operator object modified by the assignment operation.
*/
OdMvdOperator& operator=(const OdMvdOperator& other)
{
m_operator = other.m_operator;
return (*this);
}
/** \details
The assignment operator for operator objects.
\param other [in] An ANSI string that contains a textual representation of the logical operation to be assigned (right-hand operand of the assignment operation).
\returns A reference to the operator object modified by the assignment operation.
*/
OdMvdOperator& operator=(const OdAnsiString& other)
{
return (*this) = other.c_str();
}
/** \details
The assignment operator for operator objects.
\param other [in] An ANSI string that contains a textual representation of the logical operation to be assigned (right-hand operand of the assignment operation).
\returns A reference to the operator object modified by the assignment operation.
*/
OdMvdOperator& operator=(const char* other)
{
m_operator = kUnset;
if (other)
{
OdAnsiString str(other);
str.makeUpper();
if (str.iCompare("AND") == 0)
m_operator = kAND;
else if (str.iCompare("OR") == 0)
m_operator = kOR;
else if (str.iCompare("NOT") == 0)
m_operator = kNOT;
else if (str.iCompare("NAND") == 0)
m_operator = kNAND;
else if (str.iCompare("NOR") == 0)
m_operator = kNOR;
else if (str.iCompare("XOR") == 0)
m_operator = kXOR;
else if (str.iCompare("NXOR") == 0)
m_operator = kNXOR;
}
return (*this);
}
private:
Operator m_operator;
};
/** \details
A class that stores and operates the data about applicability within the Exchange Requirement Model (ERM).
*/
class OdMvdApplicability
{
public:
/** \details
Declarations that cover applicability values.
*/
enum Applicability
{
/**Applicability is not set.*/
kUnset = -1,
/**Import applicability that assumes the definition of data that the importing application can correctly process.*/
kImport = 0,
/**Export applicability that assumes the exchange application must create a data that matches the defined requirements.*/
kExport,
/**Applicable for both import and export.*/
kBoth
};
/** \details
Creates a new applicability object with unset applicability value.
*/
OdMvdApplicability()
: m_applicability(kUnset)
{}
/** \details
Retrieves the applicability type associated with the applicability object.
\returns A value of the OdMvdApplicability::Applicability enumeration that represents the applicability type.
*/
const Applicability get() const
{
return m_applicability;
}
/** \details
Checks whether the applicability value is not set.
\returns true if the applicability value is NOT specified; otherwise, the method returns false.
*/
const bool IsUnset() const
{
return (m_applicability == kUnset);
}
/** \details
Retrieves the textual representation of the applicability value associated with the applicability object.
\returns An ANSI string that contains the textual representation of the applicability type
*/
OdAnsiString toString()
{
switch (m_applicability) {
case kImport: return "import";
case kExport: return "export";
case kBoth: return "both";
default: return "";
}
}
/** \details
The equality operator that compares two applicability objects.
\param other [in] An applicability object to be compared with (right-hand operand of the comparison operation).
\returns true if the applicability object equals to another specified applicability object; otherwise, the result equals to the false value.
*/
bool operator==(const OdMvdApplicability& other) const
{
return (*this).m_applicability == other.m_applicability;
}
/** \details
The equality operator that checks whether the applicability object has a specified applicability type.
\param other [in] An OdMvdApplicability::Applicability enumeration value that contains the applicability type.
\returns true if the applicability object has the specified applicability type; otherwise, the result equals to the false value.
*/
bool operator==(const Applicability other) const
{
return (*this).m_applicability == other;
}
/** \details
The assignment operator for applicability objects.
\param other [in] Another applicability object to be assigned (right-hand operand of the assignment operation).
\returns A reference to the applicability object modified by the assignment operation.
*/
OdMvdApplicability& operator=(const OdMvdApplicability& other)
{
m_applicability = other.m_applicability;
return (*this);
}
/** \details
The assignment operator for applicability objects.
\param other [in] An ANSI string that contains a textual representation of the applicability type to be assigned (right-hand operand of the assignment operation).
\returns A reference to the applicability object modified by the assignment operation.
*/
OdMvdApplicability& operator=(const OdAnsiString& other)
{
return (*this) = other.c_str();
}
/** \details
The assignment operator for applicability objects.
\param other [in] A ANSI string that contains a textual representation of the applicability type to be assigned (right-hand operand of the assignment operation).
\returns A reference to the applicability object modified by the assignment operation.
*/
OdMvdApplicability& operator=(const char* other)
{
m_applicability = kUnset;
if (other)
{
OdAnsiString str(other);
str.makeLower();
if (str.iCompare("import") == 0)
m_applicability = kImport;
else if (str.iCompare("export") == 0)
m_applicability = kExport;
else if (str.iCompare("both") == 0)
m_applicability = kBoth;
}
return (*this);
}
private:
Applicability m_applicability;
};
/** \details
A class that implements storing and operating of exchange requirements.
*/
class OdMvdRequirement
{
public:
/** \details
Declarations of exchange requirement types.
*/
enum Requirement
{
/**An exchange requirement is undefined.*/
kUnset = -1,
/**A mandatory requirement: must be met; otherwise an error occurs.*/
kMandatory = 0,
/**A recommended requirement: should be met; otherwise a warning occurs.*/
kRecommended,
/**A not-relevant requirement: no requirements to meet.*/
kNotRelevant,
/**A not-recommended requirement: should NOT be met; otherwise a warning occurs.*/
kNotRecommended,
/**An excluded requirement: must NOT be true; otherwise an error occurs.*/
kExcluded
};
/** \details
Creates a new requirement object.
*/
OdMvdRequirement()
: m_requirement(kUnset)
{}
/** \details
Retrieves the requirement type associated with the requirement object.
\returns A value of the OdMvdRequirement::Requirement enumeration that represents the requirement type.
*/
const Requirement get() const
{
return m_requirement;
}
/** \details
Checks whether the requirement type is not set.
\returns true if the requirement type is NOT specified; otherwise, the method returns false.
*/
const bool IsUnset() const
{
return (m_requirement == kUnset);
}
/** \details
Retrieves the textual representation of the requirement type associated with the requirement object.
\returns An ANSI string that contains the textual representation of the requirement type.
*/
OdAnsiString toString()
{
switch (m_requirement) {
case kMandatory: return "mandatory";
case kRecommended: return "recommended";
case kNotRelevant: return "not-relevant";
case kNotRecommended: return "not-recommended";
case kExcluded: return "excluded";
default: return "";
}
}
/** \details
The equality operator that compares two requirement objects.
\param other [in] A requirement object to be compared with (right-hand operand of the comparison operation).
\returns true if the requirement object equals to another specified requirement object; otherwise, the result equals to the false value.
*/
bool operator==(const OdMvdRequirement& other) const
{
return (*this).m_requirement == other.m_requirement;
}
/** \details
The equality operator that checks whether the requirement object has a specified requirement type.
\param other [in] An OdMvdRequirement::Requirement enumeration value that contains the requirement type.
\returns true if the requirement object has the specified requirement type; otherwise, the result equals to the false value.
*/
bool operator==(const Requirement other) const
{
return (*this).m_requirement == other;
}
/** \details
The assignment operator for requirement objects.
\param other [in] Another requirement object to be assigned (right-hand operand of the assignment operation).
\returns A reference to the requirement object modified by the assignment operation.
*/
OdMvdRequirement& operator=(const OdMvdRequirement& other)
{
m_requirement = other.m_requirement;
return (*this);
}
/** \details
The assignment operator for requirement objects.
\param other [in] An ANSI string that contains a textual representation of the requirement type to be assigned (right-hand operand of the assignment operation).
\returns A reference to the requirement object modified by the assignment operation.
*/
OdMvdRequirement& operator=(const OdAnsiString& other)
{
return (*this) = other.c_str();
}
/** \details
The assignment operator for requirement objects.
\param other [in] A ANSI string that contains a textual representation of the requirement type to be assigned (right-hand operand of the assignment operation).
\returns A reference to the requirement object modified by the assignment operation.
*/
OdMvdRequirement& operator=(const char* other)
{
m_requirement = kUnset;
if (other)
{
OdAnsiString str(other);
str.makeLower();
if (str.iCompare("mandatory") == 0)
m_requirement = kMandatory;
else if (str.iCompare("recommended") == 0)
m_requirement = kRecommended;
else if ((str.iCompare("not-relevant") == 0) || (str.iCompare("not relevant") == 0))
m_requirement = kNotRelevant;
else if ((str.iCompare("not-recommended") == 0) || (str.iCompare("not recommended") == 0))
m_requirement = kNotRecommended;
else if (str.iCompare("excluded") == 0)
m_requirement = kExcluded;
}
return (*this);
}
private:
Requirement m_requirement;
};
} // namespace OdMvdXml
#endif // !defined(ODA_ODMVDXMLCOMMON_H_INCLUDED_)