~ubuntu-branches/ubuntu/lucid/boinc/lucid

« back to all changes in this revision

Viewing changes to doc/validate_simple.php

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
 
3
 
require_once("docutil.php");
4
 
page_head("Simple validator framework [deprecated: SimpleValidation]");
5
 
echo "
6
 
To create a validator using the simple framework,
7
 
you must supply four functions:
8
 
"; block_start(); echo "
9
 
extern int init_result(RESULT& result, void*& data);
10
 
"; block_end(); echo "
11
 
This takes a result, reads its output file(s),
12
 
parses them into a memory structure,
13
 
and returns (via the 'data' argument) a pointer to this structure.
14
 
It returns:
15
 
<ul>
16
 
<li> Zero on success,
17
 
<li> ERR_OPENDIR if there was a transient error,
18
 
e.g. the output file is on a network volume that is not available.
19
 
The validator will try this result again later.
20
 
<li> Any other return value indicates a permanent error.
21
 
Example: an output file is missing, or has a syntax error.
22
 
The result will be marked as invalid.
23
 
</ul>
24
 
"; block_start(); echo "
25
 
extern int compare_results(
26
 
    RESULT& r1, void* data1, RESULT& r2, void* data2, bool& match
27
 
);
28
 
"; block_end(); echo "
29
 
This takes two results and their associated memory structures.
30
 
It returns (via the 'match' argument) true if the two results
31
 
are equivalent (within the tolerances of the application).
32
 
"; block_start(); echo "
33
 
extern int cleanup_result(RESULT& r, void* data);
34
 
"; block_end(); echo "
35
 
This frees the structure pointed to by data, if it's non-NULL.
36
 
"; block_start(); echo "
37
 
extern double compute_granted_credit(WORKUNIT&, vector&lt;RESULT>& results);
38
 
"; block_end(); echo "
39
 
Given a set of results (at least one of which is valid)
40
 
compute the credit to be granted to all of them.
41
 
Normally this function simply returns
42
 
<code>median_mean_credit(results)</code>.
43
 
If credit is <a href=tools_work.php>specified in the workunit</a>,
44
 
call <code>get_credit_from_wu()</code>.
45
 
<p>
46
 
You must link these functions with the files
47
 
validator.C, validate_util.C, and validate_util2.C.
48
 
The result is your custom validator.
49
 
 
50
 
<h3>Example</h3>
51
 
Here's an example in which the output file
52
 
contains an integer and a double.
53
 
Two results are considered equivalent if the integer is equal
54
 
and the doubles differ by no more than 0.01.
55
 
<p>
56
 
This example uses utility functions
57
 
get_output_file_path() and try_fopen(),
58
 
which are documented <a href=backend_util.php>here</a>.
59
 
"; block_start(); echo "
60
 
struct DATA {
61
 
    int i;
62
 
    double x;
63
 
};
64
 
 
65
 
int init_result(RESULT const & result, void*& data) {
66
 
    FILE* f;
67
 
    string path;
68
 
    int i, n, retval;
69
 
    double x;
70
 
 
71
 
    retval = get_output_file_path(result, path);
72
 
    if (retval) return retval;
73
 
    retval = try_fopen(path.c_str(), f, \"r\");
74
 
    if (retval) return retval;
75
 
    n = fscanf(f, \"%d %f\", &i, &x);
76
 
    if (n != 2) return ERR_XML_PARSE;
77
 
    DATA* dp = new DATA;
78
 
    dp->i = i;
79
 
    dp->x = x;
80
 
    data = (void*) dp;
81
 
    return 0;
82
 
}
83
 
 
84
 
int compare_results(
85
 
    RESULT& r1, void* _data1, RESULT const& r2, void* _data2, bool& match
86
 
) {
87
 
    DATA* data1 = (DATA*)_data1;
88
 
    DATA* data2 = (DATA*)_data2;
89
 
    match = true;
90
 
    if (data1->i != data2->i) match = false;
91
 
    if (fabs(data1->x - data2->x) > 0.01) match = false;
92
 
    return 0;
93
 
}
94
 
 
95
 
int cleanup_result(RESULT& r, void* data) {
96
 
    if (data) delete (DATA*) data;
97
 
    return 0;
98
 
}
99
 
 
100
 
double compute_granted_credit(WORKUNIT&, vector<RESULT>& results) {
101
 
    return median_mean_credit(results);
102
 
}
103
 
 
104
 
"; block_end(); echo "
105
 
";
106
 
page_tail();
107
 
?>