Ignore:
Timestamp:
Jan 11, 2009, 10:20:06 PM (16 years ago)
Author:
dkearney
Message:

rappture object updates, stuff i'm playing around with. the code is not functional but it compiles, and i dont want to loose this state as i continue to play. the configure scripts and makefiles should still be working properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/objects/RpVariable.cc

    r1018 r1270  
    77 * ======================================================================
    88 *  AUTHOR:  Derrick Kearney, Purdue University
    9  *  Copyright (c) 2004-2005  Purdue Research Foundation
     9 *  Copyright (c) 2005-2009  Purdue Research Foundation
    1010 *
    1111 *  See the file "license.terms" for information on usage and
     
    1414 */
    1515
    16  #include "RpVariable.h"
     16#include <cstring>
     17#include <stdlib.h>
     18#include "RpVariable.h"
     19#include "RpHashHelper.h"
    1720
    18 /**********************************************************************/
    19 // METHOD: setPath()
    20 /// Set the path of this object
    21 /**
    22  */
    23 
    24 RpVariable&
    25 RpVariable::setPath(std::string newPath)
     21RpVariable::RpVariable()
    2622{
    27     path = newPath;
    28     return *this;
     23    __init();
    2924}
    3025
    31 /**********************************************************************/
    32 // METHOD: setDefaultValue()
    33 /// Set the default value of this object
    34 /**
    35  */
    36 
    37 RpVariable&
    38 RpVariable::setDefaultValue(void* newDefaultVal)
     26RpVariable::RpVariable(const RpVariable& o)
     27    :
     28        _path (o._path)
    3929{
    40     // who is responsible for freeing the pointer?
    41     defaultVal = newDefaultVal;
    42     return *this;
     30    if (o._h != NULL) {
     31        Rp_HashCopy(_h,o._h,charCpyFxn);
     32    }
    4333}
    4434
    45 /**********************************************************************/
    46 // METHOD: setCurrentValue()
    47 /// Set the current value of this object
    48 /**
    49  */
    50 
    51 RpVariable&
    52 RpVariable::setCurrentValue(void* newCurrentVal)
     35RpVariable::~RpVariable()
    5336{
    54     // who is responsible for freeing the pointer?
    55     currentVal = newCurrentVal;
    56     return *this;
     37    __close();
    5738}
    5839
    59 /**********************************************************************/
    60 // METHOD: setLabel()
    61 /// Set the label of this object
    62 /**
    63  */
    64 
    65 RpVariable&
    66 RpVariable::setLabel(std::string newLabel)
     40const char *
     41RpVariable::label(
     42    const char *val)
    6743{
    68     about.setLabel(newLabel);
    69     return *this;
     44    return (const char *) property("label",val);
    7045}
    7146
    72 /**********************************************************************/
    73 // METHOD: setDesc()
    74 /// Set the desc of this object
    75 /**
    76  */
    77 
    78 RpVariable&
    79 RpVariable::setDesc(std::string newDesc)
     47const char *
     48RpVariable::desc(
     49    const char *val)
    8050{
    81     about.setDesc(newDesc);
    82     return *this;
     51    return (const char *) property("desc",val);
    8352}
    8453
    85 /**********************************************************************/
    86 // METHOD: setHints()
    87 /// Set the hints of this object
    88 /**
    89  */
    90 
    91 RpVariable&
    92 RpVariable::setHints(std::string newHints)
     54const char *
     55RpVariable::hints(
     56    const char *val)
    9357{
    94     about.setHints(newHints);
    95     return *this;
     58    return (const char *) property("hints",val);
    9659}
    9760
    98 /**********************************************************************/
    99 // METHOD: setColor()
    100 /// Set the color of this object
    101 /**
    102  */
    103 
    104 RpVariable&
    105 RpVariable::setColor(std::string newColor)
     61const char *
     62RpVariable::color(
     63    const char *val)
    10664{
    107     about.setColor(newColor);
    108     return *this;
     65    return (const char *) property("color",val);
    10966}
    11067
    111 /**********************************************************************/
    112 // METHOD: setIcon()
    113 /// Set the icon of this object
    114 /**
    115  */
    116 
    117 RpVariable&
    118 RpVariable::setIcon(std::string newIcon)
     68const char *
     69RpVariable::icon(
     70    const char *val)
    11971{
    120     about.setIcon(newIcon);
    121     return *this;
     72    return (const char *) property("icon",val);
    12273}
    12374
    124 
    125 /**********************************************************************/
    126 // METHOD: getPath()
    127 /// Report the path of this object
    128 /**
    129  */
    130 
    131 std::string
    132 RpVariable::getPath() const
     75const char *
     76RpVariable::path(
     77    const char *val)
    13378{
    134     return path;
     79    return (const char *) property("path",val);
    13580}
    13681
    137 /**********************************************************************/
    138 // METHOD: getDefaultValue()
    139 /// Report the default value of the object
    140 /**
    141  */
     82const void *
     83RpVariable::property(
     84    const char *key,
     85    const void *val)
     86{
     87    const void *r = NULL;
     88    if (_h == NULL) {
     89        // hash table does not exist, create it
     90        _h = (Rp_HashTable*) malloc(sizeof(Rp_HashTable));
     91        Rp_InitHashTable(_h,RP_STRING_KEYS);
     92        return NULL;
     93    }
    14294
    143 void*
    144 RpVariable::getDefaultValue() const
    145 {
    146     return defaultVal;
     95    if (val == NULL) {
     96        // get the value
     97        r = Rp_HashSearchNode(_h,key);
     98    } else {
     99        //set the value
     100        Rp_HashRemoveNode(_h,key);
     101        Rp_HashAddNode(_h,key,val);
     102        r = val;
     103    }
     104
     105    return r;
    147106}
    148107
    149 /**********************************************************************/
    150 // METHOD: getCurrentValue()
    151 /// Report the current value of the object
    152 /**
    153  */
    154 
    155 void*
    156 RpVariable::getCurrentValue() const
     108void
     109RpVariable::__init()
    157110{
    158     return currentVal;
     111    _path = NULL;
     112    _h = NULL;
    159113}
    160114
    161 /**********************************************************************/
    162 // METHOD: getLabel()
    163 /// Report the label of the object
    164 /**
    165  */
     115void
     116RpVariable::__close()
     117{
     118    if (_path != NULL) {
     119        free((void *)_path);
     120    }
    166121
    167 std::string
    168 RpVariable::getLabel() const
    169 {
    170     return about.getLabel();
    171 }
     122    if (_h != NULL) {
     123        Rp_DeleteHashTable(_h);
     124    }
    172125
    173 /**********************************************************************/
    174 // METHOD: getDesc()
    175 /// Report the desc of the object
    176 /**
    177  */
    178 
    179 std::string
    180 RpVariable::getDesc() const
    181 {
    182     return about.getDesc();
    183 }
    184 
    185 /**********************************************************************/
    186 // METHOD: getHints()
    187 /// Report the hints of this object
    188 /**
    189  */
    190 
    191 std::string
    192 RpVariable::getHints() const
    193 {
    194     return about.getHints();
    195 }
    196 
    197 /**********************************************************************/
    198 // METHOD: getColor()
    199 /// Report the color of this object
    200 /**
    201  */
    202 
    203 std::string
    204 RpVariable::getColor() const
    205 {
    206     return about.getColor();
    207 }
    208 
    209 /**********************************************************************/
    210 // METHOD: getIcon()
    211 /// Report the icon of this object
    212 /**
    213  */
    214 
    215 std::string
    216 RpVariable::getIcon() const
    217 {
    218     return about.getIcon();
     126    __init();
    219127}
    220128
Note: See TracChangeset for help on using the changeset viewer.