You.i Engine
CYIPreferences Class Reference

Detailed Description

Property management class using CYIString names and values.

This class will allow easy storage and retrieval of name/value properties via a properties file. If any changes are made to this file, it will automatically reload the configuration and signal any clients that the configuration has changed.

#include <utility/YiPreferences.h>

Inheritance diagram for CYIPreferences:

Public Member Functions

 CYIPreferences ()
 
 CYIPreferences (const CYIString &path, bool bWatchFile=false)
 
 CYIPreferences (const CYIPreferences &prefs)
 
virtual ~CYIPreferences ()
 
CYIPreferencesoperator= (const CYIPreferences &rhs)
 
std::vector< CYIStringGetNames () const
 
const CYIStringGetPropFilePath () const
 
void SetPropFilePath (const CYIString &path)
 
void Clear ()
 
virtual bool Load () final
 
virtual bool Save (const CYIString &path=CYIString::EMPTY_STRING) const
 
CYIString Get (const CYIString &name, bool *pFound=nullptr) const
 
void Set (const CYIString &name, const CYIString &value)
 
bool IsWatchingFile () const
 
void UpdateFileMonitor ()
 
- Public Member Functions inherited from CYISignalHandler
 CYISignalHandler ()
 
 CYISignalHandler (const CYISignalHandler &rSignalHandler)
 
virtual ~CYISignalHandler ()
 
CYISignalHandleroperator= (const CYISignalHandler &rSignalHandler)
 
void MoveToThread (CYIThread *pThread)
 This function allows the user to override the default thread affinity to any CYIThread that may or may not be running. More...
 
CYIThreadHandle GetThreadAffinity () const
 
void SetThreadAffinity (const CYIThreadHandle &rThreadAffinity)
 
virtual bool IsConnected () const
 
virtual bool IsConnected (const CYISignalBase &rSignal) const
 
void Disconnect (CYISignalBase &rSignal)
 
void DisconnectFromAllSignals ()
 
- Public Member Functions inherited from CYIThread::Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void OnThreadStarted (CYIThread *)
 
virtual void OnThreadTerminated (CYIThread *)
 
virtual void OnThreadFinished (CYIThread *)
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const
 

Public Attributes

CYISignal< CYIPreferencesPropFileChanged
 
CYISignal< CYIPreferencesPropFileCreated
 
CYISignal< CYIPreferencesPropFileDeleted
 

Constructor & Destructor Documentation

CYIPreferences::CYIPreferences ( )

Default constructor.

CYIPreferences::CYIPreferences ( const CYIString path,
bool  bWatchFile = false 
)

Constructor taking the path to the settings file. Set the bWatchFile to true if you want the preferences file to be watched. Passing nullptr as a value for path results in an empty preferences object.

CYIPreferences::CYIPreferences ( const CYIPreferences prefs)

Copy constructor. Any watched configuration files will not be copied.

virtual CYIPreferences::~CYIPreferences ( )
virtual

Destructor.

Member Function Documentation

void CYIPreferences::Clear ( )

Removes all values from the preferences object.

CYIString CYIPreferences::Get ( const CYIString name,
bool *  pFound = nullptr 
) const

Returns the corresponding value for the specified name. Returns an empty string object if the property name could not be found. If a pointer is provided for pFound, it will be set to true if the property name is found.

std::vector<CYIString> CYIPreferences::GetNames ( ) const

Return the names used for each property

const CYIString& CYIPreferences::GetPropFilePath ( ) const
inline

Returns the properites file path being used.

bool CYIPreferences::IsWatchingFile ( ) const

Returns whether we have a file to monitor or not, which will be if bWatchFile was true when constructed, and there is a file path set.

See also
UpdateFileMonitor
virtual bool CYIPreferences::Load ( )
finalvirtual

Loads the preferences file. Returns false if the properties file could not be accessed.

CYIPreferences& CYIPreferences::operator= ( const CYIPreferences rhs)

Assignment operator which consumes the supplied preferences object. Signal objects are not copied.

virtual bool CYIPreferences::Save ( const CYIString path = CYIString::EMPTY_STRING) const
virtual

Saves the current property name/value configuration using the current path, or using the new path if specified. Returns false if the properties file could not be saved.

void CYIPreferences::Set ( const CYIString name,
const CYIString value 
)

Sets a property name with the corresponding value.

void CYIPreferences::SetPropFilePath ( const CYIString path)
inline

Sets the current properties configuration path.

void CYIPreferences::UpdateFileMonitor ( )

This method must be called by the main loop in your application, if you want file monitoring for the preferences file.

Member Data Documentation

CYISignal<CYIPreferences> CYIPreferences::PropFileChanged

This signal is emitted when the properties file has been modfied.

CYISignal<CYIPreferences> CYIPreferences::PropFileCreated

This signal is emitted when the properties file has been created.

CYISignal<CYIPreferences> CYIPreferences::PropFileDeleted

This signal is emitted when the properties file has been deleted.


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