diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2009-12-28 22:26:48 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2009-12-28 22:26:48 +0000 |
| commit | ae9b3365aa310d90d769576967263bf66bf41b19 (patch) | |
| tree | cb6259035b84a6479d382527d7e90fa9b75fbf35 /FL/Fl_Preferences.H | |
| parent | 9048b4b8950c95df9255e53c101b863037e56ecf (diff) | |
Added an ID type to preferences which can be retrieved to then re-use the same dataset. IDs can be used in callbacks as user_data(). No need to keep an Fl_Preference around that would later require deleting.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6984 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL/Fl_Preferences.H')
| -rw-r--r-- | FL/Fl_Preferences.H | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/FL/Fl_Preferences.H b/FL/Fl_Preferences.H index 7ad5de756..e734d7d23 100644 --- a/FL/Fl_Preferences.H +++ b/FL/Fl_Preferences.H @@ -80,6 +80,15 @@ public: USER ///< Preferences apply only to the current user }; + /** + Every Fl_Preferences-Group has a uniqe ID. + + ID's can be retrieved from an Fl_Preferences-Group and can then be used + to create more Fl_Preference references to the same data set, as long as the + databse remains open. + */ + typedef void *ID; + static const char *newUUID(); Fl_Preferences( Root root, const char *vendor, const char *application ); @@ -88,7 +97,10 @@ public: Fl_Preferences( Fl_Preferences *parent, const char *group ); Fl_Preferences( Fl_Preferences &parent, int groupIndex ); Fl_Preferences( Fl_Preferences *parent, int groupIndex ); + Fl_Preferences( ID id ); ~Fl_Preferences(); + + ID id(); /** Return the name of this entry. */ @@ -177,11 +189,18 @@ private: static char nameBuffer[128]; static char uuidBuffer[40]; + class RootNode; + class FL_EXPORT Node // a node contains a list to all its entries { // and all means to manage the tree structure - Node *child_, *next_, *parent_; + Node *child_, *next_; + union { // these two are mutually exclusive + Node *parent_; // top_ bit clear + RootNode *root_; // top_ bit set + }; char *path_; - char dirty_; + char dirty_:1; + char top_:1; public: Node( const char *path ); ~Node(); @@ -193,7 +212,9 @@ private: Node *search( const char *path, int offset=0 ); Node *addChild( const char *path ); void setParent( Node *parent ); - Node *parent() { return parent_; } + Node *parent() { return top_?parent_:0L; } + void setRoot(RootNode *r) { root_ = r; top_ = 1; } + RootNode *findRoot(); char remove(); char dirty(); // entry methods |
