lluseroperation.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLUSEROPERATION_H
00034 #define LL_LLUSEROPERATION_H
00035 
00036 #include "lluuid.h"
00037 #include "llframetimer.h"
00038 
00039 #include <map>
00040 
00041 class LLUserOperation
00042 {
00043 public:
00044         LLUserOperation(const LLUUID& agent_id);
00045         LLUserOperation(const LLUUID& agent_id, const LLUUID& transaction_id);
00046         virtual ~LLUserOperation();
00047 
00048         const LLUUID& getTransactionID() const { return mTransactionID; }
00049         const LLUUID& getAgentID() const { return mAgentID; }
00050 
00051         // Operation never got necessary data, so expired       
00052         virtual BOOL isExpired();
00053 
00054         // ability to mark this operation as never expiring.
00055         void SetNoExpireFlag(const BOOL flag);
00056 
00057         // Send request to the dataserver
00058         virtual void sendRequest() = 0;
00059 
00060         // Run the operation. This will only be called in the case of an
00061         // actual success or failure of the operation.
00062         virtual BOOL execute(BOOL transaction_success) = 0;     
00063 
00064         // This method is called when the user op has expired, and is
00065         // about to be deleted by the manager. This gives the user op the
00066         // ability to nack someone when the user op is never evaluated
00067         virtual void expire();
00068 
00069 protected:
00070         LLUserOperation();
00071         
00072 protected:
00073         LLUUID mAgentID;
00074         LLUUID mTransactionID;
00075         LLFrameTimer mTimer;
00076         BOOL   mNoExpire;                       // this is used for operations that expect an answer and will wait till it gets one. 
00077 };
00078 
00079 
00080 class LLUserOperationMgr
00081 {
00082 public:
00083         LLUserOperationMgr();
00084         ~LLUserOperationMgr();
00085 
00086         void addOperation(LLUserOperation* op);
00087         LLUserOperation* findOperation(const LLUUID& transaction_id);
00088         BOOL deleteOperation(LLUserOperation* op);
00089 
00090         // Call this method every once in a while to clean up old
00091         // transactions.
00092         void deleteExpiredOperations();
00093         
00094 private:
00095         typedef std::map<LLUUID, LLUserOperation*> user_operation_list_t;
00096         user_operation_list_t mUserOperationList;
00097         LLUUID mLastOperationConsidered;
00098 };
00099 
00100 extern LLUserOperationMgr* gUserOperationMgr;
00101 
00102 #endif // LL_LLUSEROPERATION_H

Generated on Thu Jul 1 06:09:24 2010 for Second Life Viewer by  doxygen 1.4.7