/* * getFlatListFromHierarchyOfValidators.hpp * * Created on: Sep 7, 2014 * Author: heber */ #ifndef GETFLATLISTFROMHIERARCHYOFVALIDATORS_HPP_ #define GETFLATLISTFROMHIERARCHYOFVALIDATORS_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include "Parameters/Validators/Validator.hpp" #include "Parameters/Validators/Ops_Validator.hpp" template void ValidatorHierarchyClimber( const Validator &_validator, std::vector *, bool> > &_validators, const bool _groundtruth) { if (dynamic_cast *>(&_validator) != NULL) { const And_Validator& and_validator = dynamic_cast& >(_validator); ValidatorHierarchyClimber(*and_validator.getA(), _validators, _groundtruth); ValidatorHierarchyClimber(*and_validator.getB(), _validators, _groundtruth); } else if (dynamic_cast *>(&_validator) != NULL) { const Or_Validator& or_validator = dynamic_cast& >(_validator); ValidatorHierarchyClimber(*or_validator.getA(), _validators, _groundtruth); ValidatorHierarchyClimber(*or_validator.getB(), _validators, _groundtruth); } else if (dynamic_cast *>(&_validator) != NULL) { const Not_Validator& not_validator = dynamic_cast& >(_validator); ValidatorHierarchyClimber(*not_validator.getA(), _validators, !_groundtruth); } else if (dynamic_cast *>(&_validator) != NULL) { const Validator * Tvalidator = dynamic_cast * >(&_validator); _validators.push_back( std::make_pair(Tvalidator, _groundtruth) ); } } /** Function that recursively climbs down the hierarchy of validators and adds all * to a common vector as tuples of validator and a boolean, giving the ground truth * of the validator, i.e. whether it was negated by a prior Not_Validator. */ template std::vector *, bool> > getFlatListFromHierarchyOfValidators(const Validator &_validator) { std::vector *, bool> > validators; ValidatorHierarchyClimber(_validator, validators, true); return validators; } #endif /* GETFLATLISTFROMHIERARCHYOFVALIDATORS_HPP_ */