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 watchFile=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::EmptyString()) 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 Attributes

CYISignal< CYIPreferencesPropFileChanged
 
CYISignal< CYIPreferencesPropFileCreated
 
CYISignal< CYIPreferencesPropFileDeleted
 

Constructor & Destructor Documentation

◆ CYIPreferences() [1/3]

CYIPreferences::CYIPreferences ( )

Default constructor.

◆ CYIPreferences() [2/3]

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

Constructor taking the path to the settings file. Set the watchFile 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() [3/3]

CYIPreferences::CYIPreferences ( const CYIPreferences prefs)

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

◆ ~CYIPreferences()

virtual CYIPreferences::~CYIPreferences ( )
virtual

Destructor.

Member Function Documentation

◆ Clear()

void CYIPreferences::Clear ( )

Removes all values from the preferences object.

◆ Get()

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.

◆ GetNames()

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

Return the names used for each property

◆ GetPropFilePath()

const CYIString& CYIPreferences::GetPropFilePath ( ) const
inline

Returns the properites file path being used.

◆ IsWatchingFile()

bool CYIPreferences::IsWatchingFile ( ) const

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

See also
UpdateFileMonitor

◆ Load()

virtual bool CYIPreferences::Load ( )
finalvirtual

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

◆ operator=()

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

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

◆ Save()

virtual bool CYIPreferences::Save ( const CYIString path = CYIString::EmptyString()) 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.

◆ Set()

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

Sets a property name with the corresponding value.

◆ SetPropFilePath()

void CYIPreferences::SetPropFilePath ( const CYIString path)
inline

Sets the current properties configuration path.

◆ UpdateFileMonitor()

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

◆ PropFileChanged

CYISignal<CYIPreferences> CYIPreferences::PropFileChanged

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

◆ PropFileCreated

CYISignal<CYIPreferences> CYIPreferences::PropFileCreated

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

◆ PropFileDeleted

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: