Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

NRSimpleAttribute< char * > Class Reference

#include <nr.hh>

Inheritance diagram for NRSimpleAttribute< char * >:

Inheritance graph
[legend]
Collaboration diagram for NRSimpleAttribute< char * >:

Collaboration graph
[legend]
List of all members.

Public Types

enum  keys {
  SCOPE_KEY = 1001, CLASS_KEY = 1002, REINFORCEMENT_KEY = 1500, LATITUDE_KEY = 1501,
  LONGITUDE_KEY = 1502, ROUTE_KEY = 1503, SOURCE_ROUTE_KEY = 1504, DATABLOCK_KEY = 2001,
  TASK_FREQUENCY_KEY = 2002, TASK_NAME_KEY = 2003, TASK_QUERY_DETAIL_KEY = 2004, TARGET_KEY = 2005,
  TARGET_RANGE_KEY = 2006, CONFIDENCE_KEY = 2007
}
enum  classes { INTEREST_CLASS = 10010, DISINTEREST_CLASS, DATA_CLASS }
enum  scopes { NODE_LOCAL_SCOPE = 11010, GLOBAL_SCOPE }
enum  types {
  INT32_TYPE, FLOAT32_TYPE, FLOAT64_TYPE, STRING_TYPE,
  BLOB_TYPE
}
enum  operators {
  IS, LE, GE, LT,
  GT, EQ, NE, EQ_ANY
}

Public Member Functions

 NRSimpleAttribute (int key, int type, int op, char *val, int size=0)
 ~NRSimpleAttribute ()
char * getVal ()
int getLen ()
void setVal (char *value)
NRAttributefind_matching_key_from (NRAttrVec *attrs, NRAttrVec::iterator start, NRAttrVec::iterator *place=NULL)
NRAttributefind_matching_key (NRAttrVec *attrs, NRAttrVec::iterator *place=NULL)
int32_t getKey ()
int8_t getType ()
int8_t getOp ()
void * getGenericVal ()
bool isSameKey (NRAttribute *attr)
bool isEQ (NRAttribute *attr)
bool isGT (NRAttribute *attr)
bool isGE (NRAttribute *attr)
bool isNE (NRAttribute *attr)
bool isLT (NRAttribute *attr)
bool isLE (NRAttribute *attr)

Static Public Member Functions

NRAttributefind_key (int key, NRAttrVec *attrs, NRAttrVec::iterator *place=NULL)
NRAttributefind_key_from (int key, NRAttrVec *attrs, NRAttrVec::iterator start, NRAttrVec::iterator *place=NULL)

Protected Attributes

int32_t key_
int8_t type_
int8_t op_
int16_t len_
void * val_

Member Enumeration Documentation

enum NRAttribute::classes [inherited]
 

Enumeration values:
INTEREST_CLASS 
DISINTEREST_CLASS 
DATA_CLASS 

Definition at line 100 of file nr.hh.

enum NRAttribute::keys [inherited]
 

Enumeration values:
SCOPE_KEY 
CLASS_KEY 
REINFORCEMENT_KEY 
LATITUDE_KEY 
LONGITUDE_KEY 
ROUTE_KEY 
SOURCE_ROUTE_KEY 
DATABLOCK_KEY 
TASK_FREQUENCY_KEY 
TASK_NAME_KEY 
TASK_QUERY_DETAIL_KEY 
TARGET_KEY 
TARGET_RANGE_KEY 
CONFIDENCE_KEY 

Definition at line 72 of file nr.hh.

