///////////////////////////////////////////////////////////////////////////////
// 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_VALIDATOR_H
#define _DAI_VALIDATOR_H
#include "OdaCommon.h"
#define STL_USING_MAP
#include "OdaSTL.h"
#include "OdPerfTimer.h"
#include "daiInstanceValidationTask.h"
#include "daiModelValidationTask.h"
#include "daiExtentValidationTask.h"
#include "daiValidationNotifier.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
{
/** \details
A class that implements functionality of work with .
*/
class DAI_EXPORT Validator : public OdRxObject
{
//DOM-IGNORE-BEGIN
ODRX_DECLARE_MEMBERS(Validator);
//DOM-IGNORE-END
public:
/** \details
Defines types of validation results which notifier objects show.
*/
enum PrintingResult
{
/**Validations that finished with an error.*/
kError = 0x0001,
/**Validations with unknown result.*/
kUnknown = 0x0002,
/**Validations with unset result.*/
kUnset = 0x0004,
/**Validation check successfully passed.*/
kOk = 0x0008,
/**Validations that didn't pass.*/
kNotOk = kError | kUnknown | kUnset,
/**All validation results.*/
kAll = kError | kUnknown | kUnset | kOk
};
/** \details
Defines validation types to be checked.
*/
enum ValidationType
{
/**Validation of instances.*/
kInstancesValidation = 0x0001,
/**Validation of a model*/
kModelValidation = 0x0002,
/**Validation of extents.*/
kExtentsValidation = 0x0004,
/**All types of validation.*/
kFullValidation = kInstancesValidation | kModelValidation | kExtentsValidation
};
/** \details
Creates a new validator associated with a specified object.
\param validationContext [in] A smart pointer to the object.
\param pSevices [in] A raw pointer to an object that implements platform specific operation for Data Access Interface.
\param createTimer [in] A flag that determines whether the validation timer is created when a new validator is created (equals true) or not (equals false).
\returns A smart pointer to the created validator.
*/
static OdSmartPtr createObject(OdDAI::InstanceValidationContextPtr &validationContext, OdDAIHostAppServicesBase* pSevices, bool createTimer = false);
/** \details
Creates a new validator with default parameters.
*/
Validator();
/** \details
Sets the progress meter for the validator object.
\param progressMeter [in] A raw pointer to the progress meter object.
*/
void setProgressMeter(OdDbHostAppProgressMeter* progressMeter);
/** \details
Sets the shown by the notifier object.
\param printingResult [in] A .
*/
void setPrintingResult(PrintingResult printingResult);
/** \details
Sets the list of to execute.
\param tasksList [in] The list of smart pointers to class instances.
*/
void setInstanceTasks(std::list tasksList);
/** \details
Adds a new to the list of validation tasks.
\param task [in] A raw pointer to the .
*/
void addInstanceTask(InstanceValidationTask* task);
/** \details
Removes all .
*/
void clearInstanceTasks();
/** \details
Retrieves the number of associated with the validator.
\returns An integer value that contains the number of .
*/
int instanceTasksCount();
/** \details
Sets the list of to execute.
\param tasksList [in] The list of smart pointers to objects.
*/
void setModelTasks(std::list tasksList);
/** \details
Adds a new to the list of validation tasks.
\param task [in] A raw pointer to the .
*/
void addModelTask(ModelValidationTask* task);
/** \details
Removes all .
*/
void clearModelTasks();
/** \details
Retrieves the number of associated with the validator.
\returns An integer value that contains the number of .
*/
int modelTasksCount();
/** \details
Sets the list of to execute.
\param tasksList [in] The list of smart pointers to objects.
*/
void setExtentTasks(std::list tasksList);
/** \details
Adds a new to the list of validation tasks.
\param task [in] A raw pointer to the .
*/
void addExtentTask(ExtentValidationTask* task);
/** \details
Removes all .
*/
void clearExtentTasks();
/** \details
Retrieves the number of associated with the validator.
\returns An integer value that contains the number of .
*/
int extentTasksCount();
/** \details
Adds a new , or validation task to the list of validation tasks.
\param task [in] A raw pointer to the .
*/
void addValidationTask(ValidationTask* task);
/** \details
Removes all , or validation tasks.
*/
void clearValidationTasks();
/** \details
Sets the list of .
\param tasksList [in] The list of smart pointers to the objects.
*/
void setNotifiers(std::list tasksList);
/** \details
Adds a new to the list of notifiers.
\param task [in] A raw pointer to the .
*/
void addNotifier(ValidationNotifier* task);
/** \details
Removes all .
*/
void clearNotifiers();
/** \details
Sets the to run.
\param validationType [in] A value.
*/
void setValidationType(ValidationType validationType);
/** \details
Starts execution of assigned to the validator object.
*/
void run();
/** \details
Retrieves the current value of the healing flag.
When this flag equals to true, the validation task object tries to heal found validation errors (if the object has an appropriated healer class).
\returns true if the healing of the validation errors is enabled; otherwise, the method returns false.
*/
bool isHealingEnable();
/** \details
Sets a new value of the healing flag.
When this flag equals to true, the validation task object tries to heal found validation errors (if the object has an appropriated healer class).
Otherwise, this flag equals to false.
\param healingEnable [in] A new value of the flag.
*/
void setHealingEnable(bool healingEnable);
/** \details
Sets a new for all .
\param pCtx [in] A smart pointer to the new object.
*/
//void setContext(InstanceValidationContextPtr pCtx);
/** \details
Retrieves the current time in milliseconds the timer has been started (if the timer is active); if the timer has been stopped, the method retrieves the final validation time.
\returns An unsigned long that contains time in milliseconds.
*/
unsigned long timerValue();
private:
void modelValidation();
void instancesValidation();
void extentsValidation();
OdDbHostAppProgressMeter* m_progressMeter;
OdSharedPtr m_timer;
bool m_healingEnable;
ValidationType m_validationType;
std::set m_printingResults;
std::list m_instanceValidationTasks;
std::list m_modelValidationTasks;
std::map > m_extentValidationTask;
std::list m_validationNotifiers;
InstanceValidationContextPtr m_validationContext;
OdDAIHostAppServicesBase* m_pServices;
};
/** \details
A data type that represents a smart pointer to an object.
*/
typedef OdSmartPtr ValidatorPtr;
}
#include "TD_PackPop.h"
#endif // _DAI_VALIDATOR_H