source: branches/uq/src/objects/RpBoolean.cc @ 5679

Last change on this file since 5679 was 5679, checked in by ldelgass, 9 years ago

Full merge 1.3 branch to uq branch to sync. Fixed partial subdirectory merge
by removing mergeinfo from lang/python/Rappture directory.

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  Rappture 2.0 Boolean Object Source
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick Kearney, Purdue University
7 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
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
17using namespace Rappture;
18
19Boolean::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
30Boolean::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
46Boolean::Boolean ( const Boolean& o )
47    :   Object(o)
48{
49    this->def(o.def());
50    this->cur(o.cur());
51
52}
53
54// default destructor
55Boolean::~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
66const char *
67Boolean::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
99const int
100Boolean::is() const
101{
102    // return "bool" in hex
103    return 0x626F6F6C;
104}
105
106// -------------------------------------------------------------------- //
Note: See TracBrowser for help on using the repository browser.