attribute.cc

来自「基于Oment++的无线传感器网络仿真」· CC 代码 · 共 91 行

CC
91
字号
#include <stdio.h>   // for null#include <string.h>  // for strdup#include <algorithm>  // for stl min#include "Attribute.h"Attribute::Attribute(int key, int op, float val){   key_ = key;   op_ = op ;   val_ = val;}Attribute::Attribute() :       key_(0), op_(0), val_(0.0) {}Attribute::~Attribute(){//	printf(" In attribute destructor \n");}Attribute Attribute::find_key_from(int key, AttrVec *attrs) {   AttrVec::iterator i;   for (i = attrs->begin(); i != attrs->end(); ++i) {  //printf(" key is in for %d\n",(*i).getKey());      if ( (*i).getKey() == key) {	//  printf(" key is %f\n",(*i).getVal());	 return (*i);      }   }   //printf("returning NULL\n");   return (*i);}bool Attribute::compareAttribute(float value){	//printf("Attribute::compareAttribute op====%d", op_);	switch (op_)	{		case LE:			return isLE(value);		break;		case GE:			return isGE(value);		break;		case LT:			return isLT(value);		break;		case GT:			return isGT(value);		break;		case EQ:			return isEQ(value);		break;		case NE:			return isNE(value);		break;		case EQ_ANY:			return true;		break;	}}	bool Attribute::isEQ(float value) {     return ( val_ ==  value);}bool Attribute::isGT(float value) {     return ( value >  val_);}bool Attribute::isGE(float value) {     return ( value >=  val_);}/*AttributeFactory::AttributeFactory(){}Attribute* AttributeFactory::LatitudeAttr(int op,float val){	Attribute* LatAtr=new Attribute(Attribute::LONGITUDE,op,val);	return LatAtr;}*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?