MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_WIDGET_USER_DATA_H__ 00023 #define __MYGUI_WIDGET_USER_DATA_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_Any.h" 00027 00028 namespace MyGUI 00029 { 00030 00032 class MYGUI_EXPORT UserData 00033 { 00034 public: 00035 UserData(); 00036 virtual ~UserData(); 00037 00039 void setUserString(const std::string& _key, const std::string& _value); 00040 00042 const std::string& getUserString(const std::string& _key) const; 00043 00045 const MapString& getUserStrings() const; 00046 00048 bool clearUserString(const std::string& _key); 00049 00051 bool isUserString(const std::string& _key) const; 00052 00054 void clearUserStrings(); 00055 00057 void setUserData(Any _data); 00058 00060 template <typename ValueType> 00061 ValueType* getUserData(bool _throw = true) 00062 { 00063 return mUserData.castType<ValueType>(_throw); 00064 } 00065 00066 /*internal:*/ 00067 void _setInternalData(Any _data); 00068 00069 template <typename ValueType> 00070 ValueType* _getInternalData(bool _throw = true) 00071 { 00072 return mInternalData.castType<ValueType>(_throw); 00073 } 00074 00075 private: 00076 // пользовательские данные 00077 MapString mMapUserString; 00078 Any mUserData; 00079 00080 // для внутренниего использования 00081 Any mInternalData; 00082 }; 00083 00084 } // namespace MyGUI 00085 00086 #endif // __MYGUI_WIDGET_USER_DATA_H__