source: trunk/examples/objects/curve/curve.cc @ 1560

Last change on this file since 1560 was 1560, checked in by dkearney, 15 years ago

updates to the object system, fixed up tree and xml parser objects, added some basic tests for them and adopted number object to accept xml text and configure itself from the parsed xml. added fermi3.cc example program which contains suggested interface from apps meeting.

File size: 1.9 KB
Line 
1#include <iostream>
2#include "RpCurve.h"
3
4size_t indent = 0;
5size_t tabstop = 4;
6
7int test(
8    const char *testname,
9    const char *desc,
10    const char *expected,
11    const char *received)
12{
13    if (strcmp(expected,received) != 0) {
14        printf("Error: %s\n", testname);
15        printf("\t%s\n", desc);
16        printf("\texpected \"%s\"\n",expected);
17        printf("\treceived \"%s\"\n",received);
18        return 1;
19    }
20    return 0;
21}
22
23int
24printCurve(Rappture::Curve *n)
25{
26    std::cout << "path: " << n->path() << std::endl;
27    std::cout << "label: " << n->label() << std::endl;
28    std::cout << "desc: " << n->desc() << std::endl;
29    std::cout << "group: " << n->group() << std::endl;
30    std::cout << "dims: " << n->dims() << std::endl;
31
32    const Rappture::Array1D *a = NULL;
33
34    for (size_t i = 0; i < n->dims(); i++) {
35        a = n->getNthAxis(i);
36        std::cout << "a[" << i << "] = " << a->label() << std::endl;
37    }
38
39    std::cout << "xml: " << n->xml(indent,tabstop) << std::endl;
40    return 0;
41}
42
43int curve_0_0 ()
44{
45    const char *desc = "test basic constructor";
46    const char *testname = "curve_0_0";
47
48    const char *expected = "output.curve(myid)";
49    const char *received = NULL;
50
51    Rappture::Curve c(expected);
52    received = c.path();
53
54    return test(testname,desc,expected,received);
55}
56
57int main()
58{
59    Rappture::Curve *n = NULL;
60    double x[] = {1,2,3,4,5,6,7,8,9,10};
61    double z[] = {1,2,3,4,5,6,7,8,9,10};
62    double y[] = {1,4,9,16,25,36,49,64,91,100};
63
64    n = new Rappture::Curve("output.curve(temperature)","mylabel",
65                            "mydesc","mygroup");
66
67    n->axis("xaxis","xlabel","xdesc","xunits","xscale",x,10);
68    n->axis("yaxis","ylabel","ydesc","yunits","yscale",y,10);
69    n->axis("zaxis","zlabel","zdesc","zunits","zscale",z,10);
70    printCurve(n);
71    n->delAxis("zlabel");
72    n->delAxis("xzylabel");
73    printCurve(n);
74
75    delete n;
76    return 0;
77}
Note: See TracBrowser for help on using the repository browser.