[rkward-cvs] SF.net SVN: rkward: [793] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Oct 2 21:40:28 UTC 2006


Revision: 793
          http://svn.sourceforge.net/rkward/?rev=793&view=rev
Author:   tfry
Date:     2006-10-02 14:40:13 -0700 (Mon, 02 Oct 2006)

Log Message:
-----------
Committing REnvironmentObject using code. Still buggy and not pretty, but fairly good so far.
Some remaining bugs:
Creating new objects (new data.frame editor) does not respect envirs
lots of failed asserts to investigate

Modified Paths:
--------------
    trunk/rkward/TODO
    trunk/rkward/rkward/core/Makefile.am
    trunk/rkward/rkward/core/rcontainerobject.cpp
    trunk/rkward/rkward/core/rcontainerobject.h
    trunk/rkward/rkward/core/renvironmentobject.cpp
    trunk/rkward/rkward/core/renvironmentobject.h
    trunk/rkward/rkward/core/robject.cpp
    trunk/rkward/rkward/core/robject.h
    trunk/rkward/rkward/core/robjectlist.cpp
    trunk/rkward/rkward/core/robjectlist.h
    trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
    trunk/rkward/rkward/misc/rkobjectlistview.cpp
    trunk/rkward/rkward/misc/rkobjectlistview.h

Modified: trunk/rkward/TODO
===================================================================
--- trunk/rkward/TODO	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/TODO	2006-10-02 21:40:13 UTC (rev 793)
@@ -44,7 +44,7 @@
 		- the UI should probably be simplified somehow. But how? All in a single list with "filter"? Ask for ideas/look at other apps
 			- this will be very hard to do with the current Qt. We'd really need several checkboxes *within* a QListViewItem. Tackle this when/after porting to Qt4
 	- RObjectListView
-		- use icons to mark up the different base types
+		- use better icons to mark up the different base types
 	- RKConsole:
 		- Console should start a command chain when submitting a batch of pasted commands
 		- Better yet, the commands might be autosplit in the backend. Need to think about how to design this correctly, though

Modified: trunk/rkward/rkward/core/Makefile.am
===================================================================
--- trunk/rkward/rkward/core/Makefile.am	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/Makefile.am	2006-10-02 21:40:13 UTC (rev 793)
@@ -2,6 +2,6 @@
 METASOURCES = AUTO
 noinst_LIBRARIES =  libcore.a
 libcore_a_SOURCES = rkvariable.cpp robjectlist.cpp robject.cpp rcontainerobject.cpp rkmodificationtracker.cpp \
-	rfunctionobject.cpp
+	rfunctionobject.cpp renvironmentobject.cpp
 noinst_HEADERS = rkvariable.h robjectlist.h robject.h rcontainerobject.h rkmodificationtracker.h \
-	rfunctionobject.h
+	rfunctionobject.h renvironmentobject.h

Modified: trunk/rkward/rkward/core/rcontainerobject.cpp
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.cpp	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/rcontainerobject.cpp	2006-10-02 21:40:13 UTC (rev 793)
@@ -244,7 +244,7 @@
 	RObjectMap::iterator it = childmap.find (object->getShortName ());
 	RK_ASSERT (it.data () == object);
 	
-	RCommand *command = new RCommand ("rk.rename.in.container (" + getFullName () + ", \"" + object->getShortName () + "\", \"" + new_name + "\")", RCommand::App | RCommand::Sync);
+	RCommand *command = new RCommand (renameChildCommand (object, new_name), RCommand::App | RCommand::Sync);
 	RKGlobals::rInterface ()->issueCommand (command, 0);
 	
 	childmap.remove (it.key ());
@@ -257,7 +257,7 @@
 	RK_TRACE (OBJECTS);
 
 	if (!removed_in_workspace) {
-		RCommand *command = new RCommand (object->getFullName () + " <- NULL", RCommand::App | RCommand::Sync);
+		RCommand *command = new RCommand (removeChildCommand (object), RCommand::App | RCommand::Sync);
 		RKGlobals::rInterface ()->issueCommand (command, 0);
 	}
 
@@ -271,6 +271,18 @@
 	delete object;
 }
 
