PageRenderTime 17ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llcompilequeue.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 228 lines | 107 code | 46 blank | 75 comment | 0 complexity | d38175eeabf74a76c2257fa7e7934cec MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llcompilequeue.h
  3. * @brief LLCompileQueue class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLCOMPILEQUEUE_H
  27. #define LL_LLCOMPILEQUEUE_H
  28. #include "lldarray.h"
  29. #include "llinventory.h"
  30. #include "llviewerobject.h"
  31. #include "llvoinventorylistener.h"
  32. #include "llmap.h"
  33. #include "lluuid.h"
  34. #include "llfloater.h"
  35. #include "llscrolllistctrl.h"
  36. #include "llviewerinventory.h"
  37. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. // Class LLFloaterScriptQueue
  39. //
  40. // This class provides a mechanism of adding objects to a list that
  41. // will go through and execute action for the scripts on each object. The
  42. // objects will be accessed serially and the scripts may be
  43. // manipulated in parallel. For example, selecting two objects each
  44. // with three scripts will result in the first object having all three
  45. // scripts manipulated.
  46. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. class LLFloaterScriptQueue : public LLFloater, public LLVOInventoryListener
  48. {
  49. public:
  50. LLFloaterScriptQueue(const LLSD& key);
  51. virtual ~LLFloaterScriptQueue();
  52. /*virtual*/ BOOL postBuild();
  53. void setMono(bool mono) { mMono = mono; }
  54. // addObject() accepts an object id.
  55. void addObject(const LLUUID& id);
  56. // start() returns TRUE if the queue has started, otherwise FALSE.
  57. BOOL start();
  58. protected:
  59. // This is the callback method for the viewer object currently
  60. // being worked on.
  61. /*virtual*/ void inventoryChanged(LLViewerObject* obj,
  62. LLInventoryObject::object_list_t* inv,
  63. S32 serial_num,
  64. void* queue);
  65. // This is called by inventoryChanged
  66. virtual void handleInventory(LLViewerObject* viewer_obj,
  67. LLInventoryObject::object_list_t* inv) = 0;
  68. static void onCloseBtn(void* user_data);
  69. // returns true if this is done
  70. BOOL isDone() const;
  71. // go to the next object. If no objects left, it falls out
  72. // silently and waits to be killed by the deleteIfDone() callback.
  73. BOOL nextObject();
  74. BOOL popNext();
  75. void setStartString(const std::string& s) { mStartString = s; }
  76. protected:
  77. // UI
  78. LLScrollListCtrl* mMessages;
  79. LLButton* mCloseBtn;
  80. // Object Queue
  81. LLDynamicArray<LLUUID> mObjectIDs;
  82. LLUUID mCurrentObjectID;
  83. bool mDone;
  84. std::string mStartString;
  85. bool mMono;
  86. };
  87. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  88. // Class LLFloaterCompileQueue
  89. //
  90. // This script queue will recompile each script.
  91. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  92. struct LLCompileQueueData
  93. {
  94. LLUUID mQueueID;
  95. LLUUID mItemId;
  96. LLCompileQueueData(const LLUUID& q_id, const LLUUID& item_id) :
  97. mQueueID(q_id), mItemId(item_id) {}
  98. };
  99. class LLAssetUploadQueue;
  100. class LLFloaterCompileQueue : public LLFloaterScriptQueue
  101. {
  102. friend class LLFloaterReg;
  103. public:
  104. static void onSaveBytecodeComplete(const LLUUID& asset_id,
  105. void* user_data,
  106. S32 status);
  107. // remove any object in mScriptScripts with the matching uuid.
  108. void removeItemByItemID(const LLUUID& item_id);
  109. LLAssetUploadQueue* getUploadQueue() { return mUploadQueue; }
  110. protected:
  111. LLFloaterCompileQueue(const LLSD& key);
  112. virtual ~LLFloaterCompileQueue();
  113. // This is called by inventoryChanged
  114. virtual void handleInventory(LLViewerObject* viewer_obj,
  115. LLInventoryObject::object_list_t* inv);
  116. // This is the callback for when each script arrives
  117. static void scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
  118. LLAssetType::EType type,
  119. void* user_data, S32 status, LLExtStat ext_status);
  120. static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status);
  121. static void onSaveBytecodeComplete(const LLUUID& asset_id,
  122. void* user_data,
  123. S32 status, LLExtStat ext_status);
  124. // compile the file given and save it out.
  125. void compile(const std::string& filename, const LLUUID& asset_id);
  126. // remove any object in mScriptScripts with the matching uuid.
  127. void removeItemByAssetID(const LLUUID& asset_id);
  128. // save the items indicated by the item id.
  129. void saveItemByItemID(const LLUUID& item_id);
  130. // find InventoryItem given item id.
  131. const LLInventoryItem* findItemByItemID(const LLUUID& item_id) const;
  132. protected:
  133. LLViewerInventoryItem::item_array_t mCurrentScripts;
  134. private:
  135. LLAssetUploadQueue* mUploadQueue;
  136. };
  137. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  138. // Class LLFloaterResetQueue
  139. //
  140. // This script queue will reset each script.
  141. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. class LLFloaterResetQueue : public LLFloaterScriptQueue
  143. {
  144. friend class LLFloaterReg;
  145. protected:
  146. LLFloaterResetQueue(const LLSD& key);
  147. virtual ~LLFloaterResetQueue();
  148. // This is called by inventoryChanged
  149. virtual void handleInventory(LLViewerObject* viewer_obj,
  150. LLInventoryObject::object_list_t* inv);
  151. };
  152. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  153. // Class LLFloaterRunQueue
  154. //
  155. // This script queue will set each script as running.
  156. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  157. class LLFloaterRunQueue : public LLFloaterScriptQueue
  158. {
  159. friend class LLFloaterReg;
  160. protected:
  161. LLFloaterRunQueue(const LLSD& key);
  162. virtual ~LLFloaterRunQueue();
  163. // This is called by inventoryChanged
  164. virtual void handleInventory(LLViewerObject* viewer_obj,
  165. LLInventoryObject::object_list_t* inv);
  166. };
  167. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  168. // Class LLFloaterNotRunQueue
  169. //
  170. // This script queue will set each script as not running.
  171. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  172. class LLFloaterNotRunQueue : public LLFloaterScriptQueue
  173. {
  174. friend class LLFloaterReg;
  175. protected:
  176. LLFloaterNotRunQueue(const LLSD& key);
  177. virtual ~LLFloaterNotRunQueue();
  178. // This is called by inventoryChanged
  179. virtual void handleInventory(LLViewerObject* viewer_obj,
  180. LLInventoryObject::object_list_t* inv);
  181. };
  182. #endif // LL_LLCOMPILEQUEUE_H