[rkward-cvs] SF.net SVN: rkward: [2144] branches/KDE4_port/rkward/core
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Oct 29 22:36:19 UTC 2007
Revision: 2144
http://rkward.svn.sourceforge.net/rkward/?rev=2144&view=rev
Author: tfry
Date: 2007-10-29 15:36:19 -0700 (Mon, 29 Oct 2007)
Log Message:
-----------
Declare functions const where applicable
Modified Paths:
--------------
branches/KDE4_port/rkward/core/rcontainerobject.cpp
branches/KDE4_port/rkward/core/rcontainerobject.h
branches/KDE4_port/rkward/core/renvironmentobject.cpp
branches/KDE4_port/rkward/core/renvironmentobject.h
branches/KDE4_port/rkward/core/rfunctionobject.cpp
branches/KDE4_port/rkward/core/rfunctionobject.h
branches/KDE4_port/rkward/core/robject.cpp
branches/KDE4_port/rkward/core/robject.h
branches/KDE4_port/rkward/core/robjectlist.cpp
branches/KDE4_port/rkward/core/robjectlist.h
Modified: branches/KDE4_port/rkward/core/rcontainerobject.cpp
===================================================================
--- branches/KDE4_port/rkward/core/rcontainerobject.cpp 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/rcontainerobject.cpp 2007-10-29 22:36:19 UTC (rev 2144)
@@ -2,7 +2,7 @@
rcontainerobject - description
-------------------
begin : Thu Aug 19 2004
- copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -17,8 +17,6 @@
#include "rcontainerobject.h"
#include <qregexp.h>
-//Added by qt3to4:
-#include <Q3ValueList>
#include "../rbackend/rinterface.h"
#include "robjectlist.h"
@@ -199,13 +197,13 @@
#warning TODO notify the modification tracker
}
-int RContainerObject::numChildren () {
+int RContainerObject::numChildren () const {
RK_TRACE (OBJECTS);
return childmap.size ();
}
// KDE4: do we need this? Can't we return the RObjectMap?
-RObject **RContainerObject::children () {
+RObject **RContainerObject::children () const {
RK_TRACE (OBJECTS);
RObject **ret = new RObject *[childmap.size ()];
@@ -232,13 +230,22 @@
return 0;
}
+RObject *RContainerObject::findChildByIndex (int position) const {
+ // don't trace this
+ if ((position >= 0) && (position < childmap.size ())) {
+ return childmap[position];
+ }
+ RK_ASSERT (false);
+ return 0;
+}
+
int RContainerObject::getIndexOf (RObject *child) const {
RK_TRACE (OBJECTS);
return childmap.indexOf (child);
}
-RObject *RContainerObject::findObject (const QString &name, bool is_canonified) {
+RObject *RContainerObject::findObject (const QString &name, bool is_canonified) const {
RK_TRACE (OBJECTS);
QString canonified = name;
@@ -256,7 +263,7 @@
return (found->findObject (remainder, true));
}
-void RContainerObject::findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified) {
+void RContainerObject::findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified) const {
RK_TRACE (OBJECTS);
RK_ASSERT (current_list);
@@ -344,19 +351,19 @@
delete object;
}
-QString RContainerObject::removeChildCommand (RObject *object) {
+QString RContainerObject::removeChildCommand (RObject *object) const {
RK_TRACE (OBJECTS);
return (object->getFullName () + " <- NULL");
}
-QString RContainerObject::renameChildCommand (RObject *object, const QString &new_name) {
+QString RContainerObject::renameChildCommand (RObject *object, const QString &new_name) const {
RK_TRACE (OBJECTS);
return ("rk.rename.in.container (" + getFullName () + ", \"" + object->getShortName () + "\", \"" + new_name + "\")");
}
-bool RContainerObject::isParentOf (RObject *object, bool recursive) {
+bool RContainerObject::isParentOf (RObject *object, bool recursive) const {
RK_TRACE (OBJECTS);
for (int i = childmap.size () - 1; i >= 0; --i) {
@@ -373,7 +380,7 @@
return false;
}
-QString RContainerObject::validizeName (const QString &child_name, bool unique) {
+QString RContainerObject::validizeName (const QString &child_name, bool unique) const {
RK_TRACE (OBJECTS);
QString ret = child_name;
ret = ret.replace (QRegExp ("[^a-zA-Z0-9]"), ".");
Modified: branches/KDE4_port/rkward/core/rcontainerobject.h
===================================================================
--- branches/KDE4_port/rkward/core/rcontainerobject.h 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/rcontainerobject.h 2007-10-29 22:36:19 UTC (rev 2144)
@@ -2,7 +2,7 @@
rcontainerobject - description
-------------------
begin : Thu Aug 19 2004
- copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -43,14 +43,16 @@
/** reimplemented from RObject to also update children */
bool updateStructure (RData *new_data);
- int numChildren ();
- RObject **children ();
+ int numChildren () const;
+ RObject **children () const;
/** like findObject (), but does not recurse, i.e. only direct children */
RObject *findChildByName (const QString &name) const;
+ /** fetches the child at the given position. This is very fast. */
+ RObject *findChildByIndex (int position) const;
/** return the index of the given child, or -1 if there is no such child */
int getIndexOf (RObject *child) const;
- bool isParentOf (RObject *object, bool recursive=false);
+ bool isParentOf (RObject *object, bool recursive=false) const;
/** creates a new child. Right now only RKVariables (false, false), or data.frames (true, true), or unspecified containers (true, false) can be created.
API will likely change. The child is NOT created in the workspace. That's your resonsibility. All this function returns is a new RObject* of the given
@@ -58,16 +60,16 @@
virtual RObject *createNewChild (const QString &name, int position=-1, RKEditor *creator=0, bool container=false, bool data_frame=false);
/** returns true, if there are no children in this container. Note: of course the object list may not be up to date! */
- bool isEmpty () { return childmap.isEmpty (); };
+ bool isEmpty () const { return childmap.isEmpty (); };
/** given child_name, constructs a name which is as close as possible to the orginial but valid (i.e. not already in use, not contaning illegal characters */
- virtual QString validizeName (const QString &child_name, bool unique=true);
+ virtual QString validizeName (const QString &child_name, bool unique=true) const;
/** reimplemented from RObject to actually search for the object */
- virtual RObject *findObject (const QString &name, bool is_canonified=false);
+ virtual RObject *findObject (const QString &name, bool is_canonified=false) const;
/** reimplemented from RObject to actually search for matching objects */
- void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false);
+ void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false) const;
void moveChild (RObject* child, int from_index, int to_index);
protected:
@@ -78,8 +80,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);
+ virtual QString removeChildCommand (RObject *object) const;
+ virtual QString renameChildCommand (RObject *object, const QString &new_name) const;
};
#endif
Modified: branches/KDE4_port/rkward/core/renvironmentobject.cpp
===================================================================
--- branches/KDE4_port/rkward/core/renvironmentobject.cpp 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/renvironmentobject.cpp 2007-10-29 22:36:19 UTC (rev 2144)
@@ -48,14 +48,14 @@
RK_TRACE (OBJECTS);
}
-QString REnvironmentObject::getFullName () {
+QString REnvironmentObject::getFullName () const {
RK_TRACE (OBJECTS);
if (type & ToplevelEnv) return ("as.environment (\"" + name + "\")");
return parent->makeChildName (name, type & Misplaced);
}
-QString REnvironmentObject::makeChildName (const QString &short_child_name, bool misplaced) {
+QString REnvironmentObject::makeChildName (const QString &short_child_name, bool misplaced) const {
RK_TRACE (OBJECTS);
if (type & GlobalEnv) return (short_child_name);
@@ -68,7 +68,7 @@
return (name + '$' + short_child_name);
}
-QString REnvironmentObject::makeChildBaseName (const QString &short_child_name) {
+QString REnvironmentObject::makeChildBaseName (const QString &short_child_name) const {
RK_TRACE (OBJECTS);
if (type & ToplevelEnv) {
@@ -142,13 +142,13 @@
}
}
-QString REnvironmentObject::renameChildCommand (RObject *object, const QString &new_name) {
+QString REnvironmentObject::renameChildCommand (RObject *object, const QString &new_name) const {
RK_TRACE (OBJECTS);
return (makeChildName (new_name) + " <- " + object->getFullName () + '\n' + removeChildCommand (object));
}
-QString REnvironmentObject::removeChildCommand (RObject *object) {
+QString REnvironmentObject::removeChildCommand (RObject *object) const {
RK_TRACE (OBJECTS);
return ("remove (" + object->getFullName () + ')');
Modified: branches/KDE4_port/rkward/core/renvironmentobject.h
===================================================================
--- branches/KDE4_port/rkward/core/renvironmentobject.h 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/renvironmentobject.h 2007-10-29 22:36:19 UTC (rev 2144)
@@ -34,12 +34,12 @@
void updateFromR (RCommandChain *chain);
- QString getFullName ();
- QString makeChildName (const QString &short_child_name, bool misplaced=false);
- QString makeChildBaseName (const QString &short_child_name);
+ QString getFullName () const;
+ QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
+ QString makeChildBaseName (const QString &short_child_name) const;
/** 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);
- QString namespaceName () { return namespace_name; };
+ QString namespaceName () const { return namespace_name; };
protected:
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" */
@@ -47,9 +47,9 @@
/** 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);
+ QString removeChildCommand (RObject *object) const;
/// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
- QString renameChildCommand (RObject *object, const QString &new_name);
+ QString renameChildCommand (RObject *object, const QString &new_name) const;
QString namespace_name;
};
Modified: branches/KDE4_port/rkward/core/rfunctionobject.cpp
===================================================================
--- branches/KDE4_port/rkward/core/rfunctionobject.cpp 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/rfunctionobject.cpp 2007-10-29 22:36:19 UTC (rev 2144)
@@ -35,7 +35,7 @@
RK_TRACE (OBJECTS);
}
-QString RFunctionObject::printArgs () {
+QString RFunctionObject::printArgs () const {
RK_TRACE (OBJECTS);
QString ret;
Modified: branches/KDE4_port/rkward/core/rfunctionobject.h
===================================================================
--- branches/KDE4_port/rkward/core/rfunctionobject.h 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/rfunctionobject.h 2007-10-29 22:36:19 UTC (rev 2144)
@@ -37,7 +37,7 @@
/** reimplemented from RObject to handle function arguments */
bool updateStructure (RData *new_data);
- QString printArgs ();
+ QString printArgs () const;
protected:
unsigned int argcount;
QString *argnames;
Modified: branches/KDE4_port/rkward/core/robject.cpp
===================================================================
--- branches/KDE4_port/rkward/core/robject.cpp 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/robject.cpp 2007-10-29 22:36:19 UTC (rev 2144)
@@ -2,7 +2,7 @@
robject - description
-------------------
begin : Thu Aug 19 2004
- copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -57,37 +57,37 @@
delete [] classnames;
}
-QString RObject::getShortName () {
+QString RObject::getShortName () const {
RK_TRACE (OBJECTS);
return name;
}
-QString RObject::getFullName () {
+QString RObject::getFullName () const {
RK_TRACE (OBJECTS);
return parent->makeChildName (RObject::name, type & Misplaced);
}
-QString RObject::getBaseName () {
+QString RObject::getBaseName () const {
RK_TRACE (OBJECTS);
return parent->makeChildBaseName (RObject::name);
}
-QString RObject::getLabel () {
+QString RObject::getLabel () const {
RK_TRACE (OBJECTS);
return getMetaProperty ("label");
}
-RObject *RObject::findObject (const QString &, bool) {
+RObject *RObject::findObject (const QString &, bool) const {
RK_TRACE (OBJECTS);
return 0;
}
-void RObject::findObjectsMatching (const QString &, RObjectSearchMap *, bool) {
+void RObject::findObjectsMatching (const QString &, RObjectSearchMap *, bool) const {
RK_TRACE (OBJECTS);
return;
}
-QString RObject::getMetaProperty (const QString &id) {
+QString RObject::getMetaProperty (const QString &id) const {
RK_TRACE (OBJECTS);
if (meta_map) {
RObject::MetaMap::iterator it;
@@ -98,7 +98,7 @@
return QString ();
}
-QString RObject::getDescription () {
+QString RObject::getDescription () const {
RK_TRACE (OBJECTS);
if (meta_map) {
RObject::MetaMap::iterator it;
@@ -109,7 +109,7 @@
return getShortName ();;
}
-QString RObject::getObjectDescription () {
+QString RObject::getObjectDescription () const {
RK_TRACE (OBJECTS);
#define ESCS replace ('<', "<")
@@ -123,7 +123,7 @@
if (isType (Function)) {
ret.append (i18n ("Function"));
- ret.append ("<br><b>" + i18n ("Usage: ") + " </b>" + getShortName ().ESCS + '(' + static_cast<RFunctionObject *> (this)->printArgs ().ESCS + ')');
+ ret.append ("<br><b>" + i18n ("Usage: ") + " </b>" + getShortName ().ESCS + '(' + static_cast<const RFunctionObject *> (this)->printArgs ().ESCS + ')');
} else if (isType (DataFrame)) {
ret.append (i18n ("Data frame"));
} else if (isType (Array)) {
@@ -190,7 +190,7 @@
RKGlobals::tracker ()->objectMetaChanged (this);
}
-QString RObject::makeClassString (const QString &sep) {
+QString RObject::makeClassString (const QString &sep) const {
RK_TRACE (OBJECTS);
QString ret;
bool first = true;
@@ -202,7 +202,7 @@
return ret;
}
-bool RObject::inherits (const QString &class_name) {
+bool RObject::inherits (const QString &class_name) const {
RK_TRACE (OBJECTS);
for (unsigned int i=0; i < numClasses (); ++i) {
@@ -213,12 +213,12 @@
return false;
}
-QString RObject::makeChildName (const QString &short_child_name, bool) {
+QString RObject::makeChildName (const QString &short_child_name, bool) const {
RK_TRACE (OBJECTS);
return (getFullName () + "[[" + rQuote (short_child_name) + "]]");
}
-QString RObject::makeChildBaseName (const QString &short_child_name){
+QString RObject::makeChildBaseName (const QString &short_child_name) const {
RK_TRACE (OBJECTS);
return (getBaseName () + "[[" + rQuote (short_child_name) + "]]");
}
@@ -358,7 +358,7 @@
return changed;
}
-bool RObject::isValidType (RData *new_data) {
+bool RObject::isValidType (RData *new_data) const {
RK_TRACE (OBJECTS);
RK_ASSERT (new_data->getDataLength () == 1);
RK_ASSERT (new_data->getDataType () == RData::IntVector);
@@ -535,7 +535,7 @@
return (copy.replace ("[\"", "$").replace ('[', "").replace ("\"]", "").replace (']', ""));
}
-RKEditor *RObject::objectOpened () {
+RKEditor *RObject::objectOpened () const {
RK_TRACE (OBJECTS);
if (!data) return 0;
@@ -588,7 +588,7 @@
data->pending = false;
}
-bool RObject::isPending () {
+bool RObject::isPending () const {
RK_TRACE (OBJECTS);
if (!data) return false;
@@ -610,7 +610,7 @@
data = 0;
}
-bool RObject::canEdit () {
+bool RObject::canEdit () const {
RK_TRACE (OBJECTS);
// TODO: find out, if binding is locked:
@@ -618,13 +618,13 @@
return (isInGlobalEnv ());
}
-bool RObject::canRead () {
+bool RObject::canRead () const {
RK_TRACE (OBJECTS);
return (this != RObjectList::getObjectList ());
}
-bool RObject::canRename () {
+bool RObject::canRename () const {
RK_TRACE (OBJECTS);
// TODO: find out, if binding is locked:
@@ -632,7 +632,7 @@
return (isInGlobalEnv ());
}
-bool RObject::canRemove () {
+bool RObject::canRemove () const {
RK_TRACE (OBJECTS);
// TODO: find out, if binding is locked:
@@ -640,11 +640,11 @@
return (isInGlobalEnv ());
}
-bool RObject::isInGlobalEnv () {
+bool RObject::isInGlobalEnv () const {
RK_TRACE (OBJECTS);
// could be made recursive instead, but likely it's faster like this
- RObject *o = this;
+ RObject *o = const_cast<RObject*> (this); // it's ok, all we need to do is find the toplevel parent
while (o && (!o->isType (ToplevelEnv))) {
o = o->parent;
}
Modified: branches/KDE4_port/rkward/core/robject.h
===================================================================
--- branches/KDE4_port/rkward/core/robject.h 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/robject.h 2007-10-29 22:36:19 UTC (rev 2144)
@@ -2,7 +2,7 @@
robject - description
-------------------
begin : Thu Aug 19 2004
- copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -77,12 +77,12 @@
/** @returns false if an object of the given old type cannot represent an object of the given new type (e.g. (new_type & RObjectType::Variable), but (old_type & RObjectType::Container)). */
static bool isMatchingType (int old_type, int new_type) { return ((old_type & ROBJECT_TYPE_INTERNAL_MASK) == (new_type & ROBJECT_TYPE_INTERNAL_MASK)); };
- QString getShortName ();
- virtual QString getFullName ();
- virtual QString getBaseName ();
- virtual QString getLabel ();
- virtual QString getMetaProperty (const QString &id);
- virtual QString getDescription ();
+ QString getShortName () const;
+ virtual QString getFullName () const;
+ virtual QString getBaseName () const;
+ QString getLabel () const;
+ QString getMetaProperty (const QString &id) const;
+ QString getDescription () const;
virtual void setLabel (const QString &value, bool sync=true);
virtual void setMetaProperty (const QString &id, const QString &value, bool sync=true);
@@ -100,28 +100,28 @@
/** mark the data of this object and all of its children as dirty (recursively). Dirty data will be updated *after* the new structure update (if the object is opened for editing) */
void markDataDirty ();
- bool canEdit ();
- bool canRead ();
- bool canRename ();
- bool canRemove ();
- bool isInGlobalEnv ();
+ bool canEdit () const;
+ bool canRead () const;
+ bool canRename () const;
+ bool canRemove () const;
+ bool isInGlobalEnv () const;
void rename (const QString &new_short_name);
void remove (bool removed_in_workspace);
- unsigned int numClasses () { return num_classes; };
- QString getClassName (int index) { return classnames[index]; };
- QString makeClassString (const QString &sep);
+ unsigned int numClasses () const { return num_classes; };
+ QString getClassName (int index) const { return classnames[index]; };
+ QString makeClassString (const QString &sep) const;
/** @param class_name the name of the class to check for
@returns true, if the object has (among others) the given class, false otherwise */
- bool inherits (const QString &class_name);
+ bool inherits (const QString &class_name) const;
/** get number of dimensions. For simplicity, In RKWard each object is considered to have at least one dimension (but that dimension may be 0 in length) */
- unsigned int numDimensions () { return num_dimensions; };
+ unsigned int numDimensions () const { return num_dimensions; };
/** get the length of the given dimension. The object is guaranteed to have at least 1 dimension, so calling getDimension (0) is always safe */
- int getDimension (int index) { return dimensions[index]; };
+ int getDimension (int index) const { return dimensions[index]; };
/** short hand for getDimension (0). Meaningful for one-dimensional objects */
- int getLength () { return dimensions[0]; };
+ int getLength () const { return dimensions[0]; };
/** A map of objects accessible by index. Used in RContainerObject. Defined here for technical reasons. */
typedef QList<RObject*> RObjectMap;
@@ -134,12 +134,12 @@
virtual void writeMetaData (RCommandChain *chain);
/** Returns the parent / container of this object. All objects have a parent except for the RObjectList (which returns 0) */
- RContainerObject *getContainer () { return (parent); };
+ RContainerObject *getContainer () const { return (parent); };
/** number of child objects. Always 0, reimplemented in RContainerObject */
- virtual int numChildren () { return 0; };
+ virtual int numChildren () const { return 0; };
/** array of child objects. Always 0, reimplemented in RContainerObject */
- virtual RObject **children () { return 0; };
+ virtual RObject **children () const { return 0; };
RDataType getDataType () const { return (typeToDataType (type)); };
static RDataType typeToDataType (int ftype) { return ((RDataType) ((ftype & DataTypeMask) >> 14)); };
@@ -154,7 +154,7 @@
/** Returns the given string in quotes, taking care of escaping quotation marks inside the string. */
static QString rQuote (const QString &string);
/** Returns a pretty description of the object, and its most important properties. TODO should this be virtual or not? I suppose, it's a close call. For now, we do all work here with casts */
- QString getObjectDescription ();
+ QString getObjectDescription () const;
/** Returns a canonified name given a non-canoified name. Warning! This is not (necessarily) suitable for submission to
R, only for internal lookup. For submission to R, always use RObject::getFullName (), as it will apply more complicated (and correct) rules depending on object type */
static QString canonifyName (const QString &from);
@@ -162,10 +162,10 @@
@param partial_name The partial name to look up
@param current_list A pointer to a valid (but probably initially empty) RObjectMap. Matches will be added to this list
@param name_is_canonified internal parameter. Set to true, if the name to match is already canonfied (else it will be canonified internally) */
- virtual void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false);
+ virtual void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false) const;
/** If the object is being edited, returns that editor (in the future probably a list of editors). Else returns 0 */
- RKEditor *objectOpened ();
+ RKEditor *objectOpened () const;
/** Tells the object it has been opened (opened=true) or closed (opened=false) by the given editor. If the object is opened by the first editor, it will
automatically take care of fetching its data. When closed by all editors, takes care of de-allocating that memory. */
void setObjectOpened (RKEditor *editor, bool opened);
@@ -182,7 +182,7 @@
@param name of the object (relative to this object)
@param is_canonified the object name may usually have to be canonified. Since this function may be called recursively, canonification may already have occurred on a higher level. In this case the argument is set to true to avoid some duplicate work. When calling from outside always leave the default false.
@returns a pointer to the object (if found) or 0 if not found */
- virtual RObject *findObject (const QString &name, bool is_canonified=false);
+ virtual RObject *findObject (const QString &name, bool is_canonified=false) const;
protected:
// why do I need those to compile? I thought they were derived classes!
friend class RContainerObject;
@@ -197,8 +197,8 @@
unsigned int num_classes;
/** generates a (full) name for a child of this object with the given name. */
- virtual QString makeChildName (const QString &short_child_name, bool misplaced=false);
- virtual QString makeChildBaseName (const QString &short_child_name);
+ virtual QString makeChildName (const QString &short_child_name, bool misplaced=false) const;
+ virtual QString makeChildBaseName (const QString &short_child_name) const;
/** Update object to reflect the structure passed in the new_data argument. If the data is mismatching (i.e. can not be accommodated by this type of object) false is returned (calls canAccommodateStructure () internally). In this case you should delete the object, and create a new one.
@returns true if the changes could be done, false if this */
@@ -209,7 +209,7 @@
virtual bool canAccommodateStructure (RData *new_data);
bool isValidName (RData *new_data);
- bool isValidType (RData *new_data);
+ bool isValidType (RData *new_data) const;
/** handles updating the object name from the given data (common functionality between RContainerObject and RKVariable. This should really never return true, as the name should never change. Hence also raises an assert. Is still useful for it's side effect of detaching and deleting the data from the RData structure after checking it.
@param new_data The data. Make sure it really is the classes field of an .rk.get.structure-command to update classes *before* calling this function! WARNING: the new_data object may get changed during this call. Call canAccommodateStructure () before calling this function!
@@ -247,7 +247,7 @@
/** see above */
virtual void discardEditData ();
- bool isPending ();
+ bool isPending () const;
void rCommandDone (RCommand *command);
};
Modified: branches/KDE4_port/rkward/core/robjectlist.cpp
===================================================================
--- branches/KDE4_port/rkward/core/robjectlist.cpp 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/robjectlist.cpp 2007-10-29 22:36:19 UTC (rev 2144)
@@ -2,7 +2,7 @@
robjectlist - description
-------------------
begin : Wed Aug 18 2004
- copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -150,7 +150,7 @@
return envobj;
}
-RObject *RObjectList::findObject (const QString &name, bool is_canonified) {
+RObject *RObjectList::findObject (const QString &name, bool is_canonified) const {
RK_TRACE (OBJECTS);
QString canonified = name;
@@ -175,7 +175,7 @@
return 0;
}
-void RObjectList::findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified) {
+void RObjectList::findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified) const {
RK_TRACE (OBJECTS);
RK_ASSERT (current_list);
@@ -200,7 +200,7 @@
}
}
-REnvironmentObject* RObjectList::findChildByNamespace (const QString &namespacename) {
+REnvironmentObject* RObjectList::findChildByNamespace (const QString &namespacename) const {
RK_TRACE (OBJECTS);
for (int i = childmap.size () - 1; i >= 0; --i) {
@@ -220,7 +220,7 @@
return (getGlobalEnv ()->createNewChild (name, position, creator, container, data_frame));
}
-QString RObjectList::validizeName (const QString &child_name, bool unique) {
+QString RObjectList::validizeName (const QString &child_name, bool unique) const {
RK_TRACE (OBJECTS);
return (getGlobalEnv ()->validizeName (child_name, unique));
@@ -240,13 +240,13 @@
updateFromR (0);
}
-QString RObjectList::renameChildCommand (RObject *object, const QString &new_name) {
+QString RObjectList::renameChildCommand (RObject *object, const QString &new_name) const {
RK_TRACE (OBJECTS);
return (makeChildName (new_name, false) + " <- " + object->getFullName () + '\n' + removeChildCommand (object));
}
-QString RObjectList::removeChildCommand (RObject *object) {
+QString RObjectList::removeChildCommand (RObject *object) const {
RK_TRACE (OBJECTS);
return ("remove (" + object->getFullName () + ')');
Modified: branches/KDE4_port/rkward/core/robjectlist.h
===================================================================
--- branches/KDE4_port/rkward/core/robjectlist.h 2007-10-29 21:35:21 UTC (rev 2143)
+++ branches/KDE4_port/rkward/core/robjectlist.h 2007-10-29 22:36:19 UTC (rev 2144)
@@ -2,7 +2,7 @@
robjectlist - description
-------------------
begin : Wed Aug 18 2004
- copyright : (C) 2004, 2006 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -47,26 +47,26 @@
void updateFromR (RCommandChain *chain);
- QString getFullName () { return QString (); };
- QString makeChildName (const QString &short_child_name, bool) { return short_child_name; };
+ QString getFullName () const { return QString (); };
+ QString makeChildName (const QString &short_child_name, bool) const { return short_child_name; };
/** reimplemented from RContainerObject: do nothing. The object-list has no meta data. */
void writeMetaData (RCommandChain *) {};
/** reimplemented from RContainerObject to search the environments in search order */
- RObject *findObject (const QString &name, bool canonified=false);
+ RObject *findObject (const QString &name, bool canonified=false) const;
/** reimplemented from RContainerObject to search the environments in search order */
- void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false);
+ void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false) const;
/** reimplemented from RContainerObject to create the child in the .GlobalEnv */
RObject *createNewChild (const QString &name, int position=-1, RKEditor *creator=0, bool container=false, bool data_frame=false);
/** reimplemented from RContainerObject to validize the name in .GlobalEnv */
- QString validizeName (const QString &child_name, bool unique=true);
+ QString validizeName (const QString &child_name, bool unique=true) const;
- KUrl getWorkspaceURL () { return current_url; };
+ KUrl getWorkspaceURL () const { return current_url; };
- REnvironmentObject* findChildByNamespace (const QString &namespacename);
+ REnvironmentObject* findChildByNamespace (const QString &namespacename) const;
static RObjectList *getObjectList () { return object_list; };
static REnvironmentObject *getGlobalEnv ();
@@ -79,10 +79,10 @@
void updateComplete ();
protected:
/// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
- QString removeChildCommand (RObject *object);
+ QString removeChildCommand (RObject *object) const;
void removeChild (RObject *object, bool removed_in_workspace);
/// reimplemented from RContainerObject to call "remove (objectname)" instead of "objectname <- NULL"
- QString renameChildCommand (RObject *object, const QString &new_name);
+ QString renameChildCommand (RObject *object, const QString &new_name) const;
/// reimplemented from RContainerObject to emit a change signal
void objectsChanged ();
bool updateStructure (RData *new_data);
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