+QString RContainerObject::removeChildCommand (RObject *object) {
+	RK_TRACE (OBJECTS);
+
+	return (object->getFullName () + " <- NULL");
+}
+
+QString RContainerObject::renameChildCommand (RObject *object, const QString &new_name) {
+	RK_TRACE (OBJECTS);
+
+	return ("rk.rename.in.container (" + getFullName () + ", \"" + object->getShortName () + "\", \"" + new_name + "\")");
+}
+
 bool RContainerObject::isParentOf (RObject *object, bool recursive) {
 	RK_TRACE (OBJECTS);
 

Modified: trunk/rkward/rkward/core/rcontainerobject.h
===================================================================
--- trunk/rkward/rkward/core/rcontainerobject.h	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/rcontainerobject.h	2006-10-02 21:40:13 UTC (rev 793)
@@ -62,7 +62,7 @@
 	QString validizeName (const QString &child_name);
 
 	/** reimplemented from RObject to actually search for the object */
-	RObject *findObject (const QString &name, bool is_canonified=false);
+	virtual RObject *findObject (const QString &name, bool is_canonified=false);
 protected:
 	void updateChildren (RData *new_children);
 	RObjectMap childmap;
@@ -71,6 +71,8 @@
 	friend class RObject;
 	virtual void renameChild (RObject *object, const QString &new_name);
 	virtual void removeChild (RObject *object, bool removed_in_workspace);
+	virtual QString removeChildCommand (RObject *object);
+	virtual QString renameChildCommand (RObject *object, const QString &new_name);
 };
 
 #endif

Modified: trunk/rkward/rkward/core/renvironmentobject.cpp
===================================================================
--- trunk/rkward/rkward/core/renvironmentobject.cpp	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/renvironmentobject.cpp	2006-10-02 21:40:13 UTC (rev 793)
@@ -16,6 +16,9 @@
  ***************************************************************************/
 
 #include "renvironmentobject.h"
+#include "robjectlist.h"
+#include "../rbackend/rinterface.h"
+#include "../rkglobals.h"
 
 #include "../debug.h"
 
@@ -23,8 +26,8 @@
 	RK_TRACE (OBJECTS);
 
 	type = Environment;
-	if (name == ".GlobalEnv") {
-		type |= GlobalEnv;
+	if (parent != RKGlobals::rObjectList ()) {
+		type |= EnvironmentVar;
 	}
 
 	// TODO: determine namespace_name
@@ -47,7 +50,7 @@
 
 	if (type & GlobalEnv) return (short_child_name);
 	if (type & EnvironmentVar) return (name + "$" + short_child_name);
-	return (namespace_name + "::" + short_child_name);
+	return (namespace_name + "::" + RObject::rQuote (short_child_name));
 }
 
 void REnvironmentObject::writeMetaData (RCommandChain *chain) {
@@ -56,28 +59,28 @@
 	if (type & EnvironmentVar) RContainerObject::writeMetaData (chain);
 }
 
