以下は JE2BWM ほかが作成した翻訳 です。 原文は University of California より GFDL で配付されており、 この翻訳も GFDL に従います。
原文: Simple validator framework [deprecated: SimpleValidation]   (翻訳対象の更新日付は 8:03 PM UTC, April 23 2007 です)。

単純なバリデータ用の雛形(旧い文書です)

boinc.gif
(英語のみ)

 

翻訳準備中

 

To create a validator using the simple framework, you must supply four functions:
extern int init_result(RESULT& result, void*& data);
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:
extern int compare_results(
    RESULT& r1, void* data1, RESULT& r2, void* data2, bool& match
);
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).
extern int cleanup_result(RESULT& r, void* data);
This frees the structure pointed to by data, if it's non-NULL.
extern double compute_granted_credit(WORKUNIT&, vector<RESULT>& results);
Given a set of results (at least one of which is valid) compute the credit to be granted to all of them. Normally this function simply returns median_mean_credit(results). If credit is specified in the workunit, call get_credit_from_wu().

You must link these functions with the files validator.C, validate_util.C, and validate_util2.C. The result is your custom validator.

Example

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.

This example uses utility functions get_output_file_path() and try_fopen(), which are documented here.

struct DATA {
    int i;
    double x;
};

int init_result(RESULT const & result, void*& data) {
    FILE* f;
    string path;
    int i, n, retval;
    double x;

    retval = get_output_file_path(result, path);
    if (retval) return retval;
    retval = try_fopen(path.c_str(), f, "r");
    if (retval) return retval;
    n = fscanf(f, "%d %f", &i, &x);
    if (n != 2) return ERR_XML_PARSE;
    DATA* dp = new DATA;
    dp->i = i;
    dp->x = x;
    data = (void*) dp;
    return 0;
}

int compare_results(
    RESULT& r1, void* _data1, RESULT const& r2, void* _data2, bool& match
) {
    DATA* data1 = (DATA*)_data1;
    DATA* data2 = (DATA*)_data2;
    match = true;
    if (data1->i != data2->i) match = false;
    if (fabs(data1->x - data2->x) > 0.01) match = false;
    return 0;
}

int cleanup_result(RESULT& r, void* data) {
    if (data) delete (DATA*) data;
    return 0;
}

double compute_granted_credit(WORKUNIT&, vector& results) {
    return median_mean_credit(results);
}

BOINCの訳のメインページに戻る | (原文のメインページに戻る)
 

最終更新時刻 14:59:14, 2007年05月19日(JST)
Copyright © 2009 University of California. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
Copyright © 2009 Komori Hitoshi(je2bwm at jarl.com). Japanese translation from English web pages on BOINC. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.