ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
iprm::IParamsSetValidator Class Referenceabstract

Interface for consistency checking of a parameter set. More...

#include <IParamsSetValidator.h>

Inheritance diagram for iprm::IParamsSetValidator:
istd::IPolymorphic

Public Types

typedef QSet< QByteArray > Ids
 

Public Member Functions

virtual Ids GetSupportedTypeIds () const =0
 Get list of parameter type IDs which can be checked by the validator.
 
virtual bool IsParamsSetConsistent (const QByteArray &validationContextId, const IParamsSet &paramsSet, ilog::IMessageConsumer *validationMessagesConsumerPtr=NULL) const =0
 Return true if the parameter set is consistent, false otherwise.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Detailed Description

Interface for consistency checking of a parameter set.

IParamsSetValidator provides validation functionality for parameter sets, ensuring that parameters meet required constraints and business rules before processing or persistence.

Validators can check:

Usage Example

#include <ilog/CMessageConsumer.h>
// Assuming validator is obtained from a component or factory
// Get supported type IDs
qDebug() << "Validator supports" << supportedTypes.size() << "type(s)";
for (const QByteArray& typeId : supportedTypes)
{
qDebug() << " - Type:" << typeId;
}
// Validate a parameter set
iprm::IParamsSet* paramsSet;
QByteArray validationContext = "save_operation";
// Create message consumer to collect validation messages
ilog::CMessageConsumer messageConsumer;
// Perform validation
bool isValid = validator->IsParamsSetConsistent(
validationContext,
*paramsSet,
&messageConsumer);
if (isValid)
{
qDebug() << "Parameter set is valid";
// Proceed with save or processing
}
else
{
qDebug() << "Validation failed";
// Handle validation errors
// Check messageConsumer for detailed error messages
}
Set of general parameters.
Definition IParamsSet.h:81
Interface for consistency checking of a parameter set.
virtual bool IsParamsSetConsistent(const QByteArray &validationContextId, const IParamsSet &paramsSet, ilog::IMessageConsumer *validationMessagesConsumerPtr=NULL) const =0
Return true if the parameter set is consistent, false otherwise.
virtual Ids GetSupportedTypeIds() const =0
Get list of parameter type IDs which can be checked by the validator.

Context-Specific Validation

Different validation contexts can have different rules:

// Validate for saving (strict rules)
bool validForSave = validator->IsParamsSetConsistent(
"save_context",
*paramsSet,
&messageConsumer);
// Validate for preview (relaxed rules)
bool validForPreview = validator->IsParamsSetConsistent(
"preview_context",
*paramsSet,
nullptr); // No detailed messages needed
if (validForSave)
{
SaveParameterSet(paramsSet);
}
else if (validForPreview)
{
ShowPreview(paramsSet);
}
Note
Validators should be stateless for thread-safety.
Multiple validators can be combined for different parameter types.
See also
IParamsSet, ilog::IMessageConsumer

Definition at line 106 of file IParamsSetValidator.h.

Member Typedef Documentation

◆ Ids

typedef QSet<QByteArray> iprm::IParamsSetValidator::Ids

Definition at line 109 of file IParamsSetValidator.h.

Member Function Documentation

◆ GetSupportedTypeIds()

virtual Ids iprm::IParamsSetValidator::GetSupportedTypeIds ( ) const
pure virtual

Get list of parameter type IDs which can be checked by the validator.

Returns the set of parameter set type identifiers that this validator can validate. This allows routing different parameter set types to appropriate validators.

Returns
Set of QByteArray type IDs supported by this validator.
validator->GetSupportedTypeIds();
QByteArray paramSetType = "algorithm_params";
if (supportedTypes.contains(paramSetType))
{
qDebug() << "Validator can check this type";
bool isValid = validator->IsParamsSetConsistent(
"default", *paramsSet, nullptr);
}
else
{
qDebug() << "Need a different validator";
}
See also
IsParamsSetConsistent

◆ IsParamsSetConsistent()

virtual bool iprm::IParamsSetValidator::IsParamsSetConsistent ( const QByteArray &  validationContextId,
const IParamsSet paramsSet,
ilog::IMessageConsumer validationMessagesConsumerPtr = NULL 
) const
pure virtual

Return true if the parameter set is consistent, false otherwise.

Validates a parameter set against constraints and business rules. Optionally, detailed validation messages can be collected through a message consumer.

Parameters
validationContextIdID identifying the validation context. Different contexts may apply different validation rules (e.g., "save", "execute", "preview").
paramsSetParameter set to be validated.
validationMessagesConsumerPtrOptional consumer for validation messages. If provided, detailed error/warning messages will be sent to it. Can be NULL if messages aren't needed.
Returns
true if parameter set is consistent and passes validation, false if validation failed.
Note
When validation fails, check validationMessagesConsumerPtr for detailed error messages if one was provided.
The same parameter set may be valid in one context and invalid in another.
ilog::CMessageConsumer messageConsumer;
bool isValid = validator->IsParamsSetConsistent(
"save_operation",
*paramsSet,
&messageConsumer);
if (!isValid)
{
qDebug() << "Validation failed:";
// Process messages from messageConsumer
// Messages contain details about what failed
}
See also
GetSupportedTypeIds, ilog::IMessageConsumer

The documentation for this class was generated from the following file: