source: branches/blt4/src/objects/RpLibStorage.h @ 2044

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

updates for the rappture objects, object examples, and object apis. small fix for rpunits c interface to check string length. there should probably be more of these checks in the c interface, but units should also be rewritten. added folders to separate out octave2 and octave3 app-fermi examples

File size: 2.9 KB
Line 
1/*
2 * ----------------------------------------------------------------------
3 *  Rappture Library Storage Header
4 *
5 * ======================================================================
6 *  AUTHOR:  Derrick S. 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#ifndef _RP_LIBRARY_STORAGE_H
15#define _RP_LIBRARY_STORAGE_H
16
17#ifdef __cplusplus
18
19#include "RpObject.h"
20#include "RpOutcome.h"
21#include "RpInt.h"
22#include "RpChain.h"
23#include "RpHash.h"
24
25namespace Rappture {
26
27class LibraryStorage
28{
29    public:
30        LibraryStorage();
31        virtual ~LibraryStorage();
32
33        /*
34        Outcome &backup();
35        Outcome &restore();
36        */
37
38        Outcome &store(const char *key, Rappture::Object *o);
39        Outcome &link(const char *oldkey, const char *newkey);
40        Rappture::Object *find(const char *key);
41        Rappture::Object *remove(const char *key);
42        Outcome &clear();
43
44        Outcome &outcome() const;
45        const Rp_Chain *contains() const;
46    private:
47
48        // use a chain because the rappture gui says that order
49        // of the objects in the input and output sections of
50        // the xml file matters.  use a hash table to easily
51        // find items by name or path the hash table holds name
52        // and paths of the objects and points to the
53        // Rp_ChainLink so we can easily remove a value from
54        // the hash table and the chain.  watchout! the link()
55        // function allows multiple hash entries to point to
56        // the same Rp_ChainLink.  this means the remove()
57        // function can delete the Rappture::Object held by a
58        // Rp_ChainLink, but the Rp_ChainLink will not be
59        // deleted. _objList can have holes in it. there is
60        // currently no way to tell how many things point to
61        // it. also, the hash table never deletes it's
62        // ClientData (the Rp_ChainLink). this object does not
63        // store NULL objects. NULL objects look to close to
64        // things that have already been deleted. if the user
65        // calls find() and the result is Rp_ChainLink that
66        // points to a NULL object, the user will get NULL back
67        // and the Rp_ChainLink will be removed along with the
68        // corresponding hash entry. bad Rp_ChainLinks are also
69        // cleaned up when the user calls the contains()
70        // function.
71
72        Rp_Chain *_objList;
73        Rp_HashTable *_objNameHash;
74        mutable Rappture::Outcome _status;
75
76        void __libStoreInit();
77        void __libStoreFree();
78        Rappture::Object *__find(const char *key, size_t flags);
79
80}; // end class LibrarayStorage
81
82} // end namespace Rappture
83
84
85#endif // ifdef __cplusplus
86
87#endif // ifndef _RP_LIBRARY_H
Note: See TracBrowser for help on using the repository browser.