PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms 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
  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
 27#ifndef LL_LLCOMPILEQUEUE_H
 28#define LL_LLCOMPILEQUEUE_H
 29
 30#include "lldarray.h"
 31#include "llinventory.h"
 32#include "llviewerobject.h"
 33#include "llvoinventorylistener.h"
 34#include "llmap.h"
 35#include "lluuid.h"
 36
 37#include "llfloater.h"
 38#include "llscrolllistctrl.h"
 39
 40#include "llviewerinventory.h"
 41
 42//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 43// Class LLFloaterScriptQueue
 44//
 45// This class provides a mechanism of adding objects to a list that
 46// will go through and execute action for the scripts on each object. The
 47// objects will be accessed serially and the scripts may be
 48// manipulated in parallel. For example, selecting two objects each
 49// with three scripts will result in the first object having all three
 50// scripts manipulated.
 51//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 52
 53class LLFloaterScriptQueue : public LLFloater, public LLVOInventoryListener
 54{
 55public:
 56	LLFloaterScriptQueue(const LLSD& key);
 57	virtual ~LLFloaterScriptQueue();
 58
 59	/*virtual*/ BOOL postBuild();
 60	
 61	void setMono(bool mono) { mMono = mono; }
 62	
 63	// addObject() accepts an object id.
 64	void addObject(const LLUUID& id);
 65
 66	// start() returns TRUE if the queue has started, otherwise FALSE.
 67	BOOL start();
 68	
 69protected:
 70	// This is the callback method for the viewer object currently
 71	// being worked on.
 72	/*virtual*/ void inventoryChanged(LLViewerObject* obj,
 73								 LLInventoryObject::object_list_t* inv,
 74								 S32 serial_num,
 75								 void* queue);
 76	
 77	// This is called by inventoryChanged
 78	virtual void handleInventory(LLViewerObject* viewer_obj,
 79								LLInventoryObject::object_list_t* inv) = 0;
 80
 81	static void onCloseBtn(void* user_data);
 82
 83	// returns true if this is done
 84	BOOL isDone() const;
 85
 86	// go to the next object. If no objects left, it falls out
 87	// silently and waits to be killed by the deleteIfDone() callback.
 88	BOOL nextObject();
 89	BOOL popNext();
 90
 91	void setStartString(const std::string& s) { mStartString = s; }
 92	
 93protected:
 94	// UI
 95	LLScrollListCtrl* mMessages;
 96	LLButton* mCloseBtn;
 97
 98	// Object Queue
 99	LLDynamicArray<LLUUID> mObjectIDs;
100	LLUUID mCurrentObjectID;
101	bool mDone;
102
103	std::string mStartString;
104	bool mMono;
105};
106
107//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108// Class LLFloaterCompileQueue
109//
110// This script queue will recompile each script.
111//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
112
113struct LLCompileQueueData
114{
115	LLUUID mQueueID;
116	LLUUID mItemId;
117	LLCompileQueueData(const LLUUID& q_id, const LLUUID& item_id) :
118		mQueueID(q_id), mItemId(item_id) {}
119};
120
121class LLAssetUploadQueue;
122
123class LLFloaterCompileQueue : public LLFloaterScriptQueue
124{
125	friend class LLFloaterReg;
126public:
127	static void onSaveBytecodeComplete(const LLUUID& asset_id,
128									void* user_data,
129									S32 status);
130									
131	// remove any object in mScriptScripts with the matching uuid.
132	void removeItemByItemID(const LLUUID& item_id);
133	
134	LLAssetUploadQueue* getUploadQueue() { return mUploadQueue; }
135
136protected:
137	LLFloaterCompileQueue(const LLSD& key);
138	virtual ~LLFloaterCompileQueue();
139	
140	// This is called by inventoryChanged
141	virtual void handleInventory(LLViewerObject* viewer_obj,
142								LLInventoryObject::object_list_t* inv);
143
144	// This is the callback for when each script arrives
145	static void scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
146								LLAssetType::EType type,
147								void* user_data, S32 status, LLExtStat ext_status);
148
149	static void onSaveTextComplete(const LLUUID& asset_id, void* user_data, S32 status, LLExtStat ext_status);
150
151	static void onSaveBytecodeComplete(const LLUUID& asset_id,
152									   void* user_data,
153									   S32 status, LLExtStat ext_status);
154
155	// compile the file given and save it out.
156	void compile(const std::string& filename, const LLUUID& asset_id);
157	
158	// remove any object in mScriptScripts with the matching uuid.
159	void removeItemByAssetID(const LLUUID& asset_id);
160
161	// save the items indicated by the item id.
162	void saveItemByItemID(const LLUUID& item_id);
163
164	// find InventoryItem given item id.
165	const LLInventoryItem* findItemByItemID(const LLUUID& item_id) const;
166	
167protected:
168	LLViewerInventoryItem::item_array_t mCurrentScripts;
169
170private:
171	LLAssetUploadQueue* mUploadQueue;
172};
173
174//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175// Class LLFloaterResetQueue
176//
177// This script queue will reset each script.
178//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179
180class LLFloaterResetQueue : public LLFloaterScriptQueue
181{
182	friend class LLFloaterReg;
183protected:
184	LLFloaterResetQueue(const LLSD& key);
185	virtual ~LLFloaterResetQueue();
186	
187	// This is called by inventoryChanged
188	virtual void handleInventory(LLViewerObject* viewer_obj,
189								LLInventoryObject::object_list_t* inv);
190};
191
192//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193// Class LLFloaterRunQueue
194//
195// This script queue will set each script as running.
196//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197
198class LLFloaterRunQueue : public LLFloaterScriptQueue
199{
200	friend class LLFloaterReg;
201protected:
202	LLFloaterRunQueue(const LLSD& key);
203	virtual ~LLFloaterRunQueue();
204	
205	// This is called by inventoryChanged
206	virtual void handleInventory(LLViewerObject* viewer_obj,
207								LLInventoryObject::object_list_t* inv);
208};
209
210//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
211// Class LLFloaterNotRunQueue
212//
213// This script queue will set each script as not running.
214//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215
216class LLFloaterNotRunQueue : public LLFloaterScriptQueue
217{
218	friend class LLFloaterReg;
219protected:
220	LLFloaterNotRunQueue(const LLSD& key);
221	virtual ~LLFloaterNotRunQueue();
222	
223	// This is called by inventoryChanged
224	virtual void handleInventory(LLViewerObject* viewer_obj,
225								LLInventoryObject::object_list_t* inv);
226};
227
228#endif // LL_LLCOMPILEQUEUE_H