llconfirmationmanager.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLCONFIRMATIONMANAGER_H
00033 #define LL_LLCONFIRMATIONMANAGER_H
00034 
00035 class LLConfirmationManager
00036 {
00037 public:
00038         class ListenerBase
00039         {
00040         public:
00041                 virtual ~ListenerBase();
00042                 virtual void confirmed(const std::string& password) = 0;
00043         };
00044 
00045         enum Type { TYPE_NONE, TYPE_CLICK, TYPE_PASSWORD };
00046         
00047         static void confirm(Type type,
00048                 const std::string& purchase, ListenerBase* listener);
00049         static void confirm(const std::string& type,
00050                 const std::string& purchase, ListenerBase* listener);
00051                 // note: these take control of, and delete the listener when done
00052 
00053         template <class T>
00054         class Listener : public ListenerBase
00055         {
00056         public:
00057                 typedef void (T::*ConfirmationMemberFunction)(const std::string&);
00058                 
00059                 Listener(T& object, ConfirmationMemberFunction function)
00060                         : mObject(object), mFunction(function)
00061                         { }
00062                 
00063                 void confirmed(const std::string& password)
00064                 {
00065                         (mObject.*mFunction)(password);
00066                 }
00067                 
00068         private:
00069                 T& mObject;
00070                 ConfirmationMemberFunction mFunction;
00071         };
00072 
00073         template <class T>
00074         static void confirm(Type type,
00075                 const std::string& action,
00076                 T& obj, void(T::*func)(const std::string&))
00077         {
00078                 confirm(type, action, new Listener<T>(obj, func));
00079         }
00080         
00081         template <class T>
00082         static void confirm(const std::string& type,
00083                 const std::string& action,
00084                 T& obj, void(T::*func)(const std::string&))
00085         {
00086                 confirm(type, action, new Listener<T>(obj, func));
00087         }               
00088 };
00089 
00090 #endif 

Generated on Thu Jul 1 06:08:22 2010 for Second Life Viewer by  doxygen 1.4.7