///////////////////////////////////////////////////////////////////////////////
// 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_ENUM_H_
#define _DAI_ENUM_H_
#include "OdaCommon.h"
#include "OdAnsiString.h"
#include "daiUtils/daiUnset.h"
#include "RxDictionary.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 EnumerationType;
/** \details
A class that provides information about the type of the EXPRESS ENUMERATION item.
*/
class DAI_EXPORT EnumItemTypeProvider
{
public:
/** \details
Retrieves the underlying definition for the enumeration item.
\returns A raw pointer to the underlying object that represents the enumeration type.
*/
const OdDAI::EnumerationType* getSchemaType() const;
protected:
virtual ~EnumItemTypeProvider();
void initSchemaType(const OdRxDictionaryPtr& types, const char* enumName);
void uninitSchemaType();
const OdDAI::EnumerationType* getSchemaTypeByName(const OdRxDictionaryPtr& types, const char* enumName);
private:
const OdDAI::EnumerationType* m_enumerationType = nullptr;
};
}
namespace OdDAI
{
/** \details
A class that implements the EXPRESS ENUMERATION data type within IFC Standard Data Access Interface (SDAI).
*/
class DAI_EXPORT Enum
{
public:
/** \details
Creates a new instance of a specified enumeration type.
\param enumerationType [in] A raw pointer to the value that determines the enumeration type.
*/
Enum(const OdDAI::EnumerationType* enumerationType);
/** \details
Creates a new instance as a copy of another object (copy constructor).
\param other [in] Another instance to copy from.
*/
Enum(const Enum& other);
/** \details
Creates a new instance with default parameters.
*/
Enum();
public:
/** \details
Retrieves if the instance has an assigned value.
\returns true if the instance has an assigned value; otherwise, the method returns false.
*/
bool exists() const;
/** \details
Makes the instance value unset.
*/
void nullify();
/** \details
Retrieves the underlying definition.
\returns A raw pointer to the underlying object that represents the enumeration type.
*/
const OdDAI::EnumerationType* getSchemaType() const;
/** \details
Retrieves the index of the current enumeration value.
\returns An integer value that contains the respective index of the current enumeration value.
*/
int getIntValue() const;
/** \details
Assigns an index that corresponds to the instance value.
\param newValue [in] An integer value to assign with the instance value.
\returns true if the specified index was successfully assigned to the instance value; otherwise, the method returns false.
*/
bool setIntValue(int newValue);
/** \details
Retrieves the current value as string.
\returns A raw pointer to a string that represents the current value.
*/
const char* getTextValue() const;
/** \details
Assigns a string that corresponds to the instance value.
\param newValue [in] An null-terminated string to assign with the instance value.
\returns true if the specified string was successfully assigned to the instance value; otherwise, the method returns false.
*/
bool setTextValue(const char * newValue);
/** \details
Assigns a string that corresponds to the instance value.
The assigned string value is case-insensitive.
\param newValue [in] An null-terminated string to assign with the instance value.
\returns true if the specified string was successfully assigned to the instance value; otherwise, the method returns false.
*/
bool setTextValueCaseInsensitive(const char * newValue);
/** \details
The equality operator for enumeration values.
\param other [in] Another value to compare with (right-hand operand of the comparison operation).
\returns true if the object equals another object (right-hand operand of the comparison operation); otherwise, the operator returns false.
*/
bool operator== (const Enum& other) const;
/** \details
The "less than" operator for enumeration values.
\param other [in] Another value to compare with (right-hand operand of the comparison operation).
\returns true if the object is less than another object (right-hand operand of the comparison operation); otherwise, the operator returns false.
*/
bool operator< (const Enum& other) const;
/** \details
The non equality operator for enumeration values.
\param other [in] Another value to compare with (right-hand operand of the comparison operation).
\returns true if the object is NOT equal to another object (right-hand operand of the comparison operation); otherwise, the operator returns false.
*/
bool operator!=(const Enum& other) const;
/** \details
The assignment operator for objects.
\param other [in] Another object (right-hand operand of the assignment operation).
\returns A reference to the object modified with the assignment operation.
*/
Enum& operator=(const Enum& other);
private:
const OdDAI::EnumerationType* m_enumerationType;
int m_value;
};
}
namespace OdDAI { namespace Utils { template <> inline const OdDAI::Enum& getUnset() { static OdDAI::Enum enumUnset; return enumUnset; } } }
namespace OdDAI { namespace Utils { inline bool isUnset(const OdDAI::Enum& value) { return !value.exists(); } } }
namespace OdDAI { namespace Utils { inline bool isUnset(const OdDAI::Enum* value) { return (value == nullptr || !value->exists()); } } }
#include "TD_PackPop.h"
#endif