1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * Rappture 2.0 Boolean Object Source |
---|
4 | * |
---|
5 | * ====================================================================== |
---|
6 | * AUTHOR: Derrick Kearney, Purdue University |
---|
7 | * Copyright (c) 2005-2009 Purdue Research Foundation |
---|
8 | * |
---|
9 | * See the file "license.terms" for information on usage and |
---|
10 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
11 | * ====================================================================== |
---|
12 | */ |
---|
13 | |
---|
14 | #include "RpBoolean.h" |
---|
15 | #include "RpUnits.h" |
---|
16 | |
---|
17 | using namespace Rappture; |
---|
18 | |
---|
19 | Boolean::Boolean ( |
---|
20 | const char *path, |
---|
21 | int val |
---|
22 | ) |
---|
23 | : Object () |
---|
24 | { |
---|
25 | this->path(path); |
---|
26 | this->def(val); |
---|
27 | this->cur(val); |
---|
28 | } |
---|
29 | |
---|
30 | Boolean::Boolean ( |
---|
31 | const char *path, |
---|
32 | int val, |
---|
33 | const char *label, |
---|
34 | const char *desc |
---|
35 | ) |
---|
36 | : Object () |
---|
37 | { |
---|
38 | this->path(path); |
---|
39 | this->label(label); |
---|
40 | this->desc(desc); |
---|
41 | this->def(val); |
---|
42 | this->cur(val); |
---|
43 | } |
---|
44 | |
---|
45 | // copy constructor |
---|
46 | Boolean::Boolean ( const Boolean& o ) |
---|
47 | : Object(o) |
---|
48 | { |
---|
49 | this->def(o.def()); |
---|
50 | this->cur(o.cur()); |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | // default destructor |
---|
55 | Boolean::~Boolean () |
---|
56 | { |
---|
57 | } |
---|
58 | |
---|
59 | /**********************************************************************/ |
---|
60 | // METHOD: xml() |
---|
61 | /// view this object's xml |
---|
62 | /** |
---|
63 | * View this object as an xml element returned as text. |
---|
64 | */ |
---|
65 | |
---|
66 | const char * |
---|
67 | Boolean::xml(size_t indent, size_t tabstop) |
---|
68 | { |
---|
69 | size_t l1width = indent + tabstop; |
---|
70 | size_t l2width = indent + (2*tabstop); |
---|
71 | const char *sp = ""; |
---|
72 | |
---|
73 | Path p(path()); |
---|
74 | _tmpBuf.clear(); |
---|
75 | |
---|
76 | // FIXME: boolean should print yes/no |
---|
77 | |
---|
78 | _tmpBuf.appendf( |
---|
79 | "%9$*6$s<boolean id=\"%1$s\">\n\ |
---|
80 | %9$*7$s<about>\n\ |
---|
81 | %9$*8$s<label>%2$s</label>\n\ |
---|
82 | %9$*8$s<description>%3$s</description>\n\ |
---|
83 | %9$*7$s</about>\n\ |
---|
84 | %9$*7$s<default>%4$i</default>\n\ |
---|
85 | %9$*7$s<current>%5$i</current>\n\ |
---|
86 | %9$*6$s</boolean>", |
---|
87 | p.id(),label(),desc(),def(),cur(),indent,l1width,l2width,sp); |
---|
88 | |
---|
89 | return _tmpBuf.bytes(); |
---|
90 | } |
---|
91 | |
---|
92 | /**********************************************************************/ |
---|
93 | // METHOD: is() |
---|
94 | /// what kind of object is this |
---|
95 | /** |
---|
96 | * return hex value telling what kind of object this is. |
---|
97 | */ |
---|
98 | |
---|
99 | const int |
---|
100 | Boolean::is() const |
---|
101 | { |
---|
102 | // return "bool" in hex |
---|
103 | return 0x626F6F6C; |
---|
104 | } |
---|
105 | |
---|
106 | // -------------------------------------------------------------------- // |
---|