MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::ObjectSettingsHandler Class Referenceabstract

An abstract class for other classes that manage groups of settings. More...

#include <objectsettings.h>

+ Inheritance diagram for Mezzanine::ObjectSettingsHandler:
+ Collaboration diagram for Mezzanine::ObjectSettingsHandler:

Public Types

typedef
SettingFilesContainer::const_iterator 
ConstSettingFilesIterator
 Const Iterator type for ObjectSettingGroup instances stored by this class.
 
typedef
SettingGroupContainer::const_iterator 
ConstSettingGroupIterator
 Const Iterator type for ObjectSettingGroup instances stored by this class.
 
typedef std::map< String,
ObjectSettingFile * > 
SettingFilesContainer
 Basic container type for ObjectSettingFile storage by this class.
 
typedef
SettingFilesContainer::iterator 
SettingFilesIterator
 Iterator type for ObjectSettingGroup instances stored by this class.
 
typedef std::map< String,
ObjectSettingGroup * > 
SettingGroupContainer
 Basic container type for ObjectSettingGroup storage by this class.
 
typedef
SettingGroupContainer::iterator 
SettingGroupIterator
 Iterator type for ObjectSettingGroup instances stored by this class.
 
typedef std::vector
< ObjectSettingGroup * > 
SettingGroupVector
 Convenience typedef for Load method returns.
 

Public Member Functions

 ObjectSettingsHandler ()
 Class constructor.
 
virtual ~ObjectSettingsHandler ()
 Class destructor.
 
void AddGroupToFile (ObjectSettingGroup *Group, const String &FileName)
 Assigns a SettingGroup to a file name that will be used when settings are saved. More...
 
void ApplySettingGroup (const String &GroupName)
 Applies all the settings (and their values) defined in a setting group. More...
 
ObjectSettingFileCreateSettingFile (const String &FileName)
 Creates a new Setting file that will track which groups are a part of it. More...
 
ObjectSettingGroupCreateSettingGroup (const String &Name)
 Creates a new blank setting group that can have it's settings populated. More...
 
void DestroyAllSettingFiles ()
 Destroys all Setting files in this handler. More...
 
void DestroyAllSettingGroups ()
 Destroys all setting groups stored in this handler.
 
void DestroySettingFile (const String &FileName)
 Destroys a Setting file by name. More...
 
void DestroySettingFile (ObjectSettingFile *ToBeDestroyed)
 Destroys a Setting file. More...
 
void DestroySettingGroup (const String &Name)
 Destroys a setting group by name. More...
 
void DestroySettingGroup (ObjectSettingGroup *ToBeDestroyed)
 Destroys a setting group. More...
 
Boolean GetAutoGenFiles () const
 Gets whether or not this object is currently allowed to create/update settings files upon initialization and destruction. More...
 
Boolean GetAutoGenPath () const
 Gets whether or not this object is currently allowed to create folders when saving. More...
 
ConstStringGetCurrentSettingsSaveFile () const
 Gets the name of the file the "Current" setting group is saved to. More...
 
ObjectSettingFileGetSettingFile (const String &FileName)
 Gets a Setting file by name. More...
 
ObjectSettingGroupGetSettingGroup (const String &Name) const
 Gets a setting group by name. More...
 
const StringGetSettingsFilePath () const
 Gets the currently set settings file path. More...
 
CountedPtr< SettingGroupVectorLoadSettings (const String &FileName, const String &Path)
 Loads settings from a settings file. More...
 
CountedPtr< SettingGroupVectorLoadSettings (const String &FileName)
 Loads settings from a settings file using the specified settings path. More...
 
CountedPtr< SettingGroupVectorLoadSettingsFromGroup (const String &FileName, const String &Group)
 Loads settings from a settings file. More...
 
CountedPtr< SettingGroupVectorLoadSettingsFromXML (XML::Node &RootSettings)
 Loads settings from an xml node. More...
 
void RemoveGroupFromFile (ObjectSettingGroup *Group, const String &FileName)
 Removes a previously assigned group from a save file name. More...
 
void SaveAllSettings ()
 Saves all settings that need saving. More...
 
void SaveSettingGroups (StringVector &GroupNames, const String &FileName, const String &Path)
 Saves all settings to a settings file. More...
 
void SaveSettingGroups (StringVector &GroupNames, const String &FileName)
 Saves all settings to a settings file using the specified settings path. More...
 
