Ignore:
Timestamp:
Mar 24, 2011, 10:40:14 AM (14 years ago)
Author:
mies
Message:

rolled back

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/utility/types/LinkID.cpp

    r9684 r9695  
    3939#include "LinkID.h"
    4040
    41 #include <boost/unordered_map.hpp>
    42 
    4341namespace ariba {
    4442namespace utility {
    4543
    46 /// the unspecified link id
    47 const LinkID LinkID::UNSPECIFIED;
     44const LinkID LinkID::UNSPECIFIED; // for this link isvalid is always false!
    4845
    49 const char* UNSPECIFIED_LINK    = "<LINKID-UNSPECIFIED>";
    50 const char* UNKNOWN_LINK                = "<LINKID-UNKNOWN>";
    51 const char* NULL_INFO                   = "<NO-INFO-AVAILABLE>";
    52 
    53 boost::unordered_map<uint16_t, const char*> link_ids;
    54 
    55 bool LinkID::isValid( const LinkID& id ) {
    56         return link_ids.count(id.local_id)!=0;
     46LinkID::LinkID() : isvalid(false) {
    5747}
    5848
    59 const char* LinkID::getInfo( const LinkID& id ) {
    60         if (!id.valid())
    61                 return UNSPECIFIED_LINK;
    62         if ( link_ids.count(id.local_id) == 0 )
    63                 return UNKNOWN_LINK;
    64         const char* info = link_ids.find( id.local_id )->second;
    65         if (info == NULL)
    66                 return NULL_INFO;
    67         return info;
     49LinkID::LinkID(const Identifier& identifier) : Identifier(identifier), isvalid(true) {
    6850}
    6951
    70 /// create a new locally unique link id
    71 LinkID LinkID::create( const char* info ) {
    72         assert( link_ids.size() != 0xFFFE );
    73         uint16_t id;
    74         do {
    75                 id = rand() & 0xFFFF;
    76         } while (id == 0 || link_ids.count(id) != 0);
    77         link_ids.insert( std::make_pair(id, info) );
    78         return LinkID(id);
     52LinkID::~LinkID() {
    7953}
    8054
    81 /// free a locally unique link id
    82 void LinkID::destroy( const LinkID& id ) {
    83         link_ids.erase(id.local_id);
     55LinkID::LinkID(const LinkID& rh) : Identifier(rh) {
    8456}
    8557
    86 std::ostream& operator<<(std::ostream& s, const LinkID& id ) {
    87         return s << id.toString();
     58LinkID& LinkID::operator=(const LinkID& rh){
     59
     60        Identifier::operator=( rh );
     61        this->isvalid = rh.isvalid;
     62
     63        return *this;
     64}
     65
     66bool LinkID::valid(){
     67        return isvalid;
     68}
     69
     70LinkID LinkID::create() {
     71        return LinkID( Identifier::random() );
    8872}
    8973
Note: See TracChangeset for help on using the changeset viewer.