Class: Wx::PersistenceManager
- Inherits:
-
Object
- Object
- Wx::PersistenceManager
- Defined in:
- lib/wx/doc/gen/persistence_manager.rb
Overview
Provides support for automatically saving and restoring object properties to persistent storage.
This class is the central element of wxWidgets persistence framework, see Persistent Objects Overview for its overview. This is a singleton class and its unique instance can be retrieved using PersistenceManager.get method.
Class Method Summary collapse
-
.get ⇒ Wx::PersistenceManager
Returns the unique persistence manager object.
-
.set(manager) ⇒ void
Set the global persistence manager to use.
Instance Method Summary collapse
-
#disable_restoring ⇒ void
Globally disable restoring the persistence object properties.
-
#disable_saving ⇒ void
Globally disable saving the persistence object properties.
-
#find(obj) ⇒ Wx::PersistentObject
Check if the object is registered and return the associated PersistentObject if it is or NULL otherwise.
-
#get_config ⇒ Wx::ConfigBase
(also: #config)
protected
Return the config object to use.
-
#get_key(who, name) ⇒ String
(also: #key)
protected
Return the path to use for saving the setting with the given name for the specified object.
-
#initialize ⇒ Wx::PersistenceManager
constructor
protected
Protected default constructor.
- #register(*args) ⇒ Object
- #register_and_restore(*args) ⇒ Object
-
#restore(obj) ⇒ Boolean
Restore the object properties previously saved by #save.
-
#save(obj) ⇒ void
Save the object properties to persistent storage.
-
#save_and_unregister(obj) ⇒ void
Combines both #save and #unregister calls.
-
#unregister(obj) ⇒ void
Unregister the object and delete the associated PersistentObject.
Constructor Details
#initialize ⇒ Wx::PersistenceManager (protected)
Protected default constructor.
This constructor is only provided for the derived classes, to use an object of this class static get method should be called.
113 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 113 def initialize; end |
Class Method Details
.get ⇒ Wx::PersistenceManager
Returns the unique persistence manager object.
If set hadn’t been called before, a default persistence manager implementation is returned.
39 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 39 def self.get; end |
.set(manager) ⇒ void
This method returns an undefined value.
Set the global persistence manager to use.
Call this method to specify a non-default persistence manager to use. It should usually be called very early (e.g. in App-derived class constructor or in the beginning of overridden App#on_init) to affect creation of all persistent controls and the object passed to it must have a lifetime long enough to be still alive when the persistent controls are destroyed and need it to save their state so typically this would be a global or a App member.
33 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 33 def self.set(manager) end |
Instance Method Details
#disable_restoring ⇒ void
This method returns an undefined value.
Globally disable restoring the persistence object properties.
By default, restoring properties in #restore is enabled but this function allows disabling it. This is mostly useful for testing.
53 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 53 def disable_restoring; end |
#disable_saving ⇒ void
This method returns an undefined value.
Globally disable saving the persistence object properties.
By default, saving properties in #save is enabled but the program may wish to disable if, for example, it detects that it is running on a system which shouldn’t be modified in any way and so configuration file (or Windows registry) shouldn’t be written to.
46 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 46 def disable_saving; end |
#find(obj) ⇒ Wx::PersistentObject
Check if the object is registered and return the associated Wx::PersistentObject if it is or NULL otherwise.
74 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 74 def find(obj) end |
#get_config ⇒ Wx::ConfigBase (protected) Also known as: config
Return the config object to use.
By default the global Config, returned by ConfigBase#get, is used but a derived class could override this function to return a different one if necessary.
119 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 119 def get_config; end |
#get_key(who, name) ⇒ String (protected) Also known as: key
Return the path to use for saving the setting with the given name for the specified object.
Notice that the name argument is the name of the setting, not the name of the object itself which can be retrieved with its GetName() method. This method can be overridden by a derived class to change where in Config the different options are stored. By default, all settings of the persistent controls are stored under “Persistent_Options” group and grouped by control type (e.g. “Window” for top level windows or “Splitter”) and name, so that the position of a splitter called “sep” could be stored under “Persistent_Options/Splitter/sep/Position” key.
129 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 129 def get_key(who, name) end |
#register(obj) ⇒ Wx::PersistentObject #register(obj, po) ⇒ Wx::PersistentObject
69 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 69 def register(*args) end |
#register_and_restore(obj) ⇒ Boolean #register_and_restore(obj, po) ⇒ Boolean
26 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 26 def register_and_restore(*args) end |
#restore(obj) ⇒ Boolean
Restore the object properties previously saved by #save.
This method does nothing if #disable_restoring had been called.
true if the object properties were restored or false if nothing was found to restore or the saved settings were invalid.
99 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 99 def restore(obj) end |
#save(obj) ⇒ void
This method returns an undefined value.
Save the object properties to persistent storage.
This method does nothing if #disable_saving had been called.
89 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 89 def save(obj) end |
#save_and_unregister(obj) ⇒ void
This method returns an undefined value.
Combines both #save and #unregister calls.
104 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 104 def save_and_unregister(obj) end |
#unregister(obj) ⇒ void
This method returns an undefined value.
Unregister the object and delete the associated Wx::PersistentObject.
For the persistent windows this is done automatically (via #save_and_unregister) when the window is destroyed so you only need to call this function explicitly if you are using custom persistent objects or if you want to prevent the object properties from being saved.
81 |
# File 'lib/wx/doc/gen/persistence_manager.rb', line 81 def unregister(obj) end |