Changes between Version 17 and Version 18 of ValidationSimple
- Timestamp:
- Oct 9, 2011, 10:21:15 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ValidationSimple
v17 v18 1 1 = Developing a custom validator = 2 To create a validator using the BOINC framework, you must supply three functions: 2 3 3 To create a validator using the BOINC framework, you must supply three functions:4 4 {{{ 5 5 extern int init_result(RESULT& result, void*& data); 6 6 }}} 7 This takes a result, reads its output file(s), parses them into a memory structure, 8 and returns (via the 'data' argument) a pointer to this structure. 9 It returns: 7 This takes a result, reads its output file(s), parses them into a memory structure, and returns (via the 'data' argument) a pointer to this structure. It returns: 10 8 11 9 * Zero on success, 12 * ERR_OPENDIR if there was a transient error, e.g. the output file is on a network volume that is not available. 13 The validator will try this result again later. 14 * Any other return value indicates a permanent error. 15 Example: an output file is missing, or has a syntax error. 16 The result will be marked as invalid. 10 * ERR_OPENDIR if there was a transient error, e.g. the output file is on a network volume that is not available. The validator will try this result again later. 11 * Any other return value indicates a permanent error. Example: an output file is missing, or has a syntax error. The result will be marked as invalid. 17 12 18 13 {{{ … … 21 16 ); 22 17 }}} 23 This takes two results and their associated memory structures. 24 It returns (via the 'match' argument) true if the two results are equivalent (within the tolerances of the application). 18 This takes two results and their associated memory structures. It returns (via the 'match' argument) true if the two results are equivalent (within the tolerances of the application). 19 25 20 {{{ 26 21 extern int cleanup_result(RESULT& r, void* data); … … 28 23 This frees the structure pointed to by data, if it's non-NULL. 29 24 30 You must link these functions with the files validator.cpp, validate_util.cpp, and validate_util2.cpp. 31 The result is your custom validator. 25 You must link these functions with the files validator.cpp, validate_util.cpp, and validate_util2.cpp. The result is your custom validator. 32 26 33 27 If for some reason you need to access the WORKUNIT in your init_result() etc. functions: 28 34 29 {{{ 35 30 DB_WORKUNIT wu; 36 wu.lookup_id( g_wup->id);31 wu.lookup_id(result->id); 37 32 }}} 33 == Example == 34 Here's an example in which the output file contains an integer and a double. Two results are considered equivalent if the integer is equal and the doubles differ by no more than 0.01. 38 35 39 == Example == 36 This example uses [wiki:BackendUtilities utility functions] get_output_file_path() and try_fopen(). 40 37 41 Here's an example in which the output file contains an integer and a double.42 Two results are considered equivalent if the integer is equal and the doubles differ by no more than 0.01.43 44 This example uses [BackendUtilities utility functions] get_output_file_path() and try_fopen().45 38 {{{ 46 39 #include <string>