MyGUI  3.2.1
MyGUI_WidgetUserData.h
Go to the documentation of this file.
00001 /*
00002  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
00003  * Distributed under the MIT License
00004  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
00005  */
00006 
00007 #ifndef __MYGUI_WIDGET_USER_DATA_H__
00008 #define __MYGUI_WIDGET_USER_DATA_H__
00009 
00010 #include "MyGUI_Prerequest.h"
00011 #include "MyGUI_Any.h"
00012 
00013 namespace MyGUI
00014 {
00015 
00017     class MYGUI_EXPORT UserData
00018     {
00019     public:
00020         UserData();
00021         virtual ~UserData();
00022 
00024         void setUserString(const std::string& _key, const std::string& _value);
00025 
00027         const std::string& getUserString(const std::string& _key) const;
00028 
00030         const MapString& getUserStrings() const;
00031 
00033         bool clearUserString(const std::string& _key);
00034 
00036         bool isUserString(const std::string& _key) const;
00037 
00039         void clearUserStrings();
00040 
00042         void setUserData(Any _data);
00043 
00045         template <typename ValueType>
00046         ValueType* getUserData(bool _throw = true) const
00047         {
00048             return mUserData.castType<ValueType>(_throw);
00049         }
00050 
00051         /*internal:*/
00052         void _setInternalData(Any _data);
00053 
00054         template <typename ValueType>
00055         ValueType* _getInternalData(bool _throw = true) const
00056         {
00057             return mInternalData.castType<ValueType>(_throw);
00058         }
00059 
00060     private:
00061         // пользовательские данные
00062         MapString mMapUserString;
00063         Any mUserData;
00064 
00065         // для внутренниего использования
00066         Any mInternalData;
00067     };
00068 
00069 } // namespace MyGUI
00070 
00071 #endif // __MYGUI_WIDGET_USER_DATA_H__