00072             {
00073     // reserved constant values used for key
00074     // range 1000-1499 is diffusion-specific
00075     SCOPE_KEY = 1001,             // INT32_TYPE
00076     CLASS_KEY = 1002,             // INT32_TYPE
00077 
00078     // range 1500-1999 is reserved for system filters
00079     REINFORCEMENT_KEY = 1500,     // BLOB_TYPE
00080     LATITUDE_KEY = 1501,          // FLOAT_TYPE
00081     LONGITUDE_KEY = 1502,         // FLOAT_TYPE
00082     ROUTE_KEY = 1503,             // STRING_TYPE
00083     SOURCE_ROUTE_KEY = 1504,      // STRING_TYPE
00084 
00085     // range 2000-2999 is app specific
00086     DATABLOCK_KEY = 2001,         // BLOB_TYPE
00087     TASK_FREQUENCY_KEY = 2002,    // FLOAT_TYPE, in secs
00088     TASK_NAME_KEY = 2003,         // STRING_TYPE
00089     TASK_QUERY_DETAIL_KEY = 2004, // BLOB_TYPE
00090     TARGET_KEY = 2005,            // STRING_TYPE
00091     TARGET_RANGE_KEY = 2006,      // FLOAT_TYPE
00092     CONFIDENCE_KEY = 2007         // FLOAT_TYPE
00093 
00094     // range 3000-3999 is reserved for experimentation
00095     // and user-defined keys
00096   };

enum NRAttribute::operators [inherited]
 

Enumeration values:
IS 
LE 
GE 
LT 
GT 
EQ 
NE 
EQ_ANY 

Definition at line 111 of file nr.hh.

00111 { IS, LE, GE, LT, GT, EQ, NE, EQ_ANY };

enum NRAttribute::scopes [inherited]
 

Enumeration values:
NODE_LOCAL_SCOPE 
GLOBAL_SCOPE 

Definition at line 101 of file nr.hh.

00101 { NODE_LOCAL_SCOPE = 11010, GLOBAL_SCOPE };

enum NRAttribute::types [inherited]
 

Enumeration values:
INT32_TYPE 
FLOAT32_TYPE 
FLOAT64_TYPE 
STRING_TYPE 
BLOB_TYPE 

Definition at line 104 of file nr.hh.

00104              { INT32_TYPE,    // 32-bit signed integer
00105                FLOAT32_TYPE,  // 32-bit
00106                FLOAT64_TYPE,  // 64-bit
00107                STRING_TYPE,   // UTF-8 format, max length 1024 chars
00108                BLOB_TYPE };   // uninterpreted binary data


Constructor & Destructor Documentation

NRSimpleAttribute< char * >::~NRSimpleAttribute  )  [inline]
 

Definition at line 211 of file nr.hh.

00211                        {
00212     assert(type_ == STRING_TYPE);
00213     delete [] (char *) val_;
00214   };


Member Function Documentation

NRAttribute* NRAttribute::find_key int  key,
NRAttrVec attrs,
NRAttrVec::iterator *  place = NULL
[inline, static, inherited]
 

Definition at line 119 of file nr.hh.

References NRAttribute::find_key_from().

00120                                                                  {
00121 
00122     return find_key_from(key, attrs, attrs->begin(), place);
00123   };

Here is the call graph for this function:

NRAttribute * NRAttribute::find_key_from int  key,
NRAttrVec attrs,
NRAttrVec::iterator  start,
NRAttrVec::iterator *  place = NULL
[static, inherited]
 

Definition at line 66 of file nr.cc.

Referenced by NRSimpleAttributeFactory< T >::find(), NRSimpleAttributeFactory< T >::find_from(), NRAttribute::find_key(), NRAttribute::find_matching_key(), and NRAttribute::find_matching_key_from().

00068                                                                    {
00069    
00070    NRAttrVec::iterator i;
00071    
00072    for (i = start; i != attrs->end(); ++i) {
00073       if ((*i)->getKey() == key) {
00074          if (place)
00075             *place = i;
00076          return (*i);
00077       };
00078    };
00079    return NULL;
00080 }

NRAttribute* NRAttribute::find_matching_key NRAttrVec attrs,
NRAttrVec::iterator *  place = NULL
[inline, inherited]
 

Definition at line 135 of file nr.hh.

References NRAttribute::find_key_from(), and NRAttribute::key_.

00136                                                                    {
00137     return find_key_from(key_, attrs, attrs->begin(), place);
00138   };

Here is the call graph for this function:

NRAttribute* NRAttribute::find_matching_key_from NRAttrVec attrs,
NRAttrVec::iterator  start,
NRAttrVec::iterator *  place = NULL
[inline, inherited]
 

