PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/lluseroperation.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 97 lines | 42 code | 19 blank | 36 comment | 0 complexity | 3571cb17fcf8c3f14ae3b5c6d79059ed MD5 | raw file
 1/** 
 2 * @file lluseroperation.h
 3 * @brief LLUserOperation class header file - used for message based
 4 * transaction. For example, L$ transactions.
 5 *
 6 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
 7 * Second Life Viewer Source Code
 8 * Copyright (C) 2010, Linden Research, Inc.
 9 * 
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation;
13 * version 2.1 of the License only.
14 * 
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * Lesser General Public License for more details.
19 * 
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 * 
24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
25 * $/LicenseInfo$
26 */
27
28#ifndef LL_LLUSEROPERATION_H
29#define LL_LLUSEROPERATION_H
30
31#include "lluuid.h"
32#include "llframetimer.h"
33
34#include <map>
35
36class LLUserOperation
37{
38public:
39	LLUserOperation(const LLUUID& agent_id);
40	LLUserOperation(const LLUUID& agent_id, const LLUUID& transaction_id);
41	virtual ~LLUserOperation();
42
43	const LLUUID& getTransactionID() const { return mTransactionID; }
44	const LLUUID& getAgentID() const { return mAgentID; }
45
46	// Operation never got necessary data, so expired	
47	virtual BOOL isExpired();
48
49	// ability to mark this operation as never expiring.
50	void SetNoExpireFlag(const BOOL flag);
51
52	// Send request to the dataserver
53	virtual void sendRequest() = 0;
54
55	// Run the operation. This will only be called in the case of an
56	// actual success or failure of the operation.
57	virtual BOOL execute(BOOL transaction_success) = 0;	
58
59	// This method is called when the user op has expired, and is
60	// about to be deleted by the manager. This gives the user op the
61	// ability to nack someone when the user op is never evaluated
62	virtual void expire();
63
64protected:
65	LLUserOperation();
66	
67protected:
68	LLUUID mAgentID;
69	LLUUID mTransactionID;
70	LLFrameTimer mTimer;
71	BOOL   mNoExpire;			// this is used for operations that expect an answer and will wait till it gets one. 
72};
73
74
75class LLUserOperationMgr
76{
77public:
78	LLUserOperationMgr();
79	~LLUserOperationMgr();
80
81	void addOperation(LLUserOperation* op);
82	LLUserOperation* findOperation(const LLUUID& transaction_id);
83	BOOL deleteOperation(LLUserOperation* op);
84
85	// Call this method every once in a while to clean up old
86	// transactions.
87	void deleteExpiredOperations();
88	
89private:
90	typedef std::map<LLUUID, LLUserOperation*> user_operation_list_t;
91	user_operation_list_t mUserOperationList;
92	LLUUID mLastOperationConsidered;
93};
94
95extern LLUserOperationMgr* gUserOperationMgr;
96
97#endif // LL_LLUSEROPERATION_H