void SaveSettingsByFile (const String &FileName, const String &Path)
 Saves all settings that have their optional filename set to the specified file. More...
 
void SaveSettingsByFile (const String &FileName)
 Saves all settings that have their optional filename set to the specified file. More...
 
void SaveSettingsToXML (XML::Node &RootSettings, Boolean SaveCurrent=true)
 Saves all the current setting groups as children of the provided XML node. More...
 
void SaveSettingsToXML (StringVector &GroupNames, XML::Node &RootSettings)
 Saves the named settings groups as children of the provided XML node. More...
 
void SetAutoGenFiles (Boolean Enable)
 Enables or disables the automatic creation of settings files on initialization and destruction of this object. More...
 
void SetAutoGenPath (Boolean Enable)
 Enables or disables the automatic creation of a directory path when saving. More...
 
void SetCurrentSettingsSaveFile (const String &FileName)
 Sets the name of the file that will have this object's "current" settings saved to. More...
 
void SetSettingsFilePath (const String &Path)
 Sets the path to be assumed when saving/loading settings to files. More...
 

Protected Member Functions

virtual void AppendCurrentSettings (XML::Node &CurrentNode)=0
 Takes all the current settings of this handler and serializes them to an XML::Node. More...
 
virtual void ApplySettingGroupImpl (ObjectSettingGroup *Group)=0
 Applies all the settings stored by a ObjectSettingGroup. More...
 
virtual String GetObjectRootNodeName () const =0
 Gets the name to be given to a Node with this handlers serialized data. More...
 
void LoadSettingSetFromXML (XML::Node &XMLNode, ObjectSettingSet *Set)
 Populates an ObjectSettingSet with settings stored in XML. More...
 
CountedPtr< SettingGroupVectorLoadSettingsFromFile (const String &FileName, const String &Path)
 Loads all ObjectSettingGroup instances serialized to a XML file into usable ObjectSettingGroup instances. More...
 
void SaveSettingSetToXML (XML::Node &XMLNode, ObjectSettingSet *Set)
 Saves an ObjectSettingSet to an XML node. More...
 
void SaveSettingsToFile (StringVector &GroupNames, const String &FileName, const String &Path)
 Saves a collection of ObjectSettingGroups stored by this handler to a file as XML. More...
 

Protected Attributes

Boolean AutoGenFiles
 Stores whether or not this handler will attempt to automatically generate a file if it doesn't exist. More...
 
Boolean AutoGenPath
 Stores whether or not this handler will attempt to automatically generate a path to a file if it doesn't exist. More...
 
String CurrentSettingsSaveFile
 Stores the name of the file where the "Current" settings group will be saved to. More...
 
SettingFilesContainer SettingFiles
 A container storing all the file saving configuration used by this handler. More...
 
SettingGroupContainer SettingGroups
 A container storing all the SettingGroups owned by this handler. More...
 
String SettingsFilePath
 Stores the path to be used for file IO operations done by this handler. More...
 

Detailed Description

An abstract class for other classes that manage groups of settings.

Definition at line 330 of file objectsettings.h.

Member Function Documentation

void Mezzanine::ObjectSettingsHandler::AddGroupToFile ( ObjectSettingGroup Group,
const String FileName 
)

Assigns a SettingGroup to a file name that will be used when settings are saved.

Parameters
GroupThe setting group getting it's optional file name updated.
FileNameThe name of the file the provided group will be added to.

Definition at line 507 of file objectsettings.cpp.

virtual void Mezzanine::ObjectSettingsHandler::AppendCurrentSettings ( XML::Node CurrentNode)
protectedpure virtual

Takes all the current settings of this handler and serializes them to an XML::Node.

Parameters
CurrentNodeThe XML::Node to be populated with this handlers current settings.

Implemented in Mezzanine::Graphics::GraphicsManager.

void Mezzanine::ObjectSettingsHandler::ApplySettingGroup ( const String GroupName)

Applies all the settings (and their values) defined in a setting group.

Parameters
GroupNameThe name of the setting group to apply.

Definition at line 416 of file objectsettings.cpp.

virtual void Mezzanine::ObjectSettingsHandler::ApplySettingGroupImpl ( ObjectSettingGroup Group)
protectedpure virtual

Applies all the settings stored by a ObjectSettingGroup.

