Changeset 400


Ignore:
Timestamp:
Apr 9, 2006, 10:03:43 PM (18 years ago)
Author:
dkearney
Message:

more tcl bindings related adjustments. this version should work well with most examples in the zoo directory.
proper changes still need to be made to gui scripts

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/core/RpUnits.h

    r388 r400  
    299299
    300300        // retrieve a list of compatible units.
    301         std::list<std::string> getCompatible() const;
     301        std::list<std::string> getCompatible(double expMultiplier=1.0) const;
    302302
    303303
     
    343343        static const RpUnits* find(std::string key);
    344344
     345        // validate is very similar to find, but it works better
     346        // for seeing complex units can be interpreted.
     347        // it validates that if the a certain units string is
     348        // provided as a unit type, then all of the base components
     349        // of that unit are available for conversions.
     350        // returns 0 on success (units are valid)
     351        // returns !0 on failure (units not valid)
     352        static int validate(const std::string& inUnits,
     353                            std::string& type,
     354                            std::list<std::string>* compatList=NULL);
     355
    345356        // user calls define to add a RpUnits object or to add a relation rule
    346357        //
  • trunk/src/core/RpLibrary.cc

    r394 r400  
    237237
    238238            if (!path.str().empty()) {
    239                 path.str(_node2comp(snode) + "." + path.str());
     239                // path.str(_node2comp(snode) + "." + path.str());
     240                path.str("." + _node2comp(snode) + path.str());
    240241            }
    241242            else {
    242                 path.str(_node2comp(snode));
     243                // path.str(_node2comp(snode));
     244                path.str("." + _node2comp(snode));
    243245            }
    244246
     
    12961298// METHOD: put()
    12971299/// Put a RpLibrary* value into the xml.
    1298 // Append flag is ignored for this function.
    1299 /**
     1300/**
     1301 *  Append flag adds additional nodes, it does not merge same
     1302 *  named nodes together
    13001303 */
    13011304
     
    13031306RpLibrary::put ( std::string path, RpLibrary* value, std::string id, int append )
    13041307{
    1305     scew_element* retNode = NULL;
    1306     scew_element* new_elem = NULL;
     1308    scew_element* retNode   = NULL;
     1309    // scew_element* old_elem  = NULL;
     1310    scew_element* new_elem  = NULL;
     1311    scew_element* childNode = NULL;
     1312    // std::string nodeName    = "";
     1313
    13071314    int retVal = 1;
    13081315
     
    13181325    }
    13191326
     1327    // nodeName = value->nodeComp();
     1328    // old_elem = _find(path+"."+nodeName,NO_CREATE_PATH);
     1329
     1330    if (!append) {
     1331        retNode = _find(path,NO_CREATE_PATH);
     1332        if (retNode) {
     1333            scew_element_free(retNode);
     1334        }
     1335        else {
     1336            // path did not exist and was not created
     1337            // do nothing
     1338        }
     1339    }
     1340
    13201341    retNode = _find(path,CREATE_PATH);
    13211342
     1343    if (retNode) {
     1344        while ( (childNode = scew_element_next(value->root,childNode)) ) {
     1345            if ((new_elem = scew_element_copy(childNode))) {
     1346                if (scew_element_add_elem(retNode, new_elem)) {
     1347                    // maybe we want to count the number of children
     1348                    // that we have successfully added?
     1349                    retVal = 0;
     1350                }
     1351                else {
     1352                    // adding new element failed
     1353                }
     1354            }
     1355            else {
     1356                // copying new element failed
     1357            }
     1358        }
     1359    }
     1360    else {
     1361        // path did not exist and was not created.
     1362    }
     1363
     1364    /*
    13221365    if (retNode) {
    13231366        if ((new_elem = scew_element_copy(value->root))) {
     
    13271370        }
    13281371    }
     1372
     1373    */
    13291374
    13301375    return *this;
  • trunk/src/core/RpUnits.cc

    r399 r400  
    249249            // add the other unit's name to the list of compatible units
    250250            // compatList.push_back(otherName.str());
    251             std::cout << " pushing " << otherName << std::endl;
    252251            compatList.push_back(otherName);
    253252
  • trunk/src/tcl/src/RpLibraryTclInterface.cc

    r399 r400  
    10631063    int opt_argc       = 2;     // max number of optional parameters
    10641064    int argsLeft       = 0;     // temp variable for calculation
     1065    int noerr = 0;
     1066    Tcl_CmdInfo info;  // pointer to the command info
    10651067
    10661068    while (opt_argc--) {
     
    11191121    }
    11201122
     1123    noerr = Tcl_GetCommandInfo(interp, addStr.c_str(), &info);
     1124    if (noerr == 1) {
     1125        // valid command
     1126        if (info.proc == &RpLibCallCmd) {
     1127            // call the rappture library put function with the Rappture Object
     1128            ((RpLibrary*) cdata)->put( path,
     1129                                       (RpLibrary*)info.clientData,
     1130                                       id, append);
     1131        }
     1132        else {
     1133            // object is not a RpLibrary
     1134            // call the rappture library put function with the inputted string
     1135            ((RpLibrary*) cdata)->put(path, addStr, id, append);
     1136        }
     1137    }
     1138    else {
     1139        // invalid command
     1140        // call the rappture library put function with the inputted string
     1141        ((RpLibrary*) cdata)->put(path, addStr, id, append);
     1142    }
     1143
    11211144    // call the rappture library put function
    1122     ((RpLibrary*) cdata)->put(path, addStr, id, append);
     1145    // ((RpLibrary*) cdata)->put(path, addStr, id, append);
    11231146
    11241147    // clear any previous result in the interpreter
Note: See TracChangeset for help on using the changeset viewer.