Definition at line 129 of file nr.hh.

References NRAttribute::find_key_from(), and NRAttribute::key_.

Referenced by OneWayMatch(), and OneWayPerfectMatch().

00131                                                                         {
00132     return find_key_from(key_, attrs, start, place);
00133   };

Here is the call graph for this function:

void* NRAttribute::getGenericVal  )  [inline, inherited]
 

Definition at line 145 of file nr.hh.

References NRAttribute::val_.

Referenced by NRAttribute::isEQ(), NRAttribute::isGE(), NRAttribute::isGT(), and PackAttrs().

00145 { return val_; };

int32_t NRAttribute::getKey  )  [inline, inherited]
 

Definition at line 140 of file nr.hh.

References int32_t, and NRAttribute::key_.

Referenced by CopyAttrs(), NRAttribute::isSameKey(), PackAttrs(), and PrintAttrs().

00140 { return key_; };

int NRSimpleAttribute< char * >::getLen  )  [inline]
 

Reimplemented from NRAttribute.

Definition at line 217 of file nr.hh.

00217 {return len_; };

int8_t NRAttribute::getOp  )  [inline, inherited]
 

Definition at line 142 of file nr.hh.

References int8_t, and NRAttribute::op_.

Referenced by DiffusionRouting::checkPublication(), DiffusionRouting::checkSubscription(), CopyAttrs(), GeoRoutingFilter::extractLocation(), OneWayMatch(), OneWayPerfectMatch(), PackAttrs(), PrintAttrs(), and GradientFilter::processNewMessage().

00142 { return op_; };

int8_t NRAttribute::getType  )  [inline, inherited]
 

Definition at line 141 of file nr.hh.

References int8_t, and NRAttribute::type_.

Referenced by CopyAttrs(), NRAttribute::isSameKey(), PackAttrs(), and PrintAttrs().

00141 { return type_; };

char* NRSimpleAttribute< char * >::getVal  )  [inline]
 

Definition at line 216 of file nr.hh.

00216 { return (char *)val_; };

bool NRAttribute::isEQ NRAttribute attr  )  [inherited]
 

Definition at line 82 of file nr.cc.

References abort(), NRAttribute::BLOB_TYPE, NRAttribute::FLOAT32_TYPE, NRAttribute::FLOAT64_TYPE, NRAttribute::getGenericVal(), NRAttribute::getLen(), int32_t, NRAttribute::INT32_TYPE, NRAttribute::isSameKey(), NRAttribute::len_, NRAttribute::STRING_TYPE, NRAttribute::type_, and NRAttribute::val_.

Referenced by NRAttribute::isNE(), OneWayMatch(), and OneWayPerfectMatch().

00082                                         {
00083 
00084    // Keys need to be the same
00085    if (!isSameKey(attr))
00086       abort();
00087 
00088    switch (type_){
00089 
00090    case INT32_TYPE:
00091       return (*(int32_t *) val_ == *(int32_t *) attr->getGenericVal());
00092       break;
00093 
00094    case FLOAT32_TYPE:
00095       return (*(float *) val_ == *(float *) attr->getGenericVal());
00096       break;
00097 
00098    case FLOAT64_TYPE:
00099       return (*(double *) val_ == *(double *) attr->getGenericVal());
00100       break;
00101 
00102    case STRING_TYPE:
00103       if (len_ != attr->getLen())
00104         return false;
00105       return (!strncmp((char *) val_, (char *) attr->getGenericVal(), len_));
00106       break;
00107 
00108    case BLOB_TYPE:
00109       if (len_ != attr->getLen())
00110         return false;
00111       return (!memcmp((void *) val_, (void *) attr->getGenericVal(), len_));
00112       break;
00113 
00114    default:
00115       abort();
00116       break;
00117    }
00118 }

Here is the call graph for this function:

bool NRAttribute::isGE NRAttribute attr  )  [inherited]
 

Definition at line 166 of file nr.cc.