Parameters
GroupThe ObjectSettingGroup to have all of it's settings applied.

Implemented in Mezzanine::Graphics::GraphicsManager.

ObjectSettingFile * Mezzanine::ObjectSettingsHandler::CreateSettingFile ( const String FileName)

Creates a new Setting file that will track which groups are a part of it.

Parameters
FileNameThe name of the file this instance cooresponds to.
Returns
Returns a pointer to the created ObjectSettingFile.

Definition at line 466 of file objectsettings.cpp.

ObjectSettingGroup * Mezzanine::ObjectSettingsHandler::CreateSettingGroup ( const String Name)

Creates a new blank setting group that can have it's settings populated.

Parameters
NameThe name to be given to the new settings group.
Returns
Returns a pointer to the newly created setting group.

Definition at line 426 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::DestroyAllSettingFiles ( )

Destroys all Setting files in this handler.

Note
This does not destroy any saved files on disk, only the helper class(es) that have been allocated in memory.

Definition at line 496 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::DestroySettingFile ( const String FileName)

Destroys a Setting file by name.

Note
This does not destroy any saved files on disk, only the helper class(es) that have been allocated in memory.
Parameters
FileNameThe name of the setting file to be destroyed.

Definition at line 480 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::DestroySettingFile ( ObjectSettingFile ToBeDestroyed)

Destroys a Setting file.

Note
This does not destroy any saved files on disk, only the helper class(es) that have been allocated in memory.
Parameters
ToBeDestroyedThe setting file to be destroyed.

Definition at line 491 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::DestroySettingGroup ( const String Name)

Destroys a setting group by name.

Parameters
NameThe name of the setting group to destroy.

Definition at line 440 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::DestroySettingGroup ( ObjectSettingGroup ToBeDestroyed)

Destroys a setting group.

Parameters
ToBeDestroyedA pointer to the group that will be destroyed.

Definition at line 449 of file objectsettings.cpp.

Boolean Mezzanine::ObjectSettingsHandler::GetAutoGenFiles ( ) const

Gets whether or not this object is currently allowed to create/update settings files upon initialization and destruction.

Returns
Returns true if this object will generate or update settings files when it is initialized and destruction.

Definition at line 637 of file objectsettings.cpp.

Boolean Mezzanine::ObjectSettingsHandler::GetAutoGenPath ( ) const

Gets whether or not this object is currently allowed to create folders when saving.

Returns
Returns true if this object will create folders in paths it uses to force the path to be valid.

Definition at line 631 of file objectsettings.cpp.

ConstString & Mezzanine::ObjectSettingsHandler::GetCurrentSettingsSaveFile ( ) const

Gets the name of the file the "Current" setting group is saved to.

Returns
Returns string ref to the name of the file current settings are being saved to, or an empty string if one is not set.

Definition at line 564 of file objectsettings.cpp.

virtual String Mezzanine::ObjectSettingsHandler::GetObjectRootNodeName ( ) const
protectedpure virtual

Gets the name to be given to a Node with this handlers serialized data.

Returns
Returns a String containing the name to be given to the XML::Node storing this handlers data.

Implemented in Mezzanine::Graphics::GraphicsManager.

ObjectSettingFile * Mezzanine::ObjectSettingsHandler::GetSettingFile ( const String FileName)

Gets a Setting file by name.

Parameters
FileNameThe name of the setting file to get.
Returns
Returns a pointer to the named setting file.

Definition at line 473 of file objectsettings.cpp.

ObjectSettingGroup * Mezzanine::ObjectSettingsHandler::GetSettingGroup ( const String Name) const

Gets a setting group by name.

Parameters
NameThe name of the setting group to get.
Returns
Returns a pointer to the named setting group.

Definition at line 433 of file objectsettings.cpp.

const String & Mezzanine::ObjectSettingsHandler::GetSettingsFilePath ( ) const

Gets the currently set settings file path.

Returns
Returns a string containing the path to use when a save/load path isn't specified.

Definition at line 554 of file objectsettings.cpp.

CountedPtr< ObjectSettingsHandler::SettingGroupVector > Mezzanine::ObjectSettingsHandler::LoadSettings ( const String FileName,
const String Path 
)

Loads settings from a settings file.

