1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * RpBoolean - Rappture 2.0 About XML object |
---|
4 | * |
---|
5 | * ====================================================================== |
---|
6 | * AUTHOR: Derrick Kearney, Purdue University |
---|
7 | * Copyright (c) 2004-2005 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 | |
---|
16 | /**********************************************************************/ |
---|
17 | // METHOD: setDefaultValue() |
---|
18 | /// Set the default value of this object |
---|
19 | /** |
---|
20 | */ |
---|
21 | |
---|
22 | RpBoolean& |
---|
23 | RpBoolean::setDefaultValue(std::string newDefaultVal) |
---|
24 | { |
---|
25 | std::string* def = NULL; |
---|
26 | |
---|
27 | def = (std::string*) RpVariable::getDefaultValue(); |
---|
28 | |
---|
29 | if (!def) { |
---|
30 | RpVariable::setDefaultValue(new std::string (newDefaultVal)); |
---|
31 | } |
---|
32 | else { |
---|
33 | *def = newDefaultVal; |
---|
34 | } |
---|
35 | |
---|
36 | return *this; |
---|
37 | } |
---|
38 | |
---|
39 | /**********************************************************************/ |
---|
40 | // METHOD: setCurrentValue() |
---|
41 | /// Set the current value of this object. |
---|
42 | /** |
---|
43 | */ |
---|
44 | |
---|
45 | RpBoolean& |
---|
46 | RpBoolean::setCurrentValue(std::string newCurrentVal) |
---|
47 | { |
---|
48 | std::string* cur = (std::string*) RpVariable::getCurrentValue(); |
---|
49 | std::string* def = (std::string*) RpVariable::getDefaultValue(); |
---|
50 | |
---|
51 | if (cur == def) { |
---|
52 | RpVariable::setCurrentValue(new std::string (newCurrentVal)); |
---|
53 | } |
---|
54 | else { |
---|
55 | *cur = newCurrentVal; |
---|
56 | } |
---|
57 | |
---|
58 | return *this; |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | /**********************************************************************/ |
---|
63 | // METHOD: getDefaultValue() |
---|
64 | /// Report the default value of this object. |
---|
65 | /** |
---|
66 | */ |
---|
67 | |
---|
68 | std::string |
---|
69 | RpBoolean::getDefaultValue(void* null_val) const |
---|
70 | { |
---|
71 | return *((std::string*) RpVariable::getDefaultValue()); |
---|
72 | } |
---|
73 | |
---|
74 | /**********************************************************************/ |
---|
75 | // METHOD: getCurrentValue() |
---|
76 | /// Report the current value of this object. |
---|
77 | /** |
---|
78 | */ |
---|
79 | |
---|
80 | std::string |
---|
81 | RpBoolean::getCurrentValue(void* null_val) const |
---|
82 | { |
---|
83 | return *((std::string*) RpVariable::getCurrentValue()); |
---|
84 | } |
---|
85 | |
---|
86 | // -------------------------------------------------------------------- // |
---|
87 | |
---|