References abort(), NRAttribute::BLOB_TYPE, NRAttribute::FLOAT32_TYPE, NRAttribute::FLOAT64_TYPE, NRAttribute::getGenericVal(), NRAttribute::getLen(), int32_t, NRAttribute::INT32_TYPE, NRAttribute::isSameKey(), NRAttribute::len_, min, NRAttribute::STRING_TYPE, NRAttribute::type_, and NRAttribute::val_.

Referenced by NRAttribute::isLT(), and OneWayMatch().

00166                                         {
00167 
00168    int cmplen, cmp;  // must be here for initialization reasons
00169 
00170    // Keys need to be the same
00171    if (!isSameKey(attr))
00172       abort();
00173 
00174    switch (type_) {
00175 
00176    case INT32_TYPE:
00177       return (*(int32_t *) val_ >= *(int32_t *) attr->getGenericVal());
00178       break;
00179 
00180    case FLOAT32_TYPE:
00181       return (*(float *) val_ >= *(float *) attr->getGenericVal());
00182       break;
00183 
00184    case FLOAT64_TYPE:
00185       return (*(double *) val_ >= *(double *) attr->getGenericVal());
00186       break;
00187 
00188    case STRING_TYPE:
00189       return (strcmp((char *) val_, (char *) attr->getGenericVal()) >= 0);
00190       break;
00191 
00192    case BLOB_TYPE:
00193       cmplen = min(len_, attr->getLen());
00194       cmp = memcmp((void *) val_, (void *) attr->getGenericVal(), cmplen);
00195       
00196       // We are greater or equal to attr
00197       if (cmp >= 0)
00198          return true;
00199       return false;
00200       break;
00201 
00202    default:
00203       abort();
00204       break;
00205    }
00206 }

Here is the call graph for this function:

bool NRAttribute::isGT NRAttribute attr  )  [inherited]
 

Definition at line 120 of file nr.cc.

References abort(), NRAttribute::BLOB_TYPE, NRAttribute::FLOAT32_TYPE, NRAttribute::FLOAT64_TYPE, NRAttribute::getGenericVal(), NRAttribute::getLen(), int32_t, NRAttribute::INT32_TYPE, NRAttribute::isSameKey(), NRAttribute::len_, min, NRAttribute::STRING_TYPE, NRAttribute::type_, and NRAttribute::val_.

Referenced by NRAttribute::isLE(), and OneWayMatch().

00120                                         {
00121 
00122    int cmplen, cmp;  // must be here for initialization reasons
00123 
00124    // Keys need to be the same
00125    if (!isSameKey(attr))
00126       abort();
00127 
00128    switch (type_) {
00129 
00130    case INT32_TYPE:
00131       return (*(int32_t *) val_ > *(int32_t *) attr->getGenericVal());
00132       break;
00133 
00134    case FLOAT32_TYPE:
00135       return (*(float *) val_ > *(float *) attr->getGenericVal());
00136       break;
00137 
00138    case FLOAT64_TYPE:
00139       return (*(double *) val_ > *(double *) attr->getGenericVal());
00140       break;
00141 
00142    case STRING_TYPE:
00143       return strncmp((char *) val_, (char *) attr->getGenericVal(),
00144                      min(len_, attr->getLen()));
00145       break;
00146 
00147    case BLOB_TYPE:
00148       cmplen = min(len_, attr->getLen());
00149       cmp = memcmp((void *) val_, (void *) attr->getGenericVal(), cmplen);
00150       
00151       // We are greater than attr
00152       if (cmp > 0)
00153          return true;
00154       // We are equal to attr up to len_, but we are longer
00155       if (cmp == 0 && (len_ > attr->getLen()))
00156          return true;
00157       return false;
00158       break;
00159 
00160    default:
00161       abort();
00162       break;
00163    }
00164 }

Here is the call graph for this function:

bool NRAttribute::isLE NRAttribute attr  )  [inline, inherited]
 

Definition at line 165 of file nr.hh.

References NRAttribute::isGT().

Referenced by OneWayMatch().

00165                                {
00166     return (!isGT(attr));
00167   };

Here is the call graph for this function:

bool NRAttribute::isLT NRAttribute attr  )  [inline, inherited]
 