Parameters
FileNameThe name of the file to load and parse.
PathThe filesystem path where the file can be found.
Returns
Returns a vector containing all the setting groups that were created while loading settings.

Definition at line 581 of file objectsettings.cpp.

CountedPtr< ObjectSettingsHandler::SettingGroupVector > Mezzanine::ObjectSettingsHandler::LoadSettings ( const String FileName)

Loads settings from a settings file using the specified settings path.

Note
Using this function means it will use the preset settings file path stored in this handler. The path must be set before calling this.
Parameters
FileNameThe name of the file to load and parse.
Returns
Returns a vector containing all the setting groups that were created while loading settings.

Definition at line 586 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::LoadSettingSetFromXML ( XML::Node XMLNode,
ObjectSettingSet Set 
)
protected

Populates an ObjectSettingSet with settings stored in XML.

Parameters
XMLNodeThe XML node storing the serialized ObjectSettingSet.
SetThe ObjectSettingSet to be populated with usable settings.

Definition at line 383 of file objectsettings.cpp.

CountedPtr< ObjectSettingsHandler::SettingGroupVector > Mezzanine::ObjectSettingsHandler::LoadSettingsFromFile ( const String FileName,
const String Path 
)
protected

Loads all ObjectSettingGroup instances serialized to a XML file into usable ObjectSettingGroup instances.

Parameters
FileNameThe name of the file to be loaded.
PathThe path to the file to be loaded.
Returns
Returns a CountedPtr to a container of the loaded ObjectSettingGroup instances.
Todo:
Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.

Definition at line 324 of file objectsettings.cpp.

CountedPtr< ObjectSettingsHandler::SettingGroupVector > Mezzanine::ObjectSettingsHandler::LoadSettingsFromGroup ( const String FileName,
const String Group 
)

Loads settings from a settings file.

Parameters
FileNameThe name of the file to load and parse.
GroupThe asset group where the file can be found.
Returns
Returns a vector containing all the setting groups that were created while loading settings.

Definition at line 572 of file objectsettings.cpp.

CountedPtr< ObjectSettingsHandler::SettingGroupVector > Mezzanine::ObjectSettingsHandler::LoadSettingsFromXML ( XML::Node RootSettings)

Loads settings from an xml node.

Parameters
RootSettingsThe node that reprsents the root of the settings group or groups.
Returns
Returns a vector containing all the setting groups that were created while loading settings.

Definition at line 594 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::RemoveGroupFromFile ( ObjectSettingGroup Group,
const String FileName 
)

Removes a previously assigned group from a save file name.

Parameters
GroupThe setting group getting removed from it's current optional file name.
FileNameThe name of the file the provided group will be removed from.

Definition at line 524 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveAllSettings ( )

Saves all settings that need saving.

Remarks
This function does a few things. First it will only save the setting groups which have their optional setting files specified, which is automatically set if they are loaded from a file. Second, it will only save the files(and their collection of Setting Groups) that are marked as needing saving to prevent unnessessary IO.

Definition at line 640 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingGroups ( StringVector GroupNames,
const String FileName,
const String Path 
)

Saves all settings to a settings file.

Remarks
This function bypasses the file utilities offered by this class and just writes the specified groups to the named file. It will not make a coresponding file class and this file will not be auto saved at any point later. This is just an explicit utility function for writing groups to the disk should you need it. In general it is better to create a file class and populate it with groups yourself.
Parameters
GroupNamesA string vector containing the names for all the settings groups to save.
FilenameThe name of the file to save the current settings to.
PathThe path to place the file being saved.

Definition at line 708 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingGroups ( StringVector GroupNames,
const String FileName 
)

Saves all settings to a settings file using the specified settings path.

Note
Using this function means it will use the preset settings file path stored in this handler. The path must be set before calling this otherwise an exception will be thrown.
Remarks
This function bypasses the file utilities offered by this class and just writes the specified groups to the named file. It will not make a coresponding file class and this file will not be auto saved at any point later. This is just an explicit utility function for writing groups to the disk should you need it. In general it is better to create a file class and populate it with groups yourself.
Parameters
GroupNamesA string vector containing the names for all the settings groups to save.
FilenameThe name of the file to save the current settings to.

Definition at line 713 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingsByFile ( const String FileName,
const String Path 
)

Saves all settings that have their optional filename set to the specified file.

