/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. #ifndef LL_LLUSEROPERATION_H
  28. #define LL_LLUSEROPERATION_H
  29. #include "lluuid.h"
  30. #include "llframetimer.h"
  31. #include <map>
  32. class LLUserOperation
  33. {
  34. public:
  35. LLUserOperation(const LLUUID& agent_id);
  36. LLUserOperation(const LLUUID& agent_id, const LLUUID& transaction_id);
  37. virtual ~LLUserOperation();
  38. const LLUUID& getTransactionID() const { return mTransactionID; }
  39. const LLUUID& getAgentID() const { return mAgentID; }
  40. // Operation never got necessary data, so expired
  41. virtual BOOL isExpired();
  42. // ability to mark this operation as never expiring.
  43. void SetNoExpireFlag(const BOOL flag);
  44. // Send request to the dataserver
  45. virtual void sendRequest() = 0;
  46. // Run the operation. This will only be called in the case of an
  47. // actual success or failure of the operation.
  48. virtual BOOL execute(BOOL transaction_success) = 0;
  49. // This method is called when the user op has expired, and is
  50. // about to be deleted by the manager. This gives the user op the
  51. // ability to nack someone when the user op is never evaluated
  52. virtual void expire();
  53. protected:
  54. LLUserOperation();
  55. protected:
  56. LLUUID mAgentID;
  57. LLUUID mTransactionID;
  58. LLFrameTimer mTimer;
  59. BOOL mNoExpire; // this is used for operations that expect an answer and will wait till it gets one.
  60. };
  61. class LLUserOperationMgr
  62. {
  63. public:
  64. LLUserOperationMgr();
  65. ~LLUserOperationMgr();
  66. void addOperation(LLUserOperation* op);
  67. LLUserOperation* findOperation(const LLUUID& transaction_id);
  68. BOOL deleteOperation(LLUserOperation* op);
  69. // Call this method every once in a while to clean up old
  70. // transactions.
  71. void deleteExpiredOperations();
  72. private:
  73. typedef std::map<LLUUID, LLUserOperation*> user_operation_list_t;
  74. user_operation_list_t mUserOperationList;
  75. LLUUID mLastOperationConsidered;
  76. };
  77. extern LLUserOperationMgr* gUserOperationMgr;
  78. #endif // LL_LLUSEROPERATION_H