Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/gui/GUIutil.cpp
Show First 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value) | ||||
// Get value | // Get value | ||||
Value = &(static_cast<CGUISetting<T>* >(it->second)->m_pSetting); | Value = &(static_cast<CGUISetting<T>* >(it->second)->m_pSetting); | ||||
return PSRETURN_OK; | return PSRETURN_OK; | ||||
} | } | ||||
template <typename T> | template <typename T> | ||||
bool GUI<T>::HasSetting(const IGUIObject* pObject, const CStr& Setting) | |||||
{ | |||||
return pObject->m_Settings.count(Setting) != 0; | |||||
} | |||||
template <typename T> | |||||
T& GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting) | |||||
{ | |||||
return static_cast<CGUISetting<T>* >(pObject->m_Settings.at(Setting))->m_pSetting; | |||||
} | |||||
template <typename T> | |||||
PSRETURN GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value) | PSRETURN GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value) | ||||
{ | { | ||||
T* v = NULL; | T* v = NULL; | ||||
PSRETURN ret = GetSettingPointer(pObject, Setting, v); | PSRETURN ret = GetSettingPointer(pObject, Setting, v); | ||||
if (ret == PSRETURN_OK) | if (ret == PSRETURN_OK) | ||||
Value = *v; | Value = *v; | ||||
return ret; | return ret; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | PSRETURN GUI<T>::SetSettingWrap(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage, const std::function<void()>& valueSet) | ||||
} | } | ||||
return PSRETURN_OK; | return PSRETURN_OK; | ||||
} | } | ||||
// Instantiate templated functions: | // Instantiate templated functions: | ||||
// These functions avoid copies by working with a pointer and move semantics. | // These functions avoid copies by working with a pointer and move semantics. | ||||
#define TYPE(T) \ | #define TYPE(T) \ | ||||
template bool GUI<T>::HasSetting(const IGUIObject* pObject, const CStr& Setting); \ | |||||
template T& GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting); \ | |||||
template PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value); \ | template PSRETURN GUI<T>::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value); \ | ||||
template PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, T& Value, const bool& SkipMessage); \ | template PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, T& Value, const bool& SkipMessage); \ | ||||
template class CGUISetting<T>; \ | template class CGUISetting<T>; \ | ||||
#include "GUItypes.h" | #include "GUItypes.h" | ||||
#undef TYPE | #undef TYPE | ||||
// Copying functions - discouraged except for primitives. | // Copying functions - discouraged except for primitives. | ||||
#define TYPE(T) \ | #define TYPE(T) \ | ||||
template PSRETURN GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value); \ | template PSRETURN GUI<T>::GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value); \ | ||||
template PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage); \ | template PSRETURN GUI<T>::SetSetting(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage); \ | ||||
#define GUITYPE_IGNORE_NONCOPYABLE | #define GUITYPE_IGNORE_NONCOPYABLE | ||||
#include "GUItypes.h" | #include "GUItypes.h" | ||||
#undef GUITYPE_IGNORE_NONCOPYABLE | #undef GUITYPE_IGNORE_NONCOPYABLE | ||||
#undef TYPE | #undef TYPE |
Wildfire Games · Phabricator