Parameters
FilenameThe optional filename that will be used to determine which groups will be saved, and to what file.
PathThe path to place the file being saved.

Definition at line 666 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingsByFile ( const String FileName)

Saves all settings that have their optional filename set to the specified file.

Note
Using this function means it will use the preset settings file path stored in this handler. The path must be set before calling this.
Parameters
FilenameThe optional filename that will be used to determine which groups will be saved, and to what file.

Definition at line 685 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingSetToXML ( XML::Node XMLNode,
ObjectSettingSet Set 
)
protected

Saves an ObjectSettingSet to an XML node.

Parameters
XMLNodeThe XML node to be written with the settings of the provided set.
SetThe ObjectSettingSet to be written to XML.

Definition at line 399 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingsToFile ( StringVector GroupNames,
const String FileName,
const String Path 
)
protected

Saves a collection of ObjectSettingGroups stored by this handler to a file as XML.

Parameters
GroupNamesA container storing all the names of of the ObjectSettingGroup instances to be saved.
FileNameThe name of the file to be saved at.
PathThe path to the file being saved.
Todo:
Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.

Definition at line 364 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingsToXML ( XML::Node RootSettings,
Boolean  SaveCurrent = true 
)

Saves all the current setting groups as children of the provided XML node.

Parameters
SaveCurrentWhether or not to also save the current settings to XML.
RootSettingsThe node to populate with all currently loaded settings groups.

Definition at line 722 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SaveSettingsToXML ( StringVector GroupNames,
XML::Node RootSettings 
)

Saves the named settings groups as children of the provided XML node.

Parameters
GroupNamesA string vector containing the names for all the settings groups to save.
RootSettingsThe node to populate with all currently loaded settings groups.

Definition at line 736 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SetAutoGenFiles ( Boolean  Enable)

Enables or disables the automatic creation of settings files on initialization and destruction of this object.

Parameters
EnableTrue to allow this object to save it's settings sets to a file on initialization and destruction.

Definition at line 634 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SetAutoGenPath ( Boolean  Enable)

Enables or disables the automatic creation of a directory path when saving.

Parameters
EnableTrue to allow this object to create folders in the intended save path allowing the path to be valid, false otherwise.

Definition at line 628 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SetCurrentSettingsSaveFile ( const String FileName)

Sets the name of the file that will have this object's "current" settings saved to.

Any group labeled "Current" (case sensative) will be used and immediately applied upon loading.
If this is enabled and no group specifiers are used, then the Current settings will automatically be saved any time the groups are saved. When using functions with group specifiers, you can include a string "Current" to save the current settings.
It's also important to note that the "Current" settings group, although it'll be present in saved files, is not a group traversible in code. It is solely intended to save the existing state at shutdown, and resume with that exact config.

Parameters
FileNameName of the file to save the current settings to.

Definition at line 559 of file objectsettings.cpp.

void Mezzanine::ObjectSettingsHandler::SetSettingsFilePath ( const String Path)

Sets the path to be assumed when saving/loading settings to files.

Parameters
PathThe path to be assumed.

Definition at line 537 of file objectsettings.cpp.

Member Data Documentation

Boolean Mezzanine::ObjectSettingsHandler::AutoGenFiles
protected

Stores whether or not this handler will attempt to automatically generate a file if it doesn't exist.

Definition at line 359 of file objectsettings.h.

Boolean Mezzanine::ObjectSettingsHandler::AutoGenPath
protected

Stores whether or not this handler will attempt to automatically generate a path to a file if it doesn't exist.

Definition at line 356 of file objectsettings.h.

String Mezzanine::ObjectSettingsHandler::CurrentSettingsSaveFile
protected

Stores the name of the file where the "Current" settings group will be saved to.

Definition at line 365 of file objectsettings.h.

SettingFilesContainer Mezzanine::ObjectSettingsHandler::SettingFiles
protected

A container storing all the file saving configuration used by this handler.

Definition at line 353 of file objectsettings.h.

SettingGroupContainer Mezzanine::ObjectSettingsHandler::SettingGroups
protected

A container storing all the SettingGroups owned by this handler.

Definition at line 350 of file objectsettings.h.

String Mezzanine::ObjectSettingsHandler::SettingsFilePath
protected

Stores the path to be used for file IO operations done by this handler.

Definition at line 362 of file objectsettings.h.


The documentation for this class was generated from the following files: