|
JX Application Framework
|
#include <JPrefsManager.h>
Classes | |
| class | DataChanged |
| class | DataMessage |
| class | DataRemoved |
| class | WrongVersion |
Public Member Functions | |
| JPrefsManager (const JString &fileName, const JFileVersion currentVersion, const bool eraseFileIfOpen) | |
| ~JPrefsManager () override | |
| JError | SaveToDisk () const |
| JFileVersion | GetPrevPrefsVersion () const |
Public Member Functions inherited from JContainer | |
| JContainer () | |
| JContainer (const JContainer &source) | |
| JContainer & | operator= (const JContainer &source) |
Public Member Functions inherited from JCollection | |
| JCollection () | |
| JCollection (const JCollection &source) | |
| ~JCollection () override | |
| JCollection & | operator= (const JCollection &source) |
| JSize | GetItemCount () const |
| bool | IsEmpty () const |
| bool | IndexValid (const JIndex index) const |
| JIndex | GetIndexFromEnd (const JIndex index) const |
| JString | ToString () const override |
Public Member Functions inherited from JBroadcaster | |
| JBroadcaster () | |
| virtual | ~JBroadcaster () |
| JBroadcaster & | operator= (const JBroadcaster &source) |
| bool | HasSenders () const |
| JSize | GetSenderCount () const |
| bool | HasRecipients () const |
| JSize | GetRecipientCount () const |
| template<class T > | |
| void | ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f) |
Static Public Attributes | |
| static const JUtf8Byte * | kDataChanged = "DataChanged::JPrefsManager" |
| static const JUtf8Byte * | kDataRemoved = "DataRemoved::JPrefsManager" |
| static const JUtf8Byte * | kWrongVersion = "WrongVersion::JPrefsManager" |
Protected Member Functions | |
| bool | IDValid (const JPrefID &id) const |
| bool | GetData (const JPrefID &id, std::string *data) const |
| void | SetData (const JPrefID &id, std::ostringstream &data) |
| void | SetData (const JPrefID &id, std::string &data) |
| void | SetData (const JPrefID &id, const JString &data) |
| void | SetData (const JPrefID &id, const JUtf8Byte *data) |
| void | RemoveData (const JPrefID &id) |
| bool | UpgradeData (const bool reportError=true) |
| virtual void | UpgradeData (const bool isNew, const JFileVersion currentVersion)=0 |
| virtual void | DataLoaded ()=0 |
Protected Member Functions inherited from JContainer | |
| void | InstallCollection (JCollection *list) |
| const JCollection * | GetList () const |
| void | Receive (JBroadcaster *sender, const Message &message) override |
Protected Member Functions inherited from JCollection | |
| void | ItemAdded () |
| void | ItemRemoved () |
| void | SetItemCount (const JSize newItemCount) |
Protected Member Functions inherited from JBroadcaster | |
| JBroadcaster (const JBroadcaster &source) | |
| void | ListenTo (const JBroadcaster *sender) |
| void | StopListening (const JBroadcaster *sender) |
| void | ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember) |
| void | StopListening (const JBroadcaster *sender, const std::type_info &messageType) |
| template<class T > | |
| void | Send (JBroadcaster *recipient, const T &message) |
| template<class T > | |
| void | Broadcast (const T &message) |
| void | SendWithFeedback (JBroadcaster *recipient, Message *message) |
| void | BroadcastWithFeedback (Message *message) |
| virtual void | ReceiveWithFeedback (JBroadcaster *sender, Message *message) |
| virtual void | ReceiveGoingAway (JBroadcaster *sender) |
Friends | |
| class | JPrefObject |
Buffers the data in a JPrefsFile and provides a base class for
application-specific preferences management. The functions to access
the data are protected because they should be hidden behind a clean
interface in the derived class.
UpgradeData() is called after the file has been read. Since UpgradeData()
must work on an empty file, this ensures that the program has a valid set
of preferences even if the file could not be read.
Some programs enforce that only a single copy is running for each user,
so an open prefs file means that the program crashed while editing the
preferences. If this is the case, pass true for eraseFileIfOpen to
the constructor.
Derived classes must implement the following function:
UpgradeData
Upgrade the preferences data from the specified version.
| JPrefsManager::JPrefsManager | ( | const JString & | fileName, |
| const JFileVersion | currentVersion, | ||
| const bool | eraseFileIfOpen | ||
| ) |
Derived class must call UpgradeData().
|
override |
Derived classes must call SaveToDisk().
|
protectedpure virtual |
Implemented in JXPrefsManager.
|
inline |
|
protected |
| JError JPrefsManager::SaveToDisk | ( | ) | const |
This creates the item if it doesn't already exist.
|
inlineprotected |
This creates the item if it doesn't already exist.
|
inlineprotected |
|
protectedpure virtual |
Returns true if the file had to be created.
|
friend |
|
static |
|
static |
|
static |