[rkward-cvs] rkward/rkward/core rcontainerobject.cpp,1.25,1.26 rcontainerobject.h,1.20,1.21 rkvariable.cpp,1.29,1.30 rkvariable.h,1.18,1.19 robject.cpp,1.18,1.19 robject.h,1.20,1.21 robjectlist.cpp,1.24,1.25
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Fri Dec 9 16:06:34 UTC 2005
Update of /cvsroot/rkward/rkward/rkward/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1345/core
Modified Files:
rcontainerobject.cpp rcontainerobject.h rkvariable.cpp
rkvariable.h robject.cpp robject.h robjectlist.cpp
Log Message:
Remove code duplication for object classification. Make dimensionality information more generic. Untested.
Index: robject.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/robject.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** robject.h 9 Dec 2005 14:05:14 -0000 1.20
--- robject.h 9 Dec 2005 16:06:32 -0000 1.21
***************
*** 59,62 ****
--- 59,64 ----
bool isVariable () { return (type & Variable); };
bool hasMetaObject () { return (type & HasMetaObject); };
+ /** @returns false if an object of the given old type can not represent an object of the given new type (e.g. (new_type & RObjectType::Variable), but (old_type & RObjectType::Container)). */
+ bool isMatchingType (int old_type, int new_type);
void rename (const QString &new_short_name);
***************
*** 70,73 ****
--- 72,82 ----
bool inherits (const QString &class_name);
+ /** get number of dimensions. In RKWard each object is viewed to have at least one dimension (this view, of course, is slightly incorrect as well, but makes life easier) */
+ int numDimensions () { 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 dimension[index]; };
+ /** short hand for getDimension (0). Meaningful for one-dimensional objects */
+ int getLength () { return dimension[0]; }
+
/** A map of objects accessible by their short name. Used in RContainerObject. Defined here for technical reasons. */
typedef QMap<QString, RObject*> RObjectMap;
***************
*** 118,124 ****
int num_classes;
QString *classname;
! /** fetches the meta data from the backend */
! virtual void getMetaData (RCommandChain *chain);
/** generates a (full) name for a child of this object with the given name. */
virtual QString makeChildName (const QString &short_child_name);
--- 127,135 ----
int num_classes;
QString *classname;
+ int num_dimensions;
+ int *dimension;
! /** fetches the meta data from the backend. Sets of a command with the given flags. Be sure to catch this command in your rCommandDone-function and send it to handleGetMetaCommand ()! */
! virtual void getMetaData (RCommandChain *chain, int flags);
/** generates a (full) name for a child of this object with the given name. */
virtual QString makeChildName (const QString &short_child_name);
***************
*** 127,136 ****
MetaMap *meta_map;
- void rCommandDone (RCommand *command);
/** handles updating class names from an update class command given as argument (common functionality between RContainerObject and RKVariable
@param command The command. Make sure it really is a command to update classes *before* calling this function!
@returns true if the classes changed, false if no change resulted */
bool handleUpdateClassCommand (RCommand *command);
!
/** an instance of this struct is created, when the object is opened for editing. For one thing, it keeps track of which editor(s) are working on the object.
In subclasses like RKVariable, the struct is extended to additionally hold the data of the object, etc. */
--- 138,154 ----
MetaMap *meta_map;
/** handles updating class names from an update class command given as argument (common functionality between RContainerObject and RKVariable
@param command The command. Make sure it really is a command to update classes *before* calling this function!
@returns true if the classes changed, false if no change resulted */
bool handleUpdateClassCommand (RCommand *command);
! /** handles updating the meta data from a get meta data command given as argument (common functionality between RContainerObject and RKVariable. Takes care of notifying modification tracker, if meta data has changed. Therefore no return value. Most likely you will call this function for the result of a command triggered by getMetaData ();
! @param command The command. Make sure it really is a get meta data command *before* calling this function! */
! void handleGetMetaCommand (RCommand *command);
! /** check the type of this object, and update dimension information from a .rk.classify command given as argument. If a type mismatch is found, this returns false, and you *must* return immediately, as the object will be deleted shortly!
! @param command The command. Make sure it really is a .rk.classify command *before* calling this function!
! @param dims_changed If the dimensions changed, this bool is set to true. If the dimensions did not change, it is left untouched (i.e. even if it already was true)
! @returns false if there was a type mismatch. In this case you *must* return! */
! bool handleClassifyCommand (RCommand *command, bool *dims_changed);
!
/** an instance of this struct is created, when the object is opened for editing. For one thing, it keeps track of which editor(s) are working on the object.
In subclasses like RKVariable, the struct is extended to additionally hold the data of the object, etc. */
Index: robjectlist.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/robjectlist.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** robjectlist.cpp 29 Sep 2005 16:02:50 -0000 1.24
--- robjectlist.cpp 9 Dec 2005 16:06:32 -0000 1.25
***************
*** 59,64 ****
RK_TRACE (OBJECTS);
- RObject::rCommandDone (command);
-
bool changed = false;
--- 59,62 ----
***************
*** 106,111 ****
pending_objects.remove (command);
RKGlobals::tracker ()->addObject (robj, 0);
!
! }
// TODO: signal change
--- 104,108 ----
pending_objects.remove (command);
RKGlobals::tracker ()->addObject (robj, 0);
! }
// TODO: signal change
Index: rcontainerobject.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rcontainerobject.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** rcontainerobject.cpp 9 Dec 2005 14:05:14 -0000 1.25
--- rcontainerobject.cpp 9 Dec 2005 16:06:32 -0000 1.26
***************
*** 31,40 ****
#define UPDATE_CLASS_COMMAND 2
#define UPDATE_CHILD_LIST_COMMAND 3
RContainerObject::RContainerObject (RContainerObject *parent, const QString &name) : RObject (parent, name) {
RK_TRACE (OBJECTS);
- dimension = 0;
- num_dimensions = 0;
num_children_updating = 0;
}
--- 31,40 ----
#define UPDATE_CLASS_COMMAND 2
#define UPDATE_CHILD_LIST_COMMAND 3
+ #define GET_META_COMMAND 4
RContainerObject::RContainerObject (RContainerObject *parent, const QString &name) : RObject (parent, name) {
RK_TRACE (OBJECTS);
num_children_updating = 0;
+ type = Container;
}
***************
*** 58,108 ****
void RContainerObject::rCommandDone (RCommand *command) {
RK_TRACE (OBJECTS);
- RObject::rCommandDone (command);
bool properties_changed = false;
! if (command->getFlags () == CLASSIFY_COMMAND) {
! // WARNING: This code is (mostly) duplicated in RKVariable!
! if (!command->intVectorLength ()) {
! RK_ASSERT (false);
! return;
! } else {
! int new_type = command->getIntVector ()[0];
!
! // check whether this is still a container object
! if ((RObject::type) && (new_type != RObject::type)) {
! if (!(new_type & RObject::Container)) {
! RK_DO (qDebug ("type-mismatch: name: %s, old_type: %d, new_type: %d", RObject::name.latin1 (), type, new_type), OBJECTS, DL_INFO);
! RObject::parent->typeMismatch (this, RObject::name);
! return; // will be deleted!
! }
! }
! if (new_type != RObject::type) {
! properties_changed = true;
! RObject::type = new_type;
! }
! // get dimensions
! if (num_dimensions != (command->intVectorLength () - 1)) {
! num_dimensions = command->intVectorLength () - 1;
! properties_changed = true;
! delete dimension;
! dimension = new int [num_dimensions];
! }
! for (int d=0; d < num_dimensions; ++d) {
! if (dimension[d] != command->getIntVector ()[d+1]) properties_changed = true;
! dimension[d] = command->getIntVector ()[d+1];
! }
! // classifiy command was successful. now get further information.
! if (hasMetaObject ()) getMetaData (RKGlobals::rObjectList()->getUpdateCommandChain ());
! RCommand *command = new RCommand ("class (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, UPDATE_CLASS_COMMAND);
! RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
- command = new RCommand ("names (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, UPDATE_CHILD_LIST_COMMAND);
- RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
- }
if (properties_changed) RKGlobals::tracker ()->objectMetaChanged (this);
!
} else if (command->getFlags () == UPDATE_CHILD_LIST_COMMAND) {
// first check, whether all known children still exist:
--- 58,81 ----
void RContainerObject::rCommandDone (RCommand *command) {
RK_TRACE (OBJECTS);
bool properties_changed = false;
! if (command->getFlags () == GET_META_COMMAND) {
! handleGetMetaCommand (command);
! } else if (command->getFlags () == CLASSIFY_COMMAND) {
! if (!handleClassifyCommand (command, &properties_changed)) {
! return; // will be deleted!
! }
! // classifiy command was successful. now get further information.
! if (hasMetaObject ()) getMetaData (RKGlobals::rObjectList()->getUpdateCommandChain (), GET_META_COMMAND);
! RCommand *command = new RCommand ("class (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, UPDATE_CLASS_COMMAND);
! RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
! command = new RCommand ("names (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, UPDATE_CHILD_LIST_COMMAND);
! RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
if (properties_changed) RKGlobals::tracker ()->objectMetaChanged (this);
!
} else if (command->getFlags () == UPDATE_CHILD_LIST_COMMAND) {
// first check, whether all known children still exist:
Index: rcontainerobject.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rcontainerobject.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** rcontainerobject.h 9 Dec 2005 14:05:14 -0000 1.20
--- rcontainerobject.h 9 Dec 2005 16:06:32 -0000 1.21
***************
*** 51,57 ****
type and with the name (if neccessary) changed to a legal value. TODO: checking for and changing illegal names is not yet implemented */
RObject *createNewChild (const QString &name, RKEditor *creator=0, bool container=false, bool data_frame=false);
-
- int numDimensions () { return num_dimensions; };
- int getDimension (int index) { return dimension[index]; };
/** returns true, if there are no children in this container. Note: of course the object list may not be up to date! */
--- 51,54 ----
Index: rkvariable.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rkvariable.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** rkvariable.cpp 9 Dec 2005 14:05:14 -0000 1.29
--- rkvariable.cpp 9 Dec 2005 16:06:32 -0000 1.30
***************
*** 27,32 ****
#define CLASSIFY_COMMAND 1
- #define UPDATE_DIM_COMMAND 2
#define UPDATE_CLASS_COMMAND 3
#define GET_STORAGE_MODE_COMMAND 10
#define GET_DATA_COMMAND 11
--- 27,32 ----
#define CLASSIFY_COMMAND 1
#define UPDATE_CLASS_COMMAND 3
+ #define GET_META_COMMAND 4
#define GET_STORAGE_MODE_COMMAND 10
#define GET_DATA_COMMAND 11
***************
*** 39,46 ****
RKVariable::RKVariable (RContainerObject *parent, const QString &name) : RObject (parent, name) {
RK_TRACE (OBJECTS);
! // TODO: better check, wether it really is one
! RObject::type = Variable;
var_type = Unknown;
- length = 0;
}
--- 39,44 ----
RKVariable::RKVariable (RContainerObject *parent, const QString &name) : RObject (parent, name) {
RK_TRACE (OBJECTS);
! type = Variable;
var_type = Unknown;
}
***************
*** 104,108 ****
RK_TRACE (OBJECTS);
! getMetaData (RKGlobals::rObjectList()->getUpdateCommandChain ());
// TODO: move classification / type mismatch-checking to RObject
--- 102,106 ----
RK_TRACE (OBJECTS);
! getMetaData (RKGlobals::rObjectList()->getUpdateCommandChain (), GET_META_COMMAND);
// TODO: move classification / type mismatch-checking to RObject
***************
*** 115,164 ****
bool properties_changed = false;
- RObject::rCommandDone (command);
-
- if (command->getFlags () == CLASSIFY_COMMAND) {
- // WARNING: This code is (mostly) duplicated in RContainerObject!
- if (!command->intVectorLength ()) {
- RK_ASSERT (false);
- return;
- }
-
- int new_type = command->getIntVector ()[0];
-
- // check whether this is still a container object
- if ((RObject::type) && (new_type != RObject::type)) {
- if ((new_type & RObject::Container)) {
- RK_DO (qDebug ("type-mismatch: name: %s, old_type: %d, new_type: %d", RObject::name.latin1 (), type, new_type), OBJECTS, DL_INFO);
- RObject::parent->typeMismatch (this, RObject::name);
- return; // will be deleted!
- }
- }
- if (new_type != RObject::type) {
- properties_changed = true;
- RObject::type = new_type;
- }
! // classifiy command was successful. now get further information.
! // TODO: actually, classify already contains dim (). Simplify!
! RCommand *command = new RCommand ("length (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetIntVector, QString::null, this, UPDATE_DIM_COMMAND);
! RKGlobals::rInterface ()->issueCommand (command, RKGlobals::rObjectList()->getUpdateCommandChain ());
!
! if (properties_changed) RKGlobals::tracker ()->objectMetaChanged (this);
! } else if (command->getFlags () == UPDATE_DIM_COMMAND) {
! if (command->intVectorLength () == 1) {
! length = command->getIntVector ()[0];
! } else {
! length = 1;
! }
!
QString dummy = getMetaProperty ("type");
int new_var_type = dummy.toInt ();
var_type = (RObject::VarType) new_var_type;
if (new_var_type != var_type) RKGlobals::tracker ()->objectMetaChanged (this);
RCommand *ncommand = new RCommand ("class (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, UPDATE_CLASS_COMMAND);
RKGlobals::rInterface ()->issueCommand (ncommand, RKGlobals::rObjectList()->getUpdateCommandChain ());
} else if (command->getFlags () == GET_STORAGE_MODE_COMMAND) {
RK_ASSERT (command->intVectorLength () == 2);
--- 113,136 ----
bool properties_changed = false;
! if (command->getFlags () == GET_META_COMMAND) {
! handleGetMetaCommand (command);
! // TODO: This is not quite good, yet, as it may result in two calls to objectMetaChanged.
QString dummy = getMetaProperty ("type");
int new_var_type = dummy.toInt ();
var_type = (RObject::VarType) new_var_type;
if (new_var_type != var_type) RKGlobals::tracker ()->objectMetaChanged (this);
+ } else if (command->getFlags () == CLASSIFY_COMMAND) {
+ if (!handleClassifyCommand (command, &properties_changed)) {
+ return; // will be deleted!
+ }
+ // classifiy command was successful. now get further information.
RCommand *ncommand = new RCommand ("class (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, UPDATE_CLASS_COMMAND);
RKGlobals::rInterface ()->issueCommand (ncommand, RKGlobals::rObjectList()->getUpdateCommandChain ());
+ if (properties_changed) RKGlobals::tracker ()->objectMetaChanged (this);
+
} else if (command->getFlags () == GET_STORAGE_MODE_COMMAND) {
RK_ASSERT (command->intVectorLength () == 2);
***************
*** 187,194 ****
setSyncing (false);
if (command->realVectorLength ()) {
! RK_ASSERT (command->realVectorLength () == length);
setNumeric (0, command->realVectorLength () - 1, command->getRealVector ());
} else if (command->stringVectorLength ()) {
! RK_ASSERT (command->stringVectorLength () == length);
setCharacter (0, command->stringVectorLength () - 1, command->getStringVector ());
delete command->getStringVector ();
--- 159,166 ----
setSyncing (false);
if (command->realVectorLength ()) {
! RK_ASSERT (command->realVectorLength () == getLength ());
setNumeric (0, command->realVectorLength () - 1, command->getRealVector ());
} else if (command->stringVectorLength ()) {
! RK_ASSERT (command->stringVectorLength () == getLength ());
setCharacter (0, command->stringVectorLength () - 1, command->getStringVector ());
delete command->getStringVector ();
***************
*** 199,203 ****
ChangeSet *set = new ChangeSet;
set->from_index = 0;
! set->to_index = length;
RKGlobals::tracker ()->objectDataChanged (this, set);
RKGlobals::tracker ()->objectMetaChanged (this);
--- 171,175 ----
ChangeSet *set = new ChangeSet;
set->from_index = 0;
! set->to_index = getLength ();
RKGlobals::tracker ()->objectDataChanged (this, set);
RKGlobals::tracker ()->objectMetaChanged (this);
***************
*** 230,236 ****
void RKVariable::setLength (int len) {
RK_TRACE (OBJECTS);
! RK_ASSERT (!length); // should only be called once
!
! length = len;
}
--- 202,209 ----
void RKVariable::setLength (int len) {
RK_TRACE (OBJECTS);
! RK_ASSERT (!getLength ()); // should only be called once
! RK_ASSERT (dimension);
!
! dimension[0] = len;
}
***************
*** 408,412 ****
if (length <= 0) length = 1;
if (length <= myData ()->allocated_length) {
! RKVariable::length = length;
return;
}
--- 381,385 ----
if (length <= 0) length = 1;
if (length <= myData ()->allocated_length) {
! dimension[0] = length;
return;
}
***************
*** 432,436 ****
myData ()->allocated_length = target;
! RKVariable::length = length;
}
--- 405,409 ----
myData ()->allocated_length = target;
! dimension[0] = length;
}
***************
*** 439,443 ****
// TODO: downsizing to values other than 0
! if (length <= 0) {
delete [] myData ()->cell_double_data;
myData ()->cell_double_data = 0;
--- 412,416 ----
// TODO: downsizing to values other than 0
! if (getLength () <= 0) {
delete [] myData ()->cell_double_data;
myData ()->cell_double_data = 0;
***************
*** 491,495 ****
void RKVariable::setTextPlain (int row, char *text) {
RK_TRACE (OBJECTS);
! RK_ASSERT (row < length);
// delete previous string data, unless it's a special value
deleteStringData (row);
--- 464,468 ----
void RKVariable::setTextPlain (int row, char *text) {
RK_TRACE (OBJECTS);
! RK_ASSERT (row < getLength ());
// delete previous string data, unless it's a special value
deleteStringData (row);
***************
*** 580,584 ****
/** get a copy of the numeric values of rows starting from from_index, going to to_index. Do not use this before making sure that the rStorage () is really numeric! */
double *RKVariable::getNumeric (int from_row, int to_row) {
! if (to_row >= length) {
RK_ASSERT (false);
return 0;
--- 553,557 ----
/** get a copy of the numeric values of rows starting from from_index, going to to_index. Do not use this before making sure that the rStorage () is really numeric! */
double *RKVariable::getNumeric (int from_row, int to_row) {
! if (to_row >= getLength ()) {
RK_ASSERT (false);
return 0;
***************
*** 592,596 ****
void RKVariable::setNumeric (int from_row, int to_row, double *data) {
! RK_ASSERT (to_row < length);
for (int row=from_row; row <= to_row; ++row) {
--- 565,569 ----
void RKVariable::setNumeric (int from_row, int to_row, double *data) {
! RK_ASSERT (to_row < getLength ());
for (int row=from_row; row <= to_row; ++row) {
***************
*** 622,626 ****
/** like getNumeric, but returns values as an array of char*s */
char **RKVariable::getCharacter (int from_row, int to_row) {
! if (to_row >= length) {
RK_ASSERT (false);
return 0;
--- 595,599 ----
/** like getNumeric, but returns values as an array of char*s */
char **RKVariable::getCharacter (int from_row, int to_row) {
! if (to_row >= getLength ()) {
RK_ASSERT (false);
return 0;
***************
*** 645,649 ****
/** like setNumeric, but sets chars. If internalStorage () is numeric, attempts to convert the given strings to numbers. I.e. the function behaves essentially like setText (), but operates on a range of cells. */
void RKVariable::setCharacter (int from_row, int to_row, char **data) {
! RK_ASSERT (to_row < length);
if (getVarType () == String) {
--- 618,622 ----
/** like setNumeric, but sets chars. If internalStorage () is numeric, attempts to convert the given strings to numbers. I.e. the function behaves essentially like setText (), but operates on a range of cells. */
void RKVariable::setCharacter (int from_row, int to_row, char **data) {
! RK_ASSERT (to_row < getLength ());
if (getVarType () == String) {
***************
*** 664,668 ****
void RKVariable::setUnknown (int from_row, int to_row) {
! RK_ASSERT (to_row < length);
if ((from_row < 0)) from_row = 0;
--- 637,641 ----
void RKVariable::setUnknown (int from_row, int to_row) {
! RK_ASSERT (to_row < getLength ());
if ((from_row < 0)) from_row = 0;
***************
*** 711,715 ****
}
! length -= (to_row - from_row) + 1;
downSize ();
RECHECK_VALID
--- 684,688 ----
}
! dimension[0] -= (to_row - from_row) + 1;
downSize ();
RECHECK_VALID
Index: robject.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/robject.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** robject.cpp 9 Dec 2005 14:05:14 -0000 1.18
--- robject.cpp 9 Dec 2005 16:06:32 -0000 1.19
***************
*** 28,34 ****
#include "../debug.h"
- #define GET_META_COMMAND 1001
- #define UPDATE_CLASS_COMMAND 1002
-
RObject::RObject (RContainerObject *parent, const QString &name) {
RK_TRACE (OBJECTS);
--- 28,31 ----
***************
*** 41,44 ****
--- 38,44 ----
num_classes = 0;
classname = 0;
+ dimension = new int [1]; // safe initialization
+ dimension[0] = 0;
+ num_dimensions = 0;
}
***************
*** 46,52 ****
RK_TRACE (OBJECTS);
- delete[] classname;
-
if (data) discardEditData ();
}
--- 46,54 ----
RK_TRACE (OBJECTS);
if (data) discardEditData ();
+
+ delete[] classname;
+
+ delete dimension;
}
***************
*** 145,148 ****
--- 147,157 ----
}
+ bool RObject::isMatchingType (int old_type, int new_type) {
+ RK_TRACE (OBJECTS);
+
+ int type_mask = Container | Variable | Workspace; // for easier typing
+ return ((old_type & type_mask) == (new_type & type_mask));
+ }
+
QString RObject::makeChildName (const QString &short_child_name) {
RK_TRACE (OBJECTS);
***************
*** 150,156 ****
}
! void RObject::getMetaData (RCommandChain *chain) {
RK_TRACE (OBJECTS);
! RCommand *command = new RCommand (".rk.get.meta (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, GET_META_COMMAND);
RKGlobals::rInterface ()->issueCommand (command, chain);
}
--- 159,165 ----
}
! void RObject::getMetaData (RCommandChain *chain, int flags) {
RK_TRACE (OBJECTS);
! RCommand *command = new RCommand (".rk.get.meta (" + getFullName () + ")", RCommand::App | RCommand::Sync | RCommand::GetStringVector, QString::null, this, flags);
RKGlobals::rInterface ()->issueCommand (command, chain);
}
***************
*** 187,213 ****
}
! void RObject::rCommandDone (RCommand *command) {
RK_TRACE (OBJECTS);
- if (command->getFlags () == GET_META_COMMAND) {
- if (command->stringVectorLength ()) {
- if (!meta_map) meta_map = new MetaMap;
! int len = command->stringVectorLength ();
! RK_ASSERT (!(len % 2));
! int cut = len/2;
! for (int i=0; i < cut; ++i) {
! meta_map->insert (command->getStringVector ()[i], command->getStringVector ()[i+cut]);
! }
!
! type |= HasMetaObject;
! } else { // no meta data received
! delete meta_map;
! meta_map = 0;
!
! type -= (type & HasMetaObject);
}
! // TODO: only signal change, if there really was a change!
! RKGlobals::tracker ()->objectMetaChanged (this);
}
}
--- 196,223 ----
}
! void RObject::handleGetMetaCommand (RCommand *command) {
RK_TRACE (OBJECTS);
! if (command->stringVectorLength ()) {
! if (!meta_map) meta_map = new MetaMap;
! meta_map->clear ();
!
! int len = command->stringVectorLength ();
! RK_ASSERT (!(len % 2));
! int cut = len/2;
! for (int i=0; i < cut; ++i) {
! meta_map->insert (command->getStringVector ()[i], command->getStringVector ()[i+cut]);
}
!
! type |= HasMetaObject;
! } else { // no meta data received
! delete meta_map;
! meta_map = 0;
!
! type -= (type & HasMetaObject);
}
+
+ // TODO: only signal change, if there really was a change!
+ RKGlobals::tracker ()->objectMetaChanged (this);
}
***************
*** 231,234 ****
--- 241,282 ----
}
+ bool RObject::handleClassifyCommand (RCommand *command, bool *dims_changed) {
+ RK_TRACE (OBJECTS);
+
+ if (!command->intVectorLength ()) {
+ RK_ASSERT (false);
+ return false;
+ }
+ int new_type = command->getIntVector ()[0];
+
+ if (!isMatchingType (type, new_type)){
+ RK_DO (qDebug ("type-mismatch: name: %s, old_type: %d, new_type: %d", RObject::name.latin1 (), type, new_type), OBJECTS, DL_INFO);
+ RObject::parent->typeMismatch (this, RObject::name);
+ return false; // will be deleted!
+ }
+ if (new_type != type) {
+ *dims_changed = true;
+ type = new_type;
+ }
+
+ // get dimensions
+ if (num_dimensions != (command->intVectorLength () - 1)) {
+ num_dimensions = command->intVectorLength () - 1;
+ *dims_changed = true;
+ delete dimension;
+ if (num_dimensions < 1) {
+ RK_ASSERT (false);
+ num_dimensions = 1;
+ }
+ dimension = new int [num_dimensions];
+ }
+ for (int d=0; d < num_dimensions; ++d) {
+ if (dimension[d] != command->getIntVector ()[d+1]) *dims_changed = true;
+ dimension[d] = command->getIntVector ()[d+1];
+ }
+
+ return true;
+ }
+
void RObject::rename (const QString &new_short_name) {
RK_TRACE (OBJECTS);
Index: rkvariable.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/core/rkvariable.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** rkvariable.h 9 Dec 2005 14:05:14 -0000 1.18
--- rkvariable.h 9 Dec 2005 16:06:32 -0000 1.19
***************
*** 48,53 ****
void setVarType (RObject::VarType, bool sync=true);
- /** The length (number of data-items) of this RKVariable */
- int getLength () { return length; };
/** A hack for now: returns the name of the parent (data.frame) */
QString getTable ();
--- 48,51 ----
***************
*** 59,63 ****
void writeMetaData (RCommandChain *chain);
friend class RContainerObject;
- int length;
RObject::VarType var_type;
--- 57,60 ----
More information about the rkward-tracker
mailing list