/////////////////////////////////////////////////////////////////////////////// // 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_VALIDATION_COMMON_H_ #define _DAI_VALIDATION_COMMON_H_ #include "OdaCommon.h" #include "daiBuildOptions.h" #include "RxModule.h" #define STL_USING_LIST #include "OdaSTL.h" #include "RxObject.h" #include "RxModule.h" #include "OdAnsiString.h" #include #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 ValidationTask; /** \details A data type that represents a smart pointer to a object. */ typedef OdSmartPtr ValidationTaskPtr; /** \details A base class that stores the messages. */ class DAI_EXPORT ValidationLogger { public: /** \details Enumeration to define the type of message. */ enum MessageType { /** An information message. */ kInfo = 0, /** A warning message. */ kWarning = 1, /** An error message. */ kError = 2 }; /** \details Adds a message to the log. \param type [in] The type of message. \param message [in] OdAnsiString value that contains the message. */ void addMessage(MessageType type, OdAnsiString message); /** \details Retrieves the vector of pairs that contains MessageType and OdAnsiString values that contains the log. \returns The vector of pairs that contains MessageType and OdAnsiString values that contains the log. */ const std::vector>& getLog() const; private: //DOM-IGNORE-BEGIN std::vector> m_log; //DOM-IGNORE-END }; /** \details A base class that stores and handles the tasks, set by user, what should be done to file inside validator. */ class DAI_EXPORT ValidationTasksHolder { public: /** \details Sets a validation task class into specific list found by function. \param taskClass [in] Validation task class. */ void addValidationTask(OdRxClass* taskClass); /** \details Remove a validation task class for validator from specific list found by function. \param taskClass [in] Validation task class. */ void removeValidationTask(OdRxClass* taskClass); /** \details Retrieves the list of the validation task classes. \returns A STD list of raw pointers to the OdRxClass. */ const std::list& modelValidationTasks() const; /** \details Retrieves the list of the instance validation task classes. \returns A STD list of raw pointers to the OdRxClass. */ const std::list& instanceValidationTasks() const; /** \details Retrieves the list of the extent validation task classes. \returns A STD list of raw pointers to the OdRxClass. */ const std::list& extentValidationTasks() const; /** \details Finds specified validation task by its name. \param taskName [in] Validation task name. \returns a pointer to an OdRxClass for validation task name */ OdRxClass* findValidationTask(const OdAnsiString& taskName) const; private: //DOM-IGNORE-BEGIN std::list DaiModelValidationTaskList; std::list DaiInstanceValidationTaskList; std::list DaiExtentValidationTaskList; //DOM-IGNORE-END }; /** \details Class that represents a validation module. */ class DAI_EXPORT ValidationModule : public OdRxModule { public: /** \details Default constructor for the ValidationModule class. */ ValidationModule(); /** \details Gets an associated validation task holder. \returns const reference to an associated object. */ const OdDAI::ValidationTasksHolder& taskHolder() const; /** \details Retrieves the list of the validation tasks which loads from file set by user. \param path [in] Ansi String value of path to the file. \param errorsLog [in] Value for error log. \returns empty string if the task loaded successfully, or an appropriate error text otherwise. */ virtual std::list loadFile(OdAnsiString path, OdDAI::ValidationLogger& errorsLog); /** \details Retrieves the name of validation module group. \returns An ANSI string that contains the name of validation module group. */ virtual OdAnsiString groupingName() const = 0; protected: //DOM-IGNORE-BEGIN OdDAI::ValidationTasksHolder m_taskHolder; //DOM-IGNORE-END }; using ValidationModulePtr = OdSmartPtr; } /** \details Returns a reference to DAI validation tasks holder. \returns Reference to DAI validation tasks holder. */ DAI_EXPORT const OdDAI::ValidationTasksHolder& oddaiGetValidationTasksHolder(); #define ODRX_VALIDATION_DECLARE_MEMBERS_GENERIC(ClassType, ClassName) \ public: \ \ /** Casts the specified pointer to an ClassName SmartPointer. **/ \ static OdSmartPtr cast(const OdRxObject* pObj) \ { \ if (pObj) \ return OdSmartPtr(((ClassName*)pObj->queryX(ClassName::desc())), kOdRxObjAttach); \ return (ClassName*)0; \ } \ \ static ClassType* g_pDesc; \ \ /** Returns the static ClassType description object associated with this object. **/ \ /** This function is for use only when the class type of this object is known. **/ \ /** If the class type of this object is unknown, use instead isA(). **/ \ static ClassType* desc(); \ \ /** Returns the ClassType description instance associated with this object. **/ \ /** This function is for use only when the class type of this object is unknown. **/ \ /** If the class type of this object is known, use instead desc(). **/ \ virtual ClassType* isA() const; \ \ /** Returns the Protocol Extension object for this object. **/ \ /** Return null if there is no Protocol Extension object is found. **/ \ virtual OdRxObject* queryX(const OdRxClass* protocolClass) const; \ \ /** Creates a new instance of this object type. **/ \ /** Returns a SmartPointer to the new instance. **/ \ static OdRxObjectPtr pseudoConstructor(); \ \ /** Creates a new instance of this object type. **/ \ /** Returns a SmartPointer to the new instance. **/ \ static OdSmartPtr createObject() \ { if (!desc()) throw OdError(eNotInitializedYet); return desc()->create(); } \ \ /** Registers ClassName with the ODA Platform. **/ \ static void rxInit(OdDAI::ValidationTasksHolder& tasksHolder); \ \ /* Unregisters ClassName with the ODA Platform. **/ \ static void rxUninit(OdDAI::ValidationTasksHolder& tasksHolder) #define ODRX_VALIDATION_DECLARE_MEMBERS(ClassName)\ ODRX_VALIDATION_DECLARE_MEMBERS_GENERIC(OdRxClass, ClassName) #define ODRX_VALIDATION_CONS_DEFINE_MEMBERS(ClassName,ParentClass,DOCREATE) \ \ ODRX_VALIDATION_CONS_DEFINE_MEMBERS_ALTNAME(ClassName,ParentClass,OD_T(#ClassName),DOCREATE) #define ODRX_VALIDATION_CONS_DEFINE_MEMBERS_ALTNAME(ClassName,ParentClass,szClassName,DOCREATE) \ \ ODRX_VALIDATION_DEFINE_MEMBERS2(ClassName,ParentClass,ClassName::pseudoConstructor,0,0,0,szClassName,OdString::kEmpty,OdString::kEmpty,0) \ \ ODRX_DEFINE_PSEUDOCONSTRUCTOR(ClassName,DOCREATE) #define ODRX_VALIDATION_DEFINE_MEMBERS2(ClassName,ParentClass,pseudoConsFn,DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags) \ \ ODRX_DEFINE_RTTI_MEMBERS(ClassName,ParentClass) \ \ ODRX_VALIDATION_DEFINE_INIT_MEMBERS(ClassName,ParentClass,pseudoConsFn, \ DwgVer,MaintVer,nProxyFlags,szDWGClassName,szDxfName,szAppName,nCustomFlags,0,0) #define ODRX_VALIDATION_DEFINE_INIT_MEMBERS(ClassName, ParentClass, pseudoConsFn, DwgVer, \ MaintVer, nProxyFlags, szDWGClassName, \ szDxfName, szAppName, nCustomFlags, pMemberCreate, pUserData) \ ODRX_VALIDATION_DEFINE_INIT_MEMBERS_GENERIC( \ ClassName, \ (::newOdRxClass(szDWGClassName, ParentClass::desc(), pseudoConsFn, DwgVer, \ MaintVer, nProxyFlags, szDxfName, szAppName, NULL, nCustomFlags, pMemberCreate, pUserData)), \ (::newOdRxClass(szDWGClassName, ParentClass::desc(), pseudoConsFn, DwgVer, \ MaintVer, nProxyFlags, szDxfName, szAppName, pAppNameChangeCallback, nCustomFlags, pMemberCreate, pUserData))) #define ODRX_VALIDATION_DEFINE_INIT_MEMBERS_GENERIC(ClassName, CREATE_CLASS_INSTANCE, CREATE_CLASS_INSTANCE2) \ \ /* Registers this class with Teigha. */ \ void ClassName::rxInit(OdDAI::ValidationTasksHolder& tasksHolder) \ { \ if (!ClassName::g_pDesc) { \ ClassName::g_pDesc = CREATE_CLASS_INSTANCE; \ tasksHolder.addValidationTask(ClassName::desc()); \ } else { \ ODA_ASSERT(("Class ["#ClassName"] is already initialized.",0)); \ throw OdError(eExtendedError); \ } \ } \ \ /* Unregisters this class with Teigha. */ \ void ClassName::rxUninit(OdDAI::ValidationTasksHolder& tasksHolder) \ { \ if (ClassName::g_pDesc) { \ tasksHolder.removeValidationTask(ClassName::desc()); \ ::deleteOdRxClass(ClassName::g_pDesc); \ ClassName::g_pDesc = 0; \ } else { \ ODA_ASSERT(("Class ["#ClassName"] is not initialized yet.",0)); \ throw OdError(eNotInitializedYet); \ } \ } #include "TD_PackPop.h" #endif // _DAI_VALIDATION_COMMON_H_