JX Application Framework
|
#include <JPrefObject.h>
Public Member Functions | |
JPrefObject (JPrefsManager *prefsMgr, const JPrefID &id) | |
virtual | ~JPrefObject () |
bool | PrefInfoValid () const |
bool | GetPrefInfo (JPrefsManager **mgr, JIndex *id) const |
void | SetPrefInfo (JPrefsManager *prefsMgr, const JPrefID &id) |
void | ReadPrefs () |
void | WritePrefs () const |
Protected Member Functions | |
virtual void | ReadPrefs (std::istream &input)=0 |
virtual void | WritePrefs (std::ostream &output) const =0 |
Base class for objects that own an ID in a preferences file. To read/ write preferences, simply call JPrefObject::Read/WritePrefs(). This is designed to be a mixin class, but must only be used once since it assumes a single id in the prefs file. It should also not be inherited virtually. Even though Read/WritePrefs() is virtual, it should never be overridden more than once, in the leaf class. Otherwise, one will eventually have to insert an override of these functions into the inheritance path, and this will require that derived classes know about the change. The better way to handle it is for the leaf class to either read/write everything explicitly via access functions provided by the base classes or to call subsidiary read/write functions in each base class. This makes it explicit that the leaf class knows what is stored and makes it much easier to handle new information in base classes.
JPrefObject::JPrefObject | ( | JPrefsManager * | prefsMgr, |
const JPrefID & | id | ||
) |
prefsMgr can be nullptr
|
virtual |
|
inline |
|
inline |
void JPrefObject::ReadPrefs | ( | ) |
|
protectedpure virtual |
Implemented in JUpdateChecker, JXDockManager, and JXToolBar.
|
inline |
void JPrefObject::WritePrefs | ( | ) | const |
|
protectedpure virtual |
Implemented in JXToolBar, JUpdateChecker, and JXDockManager.