source: trunk/src/objects/RpObject.h @ 1586

Last change on this file since 1586 was 1586, checked in by dkearney, 11 years ago

updating potential apis for c cpp and python. adding random() and diff()
functions to the rappture objects. objects should be able to generate a random
value for itself based on how it was configured. objects should be able to
compare itself with another object and tell us what the differences are.

File size: 3.7 KB
Line 
1/*
2 * ======================================================================
3 *  AUTHOR:  Derrick S. Kearney, Purdue University
4 *  Copyright (c) 2005-2009  Purdue Research Foundation
5 *
6 *  See the file "license.terms" for information on usage and
7 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8 * ======================================================================
9 */
10
11#ifndef RAPPTURE_OBJECT_H
12#define RAPPTURE_OBJECT_H
13
14#include "RpInt.h"
15#include "RpHash.h"
16#include "RpOutcome.h"
17#include "RpAccessor.h"
18#include "RpBuffer.h"
19#include "RpPath.h"
20#include "RpParserXML.h"
21#include "RpObjConfig.h"
22#include <cstdarg>
23
24namespace Rappture {
25
26class Object
27{
28    public:
29        Object ();
30        Object (const char *name,
31                const char *path,
32                const char *label,
33                const char *desc,
34                const char *hints,
35                const char *color);
36        Object (const Object& o);
37        virtual ~Object();
38
39        const char *name(void) const;
40        void name(const char *p);
41
42        const char *path(void) const;
43        void path(const char *p);
44
45        const char *label(void) const;
46        void label(const char *p);
47
48        const char *desc(void) const;
49        void desc(const char *p);
50
51        const char *hints(void) const;
52        void hints(const char *p);
53
54        const char *color(void) const;
55        void color(const char *p);
56
57        // void *icon(void) const;
58        // void icon(void *p, size_t nbytes);
59
60        // these functions are not completely improper use proof
61        // user is responsible for calling propremove() on any item
62        // they put into the hash table.
63
64        // get/set void* property
65        const void *property(const char *key) const;
66        void property(const char *key, const void *val, size_t nbytes);
67
68        // get/set const char * property
69        const char *propstr(const char *key) const;
70        void propstr(const char *key, const char *val);
71
72        // remove property from hash table
73        void propremove (const char *key);
74
75        // return the value of object based on provided hints
76        virtual void vvalue(void *storage, size_t numHints, va_list arg) const;
77        // populate the object with a random value
78        virtual void random();
79        // return the difference between this object and o
80        virtual Rp_Chain *diff(const Object& o);
81
82        // get the Rappture1.1 xml text for this object
83        // virtual const char *xml(size_t indent, size_t tabstop) const;
84
85        // configure the object properties based on Rappture1.1 xml text
86        virtual void configure(size_t as, ClientData c);
87        virtual void dump(size_t as, ClientData c);
88
89        virtual Outcome &outcome() const;
90        virtual const int is() const;
91
92    protected:
93
94        /// temprorary buffer for returning text to the user
95        SimpleCharBuffer _tmpBuf;
96
97        /// status of the object
98        mutable Rappture::Outcome _status;
99
100        virtual void __hintParser(char *hint,
101            const char **hintKey, const char **hintVal) const;
102
103        virtual void __configureFromXml(ClientData c);
104        virtual void __configureFromTree(ClientData c);
105        virtual void __dumpToXml(ClientData c);
106        virtual void __dumpToTree(ClientData c);
107    private:
108
109        /// hash table holding other object properties
110        Rp_HashTable *_h;
111
112        /// initialize the object, set the data members to 0 or null
113        void __init();
114
115        /// close out the object, freeing its memory
116        void __clear();
117};
118
119} // RAPPTURE_OBJECT_H
120
121/*--------------------------------------------------------------------------*/
122/*--------------------------------------------------------------------------*/
123
124#endif
Note: See TracBrowser for help on using the repository browser.