Definition at line 161 of file nr.hh.

References NRAttribute::isGE().

Referenced by OneWayMatch().

00161                                {
00162     return (!isGE(attr));
00163   };

Here is the call graph for this function:

bool NRAttribute::isNE NRAttribute attr  )  [inline, inherited]
 

Definition at line 157 of file nr.hh.

References NRAttribute::isEQ().

Referenced by OneWayMatch().

00157                                {
00158     return (!isEQ(attr));
00159   };

Here is the call graph for this function:

bool NRAttribute::isSameKey NRAttribute attr  )  [inline, inherited]
 

Definition at line 147 of file nr.hh.

References NRAttribute::getKey(), NRAttribute::getType(), NRAttribute::key_, and NRAttribute::type_.

Referenced by NRAttribute::isEQ(), NRAttribute::isGE(), and NRAttribute::isGT().

00147                                     {
00148     return ((type_ == attr->getType()) && (key_ == attr->getKey()));
00149   };

Here is the call graph for this function:

NRSimpleAttribute< char * >::NRSimpleAttribute int  key,
int  type,
int  op,
char *  val,
int  size = 0
 

Definition at line 208 of file nr.cc.

References NRSimpleAttribute< T >::setVal(), NRAttribute::STRING_TYPE, and NRAttribute::val_.

00208                                                                                            :
00209    NRAttribute(key, type, op, (strlen(val) + 1))
00210 {
00211    assert(type == STRING_TYPE);
00212    val_ = NULL;
00213    setVal(val);
00214 }

Here is the call graph for this function:

void NRSimpleAttribute< char * >::setVal char *  value  ) 
 

Definition at line 216 of file nr.cc.

References NRAttribute::len_, and NRAttribute::val_.

00216                                                   {
00217    delete [] (char *) val_;
00218    len_ = strlen(value) + 1;
00219    val_ = (void *) new char[len_ + 1];
00220    memcpy(val_, value, len_);
00221 }


Member Data Documentation

int32_t NRAttribute::key_ [protected, inherited]
 

Definition at line 171 of file nr.hh.

Referenced by NRAttribute::find_matching_key(), NRAttribute::find_matching_key_from(), NRAttribute::getKey(), NRAttribute::isSameKey(), and NRAttribute::NRAttribute().

int16_t NRAttribute::len_ [protected, inherited]
 

Definition at line 174 of file nr.hh.

Referenced by NRSimpleAttribute< int >::getLen(), NRAttribute::getLen(), NRAttribute::isEQ(), NRAttribute::isGE(), NRAttribute::isGT(), NRAttribute::NRAttribute(), NRSimpleAttribute< void * >::NRSimpleAttribute(), NRSimpleAttribute< void * >::setVal(), and setVal().

int8_t NRAttribute::op_ [protected, inherited]
 

Definition at line 173 of file nr.hh.

Referenced by NRAttribute::getOp(), and NRAttribute::NRAttribute().

int8_t NRAttribute::type_ [protected, inherited]
 

Definition at line 172 of file nr.hh.

Referenced by NRAttribute::getType(), NRAttribute::isEQ(), NRAttribute::isGE(), NRAttribute::isGT(), NRAttribute::isSameKey(), NRAttribute::NRAttribute(), and NRSimpleAttribute< int >::~NRSimpleAttribute().

void* NRAttribute::val_ [protected, inherited]
 

Definition at line 175 of file nr.hh.

Referenced by NRAttribute::getGenericVal(), NRSimpleAttribute< int >::getVal(), NRAttribute::isEQ(), NRAttribute::isGE(), NRAttribute::isGT(), NRAttribute::NRAttribute(), NRSimpleAttribute< int >::NRSimpleAttribute(), NRSimpleAttribute< void * >::NRSimpleAttribute(), NRSimpleAttribute(), NRSimpleAttribute< int >::setVal(), NRSimpleAttribute< void * >::setVal(), setVal(), and NRSimpleAttribute< int >::~NRSimpleAttribute().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 13:06:00 2004 for NS2.26SourcesOriginal by doxygen 1.3.3