-QString REnvironmentObject::listChildrenCommand () {
+void REnvironmentObject::updateFromR () {
 	RK_TRACE (OBJECTS);
 
-	return ("ls (as.environment (" + getFullName () + ", all.names=TRUE)");
+	RCommand *command = new RCommand (".rk.get.environment.structure (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStructuredData, QString::null, this, ROBJECT_UDPATE_STRUCTURE_COMMAND);
+	RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
 }
 
+bool REnvironmentObject::updateStructure (RData *new_data) {
+	RK_TRACE (OBJECTS);
+	RK_ASSERT (new_data->getDataType () == RData::StructureVector);
+
+//	if (!RObject::updateStructure (new_data)) return false;		// this is an environment object. nothing to update
+	updateChildren (new_data);		// children are directly in the structure
+
+	return true;
+}
+
 void REnvironmentObject::renameChild (RObject *object, const QString &new_name) {
 	RK_TRACE (OBJECTS);
 
 	if (type & GlobalEnv) {
-		RObjectMap::iterator it = childmap.find (object->getShortName ());
-		RK_ASSERT (it.data () == object);
-		
-		RCommand *command = new RCommand (makeChildName (new_name) + " <- " + object->getFullName ());
-		RKGlobals::rInterface ()->issueCommand (command, 0);
-		command = new RCommand ("remove (" + object->getFullName () + ")", RCommand::App | RCommand::Sync);
-		RKGlobals::rInterface ()->issueCommand (command, 0);
-		
-		childmap.remove (it);
-		childmap.insert (new_name, object);
-	
-		object->name = new_name;
+		RContainerObject::renameChild (object, new_name);
 	} else {
 		RK_ASSERT (false);
 	}
@@ -87,17 +90,20 @@
 	RK_TRACE (OBJECTS);
 
 	if ((type & GlobalEnv) || removed_in_workspace) {
-		RObjectMap::iterator it = childmap.find (object->getShortName ());
-		RK_ASSERT (it.data () == object);
-		
-		if (!removed_in_workspace) {
-			RCommand *command = new RCommand ("remove (" + object->getFullName () + ")", RCommand::App | RCommand::Sync);
-			RKGlobals::rInterface ()->issueCommand (command, 0);
-		}
-		
-		childmap.remove (it);
-		delete object;
+		RContainerObject::removeChild (object, removed_in_workspace);
 	} else {
 		RK_ASSERT (false);
 	}
 }
+
+QString REnvironmentObject::renameChildCommand (RObject *object, const QString &new_name) {
+	RK_TRACE (OBJECTS);
+
+	return (makeChildName (new_name) + " <- " + object->getFullName () + "\n" + removeChildCommand (object));
+}
+
+QString REnvironmentObject::removeChildCommand (RObject *object) {
+	RK_TRACE (OBJECTS);
+
+	return ("remove (" + object->getFullName () + ")");
+}

Modified: trunk/rkward/rkward/core/renvironmentobject.h
===================================================================
--- trunk/rkward/rkward/core/renvironmentobject.h	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/renvironmentobject.h	2006-10-02 21:40:13 UTC (rev 793)
@@ -32,14 +32,14 @@
 	REnvironmentObject (RContainerObject *parent, const QString &name);
 	~REnvironmentObject ();
 
+	void updateFromR ();
+
 	QString getFullName ();
 	QString makeChildName (const QString &short_child_name);
 /** reimplemented from RContainerObject: If this is an environment var, call RContainerObject::writeMetaData (). Else, do nothing. An environment has no meta data. */
 	void writeMetaData (RCommandChain *chain);
 
 	bool isGlobalEnv () { return (type & GlobalEnv); };
-
-	QString listChildrenCommand ();
 /** 
 # search ()
 or rather
@@ -64,10 +64,16 @@
 RContainerObject::canonifyName
 */
 protected:
+	friend class RObjectList;
+	bool updateStructure (RData *new_data);
 /** reimplemented from RContainerObject to raise an assert if this is not the isGlobalEnv (). Otherwise calls "remove (objectname)" instead of objectname <- NULL" */
 	void renameChild (RObject *object, const QString &new_name);
 /** reimplemented from RContainerObject to raise an assert if this is not the isGlobalEnv (). Otherwise calls "remove (objectname)" instead of objectname <- NULL" */
 	void removeChild (RObject *object, bool removed_in_workspace);
+/// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
+	QString removeChildCommand (RObject *object);
+/// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
+	QString renameChildCommand (RObject *object, const QString &new_name);
 	QString namespace_name;
 };
  

Modified: trunk/rkward/rkward/core/robject.cpp
===================================================================
--- trunk/rkward/rkward/core/robject.cpp	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/robject.cpp	2006-10-02 21:40:13 UTC (rev 793)
@@ -38,7 +38,7 @@
 	data = 0;
 	classnames = 0;
 	num_classes = 0;
-	dimensions = 0;
+	dimensions = new int[1];	// safe initialization
 	num_dimensions = 0;
 }
 

Modified: trunk/rkward/rkward/core/robject.h
===================================================================
--- trunk/rkward/rkward/core/robject.h	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/robject.h	2006-10-02 21:40:13 UTC (rev 793)
@@ -161,6 +161,7 @@
 // why do I need those to compile? I thought they were derived classes!
 	friend class RContainerObject;
 	friend class RObjectList;
+	friend class REnvironmentObject;
 	RContainerObject *parent;
 	QString name;
 	int type;

Modified: trunk/rkward/rkward/core/robjectlist.cpp
===================================================================
--- trunk/rkward/rkward/core/robjectlist.cpp	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/robjectlist.cpp	2006-10-02 21:40:13 UTC (rev 793)
@@ -19,16 +19,15 @@
 #define AUTO_UPDATE_INTERVAL 10000
 #define UPDATE_DELAY_INTERVAL 500
 
-#define UPDATE_WORKSPACE_COMMAND 1
+#define ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND 1
+#define ROBJECTLIST_UDPATE_COMPLETE_COMMAND 2
 
 #include <qtimer.h>
 #include <qstringlist.h>
 
 #include <klocale.h>
 
-#include "rkvariable.h"
-#include "rfunctionobject.h"
-
+#include "renvironmentobject.h"
 #include "../rbackend/rinterface.h"
 #include "rkmodificationtracker.h"
 
@@ -47,6 +46,8 @@
 	type = RObject::Workspace;
 	
 	update_chain = 0;
