/////////////////////////////////////////////////////////////////////////////// // 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_SCHEMA_H_ #define _DAI_SCHEMA_H_ #include "OdaCommon.h" #include "daiEntity.h" #include "daiDefinedType.h" #include "daiRules/daiGlobalRule.h" #include "TD_PackPush.h" //DOM-IGNORE-BEGIN class ScopedSymbolTable; using ScopedSymbolTablePtr = ScopedSymbolTable*; class ActivationRecord; using ActivationRecordPtr = std::shared_ptr; //DOM-IGNORE-END /** \details Implements the Data Access Interface (DAI) that provides functionality for manipulating data that is defined within the EXPRESS SCHEMA format. */ namespace OdDAI { class InstanceFactory; /** \details A data type that represents a smart pointer to an InstanceFactory object. */ typedef OdSmartPtr InstanceFactoryPtr; class ExternalSchema; /** \details A data type that represents a smart pointer to an ExternalSchema object. */ typedef OdSmartPtr ExternalSchemaPtr; class InterfaceSpec; /** \details A data type that represents a smart pointer to an InterfaceSpec object. */ typedef OdSmartPtr InterfaceSpecPtr; /** \details A class that implements working with a schema definition. */ class DAI_EXPORT Schema : public DictionaryInstance { public: //DOM-IGNORE-BEGIN ODRX_DECLARE_MEMBERS(Schema); //DOM-IGNORE-END /** \details Destroys the schema object. */ virtual ~Schema(); /** \details Retrieves the name of the schema. \returns An ANSI string that contains the name of the schema. */ const OdAnsiString& name() const; /** \details Retrieves a of the schema. \returns A of the schema. */ const EntitySet& entities() const; /** \details Retrieves a of the schema. \returns A of the schema. */ const EntitySet& complexEntities() const; /** \details Retrieves a of the schema. \returns A of the schema. */ const DefinedTypeSet& types() const; /** \details Searches an by its name. \param entityName [in] An ANSI string that contains the entity name. \returns A smart pointer to the found . If the entity is not found, the method returns a NULL smart pointer. */ const EntityPtr find(OdAnsiString entityName) const; /** \details Searches for an entity or type definition by its name. \param typeName [in] An ANSI string that contains the entity name. \returns A smart pointer to the of found entity or type definition. If the entity or type is not found, the method returns a NULL smart pointer. */ const NamedTypePtr namedType(OdAnsiString typeName) const; /** \details Retrieves the collection of super types starting from a specified entity definition. The method fills a passed and returns it to a calling subroutine. \param targetEntity [in] A smart pointer to the starting . \param collectionToFill [out] A placeholder for the super types collection. */ void getSuperEntityCollection(const EntityPtr targetEntity, EntityList& collectionToFill) const; /** \details Retrieves the current value of an attribute specified by its name. \param attrName [in] An ANSI string that contains the attribute name. \returns The current value of the attribute. \remarks The method provides the late binding access to the attribute value by its name. Attributes of select and aggregate data types are also supported. */ virtual OdRxValue getAttr(const char * attrName) const; /** \details Checks whether a specified model meet a global rule with a specified name and forms the list with names of aggregates that violates the specified global rule. \param model [in] A smart pointer to the model object to be validated. \param ruleName [in] An ANSI string that contains the global rule name. \param aggr [out] A placeholder for a list with names of Where Rules instances within Global Rule that didn't pass the check. \returns * if the validation passes. * if the global rule constraint is violated. * if the constraint expression is unknown or is not defined. */ OdDAI::Logical validateGlobalRule(const ModelPtr model, const char *ruleName, ListOfOdAnsiString &aggr) const; /** \details Retrieves the array of the schema's . \returns An array that contains smart pointers to the schema's objects. */ const OdArray& getGlobalRules() const; /** \details Writes data from the schema object to a physical file. \param fileName [in] A string that contains the full path to the output file to write data. \returns eOk if the data was successfully written; otherwise, the method returns an appropriate error code. */ OdResult writeToFile(const OdString& fileName) const; /** \details Creates a new complex entity from a specified list of entities. \param complexEntityList [in] A list of entities to create from. \returns A smart pointer to a created complex . \remarks * The result is plain list of entities without supertypes. * The associativity rule is valid for operation (A+B)+C=A+(B+C) and gets same result = A+B+C. */ OdDAI::EntityPtr getComplexEntity(OdDAI::List& complexEntityList); /** \details Creates a complex entity from name. \param entityName [in] Name of complex entity. It should contain names of sub entities, separated by '+'. \returns Smart pointer to newly created (or existing) complex entity, if success; otherwise returns empty pointer. */ OdDAI::EntityPtr getComplexEntity(const OdAnsiString& entityName); /** \details Creates a complex entity from list of entity names collection. \param entityNameCollection [in] Collection of already created entity names. \returns created complex entity if success, otherwise return empty pointer. */ OdDAI::EntityPtr getComplexEntity(OdDAI::List& entityNameCollection); /** \details Retrieves a set of assigned External Schemas for the schema. \returns an constant OdArray of smart pointers to ExternalSchema objects. */ //const OdArray& externalSchemas() const; /** \details Retrieves an interface specification for the schema definition. \returns a smart pointer to InterfaceSpecification instance, if cross-references are present for the schema; otherwise returns nullptr. */ const InterfaceSpecPtr& interfaceSpecification() const; //DOM-IGNORE-BEGIN void setSymbolTable(ScopedSymbolTablePtr symbolTable) { m_symbolTable = symbolTable; }; ScopedSymbolTablePtr getSymbolTable() const { return m_symbolTable; }; void setActivationRecord(ActivationRecordPtr &ar) { m_ar = ar; }; ActivationRecordPtr getActivationRecord() const { return m_ar; }; void setInstanceFactory(InstanceFactory *instanceFactory); InstanceFactoryPtr getInstanceFactory() const; protected: /** \details Sets a new name for the schema definition. \param name [in] A name for the schema definition. \remarks This method is for internal use only. */ void setName(const OdAnsiString &name); /** \details Sets a new set of entity definitions for the schema. \param entities [in] A set of entity definitions to assign to the schema definition. \remarks This method is for internal use only. */ void setEntities(const EntitySet &entities); /** \details Sets a new set of entity definitions for the schema. \param entities [in] A set of entity definitions to assign to the schema definition. \remarks This method is for internal use only. */ void setComplexEntities(const EntitySet& complexEntities); /** \details Sets a new set of defined types for the schema. \param types [in] A set of defined types to assign to the schema definition. \remarks This method is for internal use only. */ void setTypes(const DefinedTypeSet &types); /** \details Sets a new set of unnamed types for the schema. \param types [in] A set of unnamed types to assign to the schema definition. \remarks This method is for internal use only. */ void setUnnamedTypes(const DefinedTypeSet &unnamedTypes); /** \details Sets a new set of Global Rules for the schema. \param globalRules [in] A set of Global Rules to assign to the schema definition. \remarks This method is for internal use only. */ void setGlobalRules(const OdArray &globalRules); /** \details Sets a new set of External Schemas for the schema. \param externalSchemas [in] A set of External Schemas to assign to the schema definition. \remarks This method is for internal use only. */ //void setExternalSchemas(const OdArray &externalSchemas); /** \details Sets an interface specification for the schema. \param interfaceSpec [in] A smart pointer to InterfaceSpec to assign to the schema definition. \remarks This method is for internal use only. */ void setInterfaceSpecification(const InterfaceSpecPtr &interfaceSpec); protected: /** The schema name.*/ OdAnsiString m_name; /** Entity definitions that are contained in the schema.*/ OdRxDictionaryPtr m_entities; #ifdef COMPLEX_ENTITY_SYNC /** Complex entity type definitions mutex.*/ OdMutex m_complexEntitiesMutex; #endif /** Complex entity type definitions. Contains entities not explicitly specified in schema.*/ OdRxDictionaryPtr m_complexEntities; /** Type definitions that are contained in the schema.*/ OdRxDictionaryPtr m_types; /** Set of Global Rules definitions declared in the schema.*/ OdArray m_globalRules; /** Entity type definitions without names that are contained in the schema.*/ OdRxDictionaryPtr m_unnamedTypes; /** An array of entity type definitions without names that are contained in the schema.*/ OdArray m_unnamedTypesArray; /** An array of external schemas for the schema.*/ //OdArray m_externalSchemas; InstanceFactoryPtr m_instanceFactory; ScopedSymbolTablePtr m_symbolTable = nullptr; ActivationRecordPtr m_ar = nullptr; InterfaceSpecPtr m_interfaceSpec; friend class SchemaFiller; //DOM-IGNORE-END }; /** \details A data type that represents a smart pointer to a object. */ typedef OdSmartPtr SchemaPtr; } #include "TD_PackPop.h" #endif // _DAI_SCHEMA_H_