EPONImplementationforOMNet++  0.8Beta
ONUTable Class Reference

A simple class containing a vector of ONUTableEntry objects. More...

#include <ONUTable.h>

List of all members.

Public Member Functions

virtual void addONU (ONUTableEntry &entry)
virtual void removeONU (MACAddress id)
virtual void removeONU (uint32_t idx)
virtual ONUTableEntrygetEntry (uint32_t idx)
virtual ONUTableEntrygetEntry (MACAddress id)
virtual ONUTableEntrygetEntry (std::string id)
virtual int getTableSize ()
virtual MACAddress getMACFromString (std::string id)
 Note: The entry may be null which leads to SEGFAULT This happens usually if the ONU we expect is not registered...

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Protected Attributes

vector< ONUTableEntrytbl

Detailed Description

A simple class containing a vector of ONUTableEntry objects.

ONUTable also provides some basic functions for adding, removing and finding specific entries based on MAC address or index. NOTE: DO NOT FORGET: It is NOT a vector so you must not call size() BUT instead call getTableSize().


Member Function Documentation

void ONUTable::addONU ( ONUTableEntry entry) [virtual]
                                         {

      if (tbl.size() == 0 ) {
            tbl.push_back(entry);
            return;
      }

      for (uint32_t i=0; i<tbl.size(); i++){
            // Do not add the same onu 2 times
            if (getEntry(i)->getId() == entry.getId()) {
                  *getEntry(i) = entry;
                  return;
            }
      }

      // If HERE, entry is new
      tbl.push_back(entry);

}
ONUTableEntry * ONUTable::getEntry ( uint32_t  idx) [virtual]
                                              {
      if (idx<0 || idx>=tbl.size()) return NULL;
      return &tbl[idx];
}
ONUTableEntry * ONUTable::getEntry ( MACAddress  id) [virtual]
                                               {
      for (uint32_t i=0; i<tbl.size(); i++){
            if (getEntry(i)->getId() == id) {
                  return &tbl[i];
            }
      }
      return NULL;
}
ONUTableEntry * ONUTable::getEntry ( std::string  id) [virtual]
                                              {
      for (uint32_t i=0; i<tbl.size(); i++){
            if (getEntry(i)->getId().str() == id) {
                  return &tbl[i];
            }
      }
      return NULL;
}
MACAddress ONUTable::getMACFromString ( std::string  id) [virtual]

Note: The entry may be null which leads to SEGFAULT This happens usually if the ONU we expect is not registered...

                                                 {
      if (getEntry(id))
            return getEntry(id)->getId();
      else
            return MACAddress::UNSPECIFIED_ADDRESS;
}
int ONUTable::getTableSize ( ) [virtual]
{return tbl.size();}
void ONUTable::handleMessage ( cMessage *  msg) [protected, virtual]
{
      // TODO - Generated method body
      delete msg;
}
void ONUTable::initialize ( ) [protected, virtual]
{
      WATCH_VECTOR(tbl);
}
void ONUTable::removeONU ( MACAddress  id) [virtual]
                                     {
      for (uint32_t i=0; i<tbl.size(); i++){
            if (getEntry(i)->getId() == id) {
                  tbl.erase(tbl.begin()+i);
                  return;
            }
      }
}
void ONUTable::removeONU ( uint32_t  idx) [virtual]
                                    {
      if (idx<0 || idx>=tbl.size()) return;
      tbl.erase(tbl.begin()+idx);
}

Member Data Documentation

vector<ONUTableEntry> ONUTable::tbl [protected]

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Friends Defines