+	toplevel_environments = 0;
+	num_toplevel_environments = 0;
 }
 
 RObjectList::~RObjectList () {
@@ -65,62 +66,176 @@
 	emit (updateStarted ());
 	update_chain = RKGlobals::rInterface ()->startChain (0);
 
-	RCommand *command = new RCommand (".rk.get.environment.structure (as.environment (\".GlobalEnv\"))", RCommand::App | RCommand::Sync | RCommand::GetStructuredData, QString::null, this, ROBJECT_UDPATE_STRUCTURE_COMMAND);
+	RCommand *command = new RCommand ("search ()", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND);
 	RKGlobals::rInterface ()->issueCommand (command, update_chain);
 }
 
-bool RObjectList::updateStructure (RData *new_data) {
+void RObjectList::rCommandDone (RCommand *command) {
 	RK_TRACE (OBJECTS);
-	RK_ASSERT (new_data->getDataType () == RData::StructureVector);
 
-//	if (!RObject::updateStructure (new_data)) return false;		// this is the workspace object. nothing to update
-	updateChildren (new_data);		// children are directly in the structure
+	if (command->getFlags () == ROBJECTLIST_UDPATE_ENVIRONMENTS_COMMAND) {
+		unsigned int num_new_environments = command->getDataLength ();
+		RK_ASSERT (command->getDataType () == RData::StringVector);
+		RK_ASSERT (num_new_environments >= 2);
+		QString *new_environments = command->getStringVector ();
 
-	RK_ASSERT (update_chain);
-	RKGlobals::rInterface ()->closeChain (update_chain);
-	update_chain = 0;
+		updateEnvironments (new_environments, num_new_environments);
 
-	RK_DO (qDebug ("object list update complete"), OBJECTS, DL_DEBUG);
-	emit (updateComplete ());
+		RKGlobals::rInterface ()->issueCommand (QString (), RCommand::App | RCommand::Sync | RCommand::EmptyCommand, QString (), this, ROBJECTLIST_UDPATE_COMPLETE_COMMAND, update_chain);
+	} else if (command->getFlags () == ROBJECTLIST_UDPATE_COMPLETE_COMMAND) {
+		RK_ASSERT (update_chain);
+		RKGlobals::rInterface ()->closeChain (update_chain);
+		update_chain = 0;
+	
+		RK_DO (qDebug ("object list update complete"), OBJECTS, DL_DEBUG);
+		emit (updateComplete ());
+	} else {
+		RK_ASSERT (false);
+	}
+}
 
+void RObjectList::updateEnvironments (QString *env_names, unsigned int env_count) {
+	RK_TRACE (OBJECTS);
+
+	QValueList<REnvironmentObject *> removelist;
+
+	// check which envs are removed
+	// we could as well iterate over the childmap, but this is easier
+	for (unsigned int i = 0; i < num_toplevel_environments; ++i) {
+		bool found = false;
+		for (unsigned int j = 0; i < env_count; ++j) {
+			if (toplevel_environments[i]->getShortName () == env_names[j]) {
+				found = true;
+				break;
+			}
+		}
+		if (!found) removelist.append (toplevel_environments[i]);
+	}
+
+	// remove the environments which are gone
+	for (QValueList<REnvironmentObject *>::const_iterator it = removelist.constBegin (); it != removelist.constEnd (); ++it) {
+		removeChild (*it, true);
+	}
+
+	// find which items are new
+	for (unsigned int i = 0; i < env_count; ++i) {
+		QString name = env_names[i];
+		if (childmap.find (name) == childmap.end ()) {
+			REnvironmentObject *envobj = new REnvironmentObject (this, env_names[i]);
+
+			if (name == ".GlobalEnv") {
+				envobj->type |= GlobalEnv;
+			} else if (name.contains (':')) {
+				envobj->namespace_name = name.section (':', 1);
+			} else if (name == "Autoloads") {
+				envobj->type |= GlobalEnv;              // this is wrong! but it's a temporary HACK to get things to work
+			}
+
+			childmap.insert (name, envobj);
+			RKGlobals::tracker ()->addObject (envobj, 0);
+			envobj->updateFromR ();
+		} else {
+			RObject *obj = childmap[name];
+			// for now, we only update the .GlobalEnv. All others we assume to be static
+			if (obj->isType (GlobalEnv)) {
+				obj->updateFromR ();
+			}
+		}
+	}
+
+	// set the new list of environments in the correct order
+	delete [] toplevel_environments;
+	toplevel_environments = new REnvironmentObject*[env_count];
+	num_toplevel_environments = env_count;
+	for (unsigned int i = 0; i < env_count; ++i) {
+		RObject *obj = childmap[env_names[i]];
+		RK_ASSERT (obj);
+		RK_ASSERT (obj->isType (Environment));
+
+		toplevel_environments[i] = static_cast<REnvironmentObject *> (obj); 
+	}
+}
+
+RObject *RObjectList::findObject (const QString &name, bool is_canonified) {
+	RK_TRACE (OBJECTS);
+
+	QString canonified = name;
+	if (!is_canonified) {
+		canonified = canonified.replace ("[\"", "$").replace ('[', "").replace ("\"]", "").replace (']', "");
+	}
+
+	// TODO: there could be objects with "::" in their names!
+	if (canonified.contains ("::")) {
+		QString env = canonified.section ("::", 0, 0);
+		QString remainder = canonified.section ("::", 1);
+
+		RObjectMap::iterator it = childmap.find (env);
+		if (it == childmap.end ()) return 0;
+
+		RObject *found = it.data ();
+		return (found->findObject (remainder, true));
+	}
+
+	// no environment specified, do regular search:
+	// TODO: there could be objects with "$" in their names!
+	QString current_level = canonified.section (QChar ('$'), 0, 0);
+	QString remainder = canonified.section (QChar ('$'), 1);
+
+	for (int i = 0; i < num_toplevel_environments; ++i) {
+		RObject *found = toplevel_environments[i]->findChild (current_level);
+		if (found) {
+			if (remainder.isEmpty ()) return (found);
+			return (found->findObject (remainder, true));
+		}
+	}
+	return 0;
+}
+
+bool RObjectList::updateStructure (RData *new_data) {
+	RK_TRACE (OBJECTS);
+
+	RK_ASSERT (false);
+
 	return true;
 }
 
 void RObjectList::timeout () {
 	RK_TRACE (OBJECTS);
+
 	updateFromR ();
 }
 
-void RObjectList::renameChild (RObject *object, const QString &new_name) {
+QString RObjectList::renameChildCommand (RObject *object, const QString &new_name) {
 	RK_TRACE (OBJECTS);
 
-	RObjectMap::iterator it = childmap.find (object->getShortName ());
-	RK_ASSERT (it.data () == object);
-	
-	RCommand *command = new RCommand (makeChildName (new_name) + " <- " + object->getFullName ());
-	RKGlobals::rInterface ()->issueCommand (command, 0);
-	command = new RCommand ("remove (" + object->getFullName () + ")", RCommand::App | RCommand::Sync);
-	RKGlobals::rInterface ()->issueCommand (command, 0);
-	
-	childmap.remove (it);
-	childmap.insert (new_name, object);
+	return (makeChildName (new_name) + " <- " + object->getFullName () + "\n" + removeChildCommand (object));
+}
 
-	object->name = new_name;
+QString RObjectList::removeChildCommand (RObject *object) {
+	RK_TRACE (OBJECTS);
+
+	return ("remove (" + object->getFullName () + ")");
 }
 
 void RObjectList::removeChild (RObject *object, bool removed_in_workspace) {
 	RK_TRACE (OBJECTS);
 
-	RObjectMap::iterator it = childmap.find (object->getShortName ());
-	RK_ASSERT (it.data () == object);
-	
-	if (!removed_in_workspace) {
-		RCommand *command = new RCommand ("remove (" + object->getFullName () + ")", RCommand::App | RCommand::Sync);
-		RKGlobals::rInterface ()->issueCommand (command, 0);
+	if (removed_in_workspace) {
+		// remove from list of toplevel environments
+		REnvironmentObject **new_toplevel_envs = new REnvironmentObject*[num_toplevel_environments];
+		int num_new_toplevel_envs = 0;
+		for (int i=0; i < num_toplevel_environments; ++i) {
+			if (toplevel_environments[i] != object) new_toplevel_envs[num_new_toplevel_envs++] = toplevel_environments[i];
+		}
+		RK_ASSERT ((num_toplevel_environments - 1) == num_new_toplevel_envs);
+		delete [] toplevel_environments;
+		toplevel_environments = new_toplevel_envs;
+		num_toplevel_environments = num_new_toplevel_envs;
+
+		RContainerObject::removeChild (object, removed_in_workspace);
+	} else {
+		RK_ASSERT (false);
 	}
-	
-	childmap.remove (it);
-	delete object;
 }
 
 #include "robjectlist.moc"

Modified: trunk/rkward/rkward/core/robjectlist.h
===================================================================
--- trunk/rkward/rkward/core/robjectlist.h	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/core/robjectlist.h	2006-10-02 21:40:13 UTC (rev 793)
@@ -30,6 +30,7 @@
 class RCommand;
 class RCommandChain;
 class RKEditor;
+class REnvironmentObject;
 
 /**
 This class is responsible for keeping and updating a list of objects in the R-workspace.
@@ -53,6 +54,9 @@
 	
 	RCommandChain *getUpdateCommandChain () { return update_chain; };
 
+	/** reimplemented from RContainerObject to search the environments in search order */
+	RObject *findObject (const QString &name, bool canonified=false);
+
 	KURL getWorkspaceURL () { return current_url; };
 public slots:
 	void timeout ();
@@ -63,12 +67,15 @@
 	void updateComplete ();
 protected:
 /// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
-	void renameChild (RObject *object, const QString &new_name);
+	QString removeChildCommand (RObject *object);
+	void removeChild (RObject *object, bool removed_in_workspace);
 /// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
-	void removeChild (RObject *object, bool removed_in_workspace);
+	QString renameChildCommand (RObject *object, const QString &new_name);
 /// reimplemented from RContainerObject to emit a change signal
 	void objectsChanged ();
 	bool updateStructure (RData *new_data);
+	void rCommandDone (RCommand *command);
+	void updateEnvironments (QString *env_names, unsigned int env_count);
 private:
 	friend class RKLoadAgent;
 	friend class RKSaveAgent;
@@ -77,6 +84,9 @@
 	
 	RCommandChain *update_chain;
 
+	REnvironmentObject **toplevel_environments;
+	unsigned int num_toplevel_environments;
+
 	KURL current_url;
 };
 
@@ -84,8 +94,12 @@
 \page RepresentationOfRObjectsInRKWard Representation of R objects in RKWard
 \brief How objects in R space are represented in RKWard
 
-This page has not been written, yet.
+Due to primarily two reasons, RKWard needs to keep it's own list of objects in the R workspace. The first, and most important reason is threading: R objects might be modified or even removed in the R backend, while the GUI thread is trying to access them. Since we have no control over what's going on inside R, this cannot be solved with a simple mutex. So rather, we copy a representation into memory accessed by the GUI thread only (in the future, maybe the backend thread will get access to this representation for more efficient updating, but still a representation separate from that kept in R itself is needed).
 
+The second reason is that R and Qt includes clash, and we cannot easily use R SEXPs directly in Qt code.
+
+RKWard then uses an own specialized description of R objects. This is slightly more abstracted than objects in R, but stores the most important information about each object, and of course the hierarchical organization of objects.
+
 TODO: write me!
 	
 @see RObject

Modified: trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp	2006-10-02 21:40:13 UTC (rev 793)
@@ -193,7 +193,7 @@
 void RKEditorDataFrame::columnAdded (int col) {
 	RK_TRACE (EDITOR);
 	RObject *obj = static_cast<RContainerObject *> (getObject ())->createNewChild (static_cast<RContainerObject *> (getObject ())->validizeName (QString::null), this);
-	RK_ASSERT (obj->isVariable ());	
+	RK_ASSERT (obj->isVariable ());
 	RKGlobals::rInterface ()->issueCommand (new RCommand (".rk.data.frame.insert.column (" + getObject ()->getFullName () + ", \"" + obj->getShortName () + "\", " + QString ().setNum (col+1) + ")", RCommand::App | RCommand::Sync));
 	static_cast<RKVariable*> (obj)->setLength (dataview->numTrueRows ());
 	obj->setCreatedInEditor (this);

Modified: trunk/rkward/rkward/misc/rkobjectlistview.cpp
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/misc/rkobjectlistview.cpp	2006-10-02 21:40:13 UTC (rev 793)
@@ -2,7 +2,7 @@
                           rkobjectlistview  -  description
                              -------------------
     begin                : Wed Sep 1 2004
-    copyright            : (C) 2004 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 

Modified: trunk/rkward/rkward/misc/rkobjectlistview.h
===================================================================
--- trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-02 19:24:42 UTC (rev 792)
+++ trunk/rkward/rkward/misc/rkobjectlistview.h	2006-10-02 21:40:13 UTC (rev 793)
@@ -2,7 +2,7 @@
                           rkobjectlistview  -  description
                              -------------------
     begin                : Wed Sep 1 2004
-    copyright            : (C) 2004 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list