InformationItem Class Reference

#include <InformationItem.h>

List of all members.

Public Member Functions

 InformationItem ()
 InformationItem (string prefix, char *id)
 InformationItem (string id)
 InformationItem (const InformationItem &II)
 ~InformationItem ()
virtual void setScope (string input)
virtual void setID (const char *id)
virtual bool setPop (double p)
virtual string getScope ()
virtual char * getID ()
virtual double getPop ()
virtual int scopeSize ()
virtual std::string info () const
virtual std::string toString ()
bool operator< (const InformationItem *II)
bool operator== (const InformationItem *II)
bool operator== (const InformationItem II)
bool operator() (const InformationItem *II1, const InformationItem *II2) const

Protected Attributes

string scope
 The scope ID of the Information Item.
char ID [PURSUIT_ID_LEN+1]
 The Item ID of the Information Item.
double pop
 The popularity of the Information Item.

Constructor & Destructor Documentation

InformationItem::InformationItem (  ) 

The Publish Subscribe Information Item class source

00022                                  {
00023         pop=1;
00024 }

InformationItem::InformationItem ( string  prefix,
char *  id 
)

00027                                                         {
00028         int chk=prefix.length()%PURSUIT_ID_LEN;
00029         if(strlen(id)==PURSUIT_ID_LEN && chk==0) {
00030                 for(int i=0;i<PURSUIT_ID_LEN+1;i++)
00031                         ID[i]=id[i];
00032                 scope=prefix;
00033         }
00034         else {
00035                 opp_error("Information item creation failed because of invalid ID or scope size");
00036                 return;
00037         }
00038         pop=1;
00039 }

InformationItem::InformationItem ( string  id  ) 

00050                                           {
00051         scope=id.substr(0,id.size()-PURSUIT_ID_LEN);
00052         string remaining=id.substr(id.size()-PURSUIT_ID_LEN,PURSUIT_ID_LEN);
00053         for(uint i=0;i<sizeof(remaining);i++)
00054                 ID[i]=remaining[i];
00055         pop=1;
00056 }

InformationItem::InformationItem ( const InformationItem II  ) 

00042                                                           {
00043         scope=II.scope;
00044         for(uint i=0;i<sizeof(II.ID);i++)
00045                 ID[i]=II.ID[i];
00046         pop=1;
00047 }

InformationItem::~InformationItem (  ) 

00059                                   {
00060 
00061 }


Member Function Documentation

virtual char* InformationItem::getID (  )  [inline, virtual]

00073 {return ID;};

virtual double InformationItem::getPop (  )  [inline, virtual]

00076 {return pop;};

virtual string InformationItem::getScope (  )  [inline, virtual]

00070 {return scope;}

std::string InformationItem::info (  )  const [virtual]

00102 {
00103     std::stringstream out;
00104     string temp=ID;
00105     out << "Scope:";
00106     for(uint i=0;i<scope.length();i++)
00107         out << " 0x" << chararray_to_hex(scope.substr(i,1));
00108     out << endl << "ID:";
00109     for(uint i=0;i<temp.length();i++)
00110                 out << " 0x" << chararray_to_hex(temp.substr(i,1)) << " ";
00111 
00112     return out.str();
00113 }

bool InformationItem::operator() ( const InformationItem II1,
const InformationItem II2 
) const [inline]

00125                                                                                              {
00126                         std::string fullID(II1->scope);
00127                         std::string fullItemID(II2->scope);
00128                         fullID.append(II1->ID,sizeof(II1->ID));
00129                         fullItemID.append(II2->ID,sizeof(II2->ID));
00130                         return (fullID.compare(fullItemID) < 0);
00131                 }

bool InformationItem::operator< ( const InformationItem II  )  [inline]

00091                                                             {
00092                         std::string fullID(scope);
00093                         std::string fullItemID(II->scope);
00094                         fullID.append(ID,sizeof(ID));
00095                         fullItemID.append(II->ID,sizeof(II->ID));
00096                         return (fullID.compare(fullItemID) < 0);
00097                 }

bool InformationItem::operator== ( const InformationItem  II  )  [inline]

00113                                                             {
00114                         std::string fullID(scope);
00115                         std::string fullItemID(II.scope);
00116                         fullID.append(ID,sizeof(ID));
00117                         fullItemID.append(II.ID,sizeof(II.ID));
00118                         return (fullID.compare(fullItemID) == 0);
00119                 }

bool InformationItem::operator== ( const InformationItem II  )  [inline]

00102                                                              {
00103                         std::string fullID(scope);
00104                         std::string fullItemID(II->scope);
00105                         fullID.append(ID,sizeof(ID));
00106                         fullItemID.append(II->ID,sizeof(II->ID));
00107                         return (fullID.compare(fullItemID) == 0);
00108                 }

virtual int InformationItem::scopeSize (  )  [inline, virtual]

00080 {return scope.size()/PURSUIT_ID_LEN;};

void InformationItem::setID ( const char *  id  )  [virtual]

00076                                           {
00077         if(strlen(id)==PURSUIT_ID_LEN) {
00078                 for(int i=0;i<PURSUIT_ID_LEN+1;i++)
00079                         ID[i]=id[i];
00080         }
00081         else {
00082                 opp_error("Setting ID of information item failed because of invalid ID");
00083                 return;
00084         }
00085 }

bool InformationItem::setPop ( double  p  )  [virtual]

00088                                      {
00089         //Check is given popularity if in the probability range
00090         if(0<p && 1>p) {
00091                 pop=p;
00092                 return true;
00093         }
00094         else
00095                 pop=0;
00096 
00097         return false;
00098 }

void InformationItem::setScope ( string  input  )  [virtual]

00064                                             {
00065         int chk=prefix.length()%PURSUIT_ID_LEN;
00066         if(chk==0) {
00067                 scope=prefix;
00068         }
00069         else {
00070                 opp_error("Information item creation failed because of invalid scope size");
00071                 return;
00072         }
00073 }

std::string InformationItem::toString (  )  [virtual]

00116                                     {
00117         string out=scope+ID;
00118         return out;
00119 }


Member Data Documentation

char InformationItem::ID[PURSUIT_ID_LEN+1] [protected]

The Item ID of the Information Item.

double InformationItem::pop [protected]

The popularity of the Information Item.

string InformationItem::scope [protected]

The scope ID of the Information Item.


The documentation for this class was generated from the following files:
Generated on Thu Jun 14 17:12:42 2012 for PAL by  doxygen 1.6.3