Alex Bikfalvi
SimStream Documentation
StreamBootPushMulti.cpp
00001 #include "Headers.h" 00002 #include "StreamBootPushMulti.h" 00003 00004 CStreamBootPushMulti::CStreamBootPushMulti(__uint32 layers, CAddress root) 00005 { 00006 assert(layers); 00007 00008 this->layers = layers; 00009 this->root = root; 00010 00011 this->hosts = new List[this->layers]; 00012 } 00013 00014 CStreamBootPushMulti::~CStreamBootPushMulti() 00015 { 00016 delete[] this->hosts; 00017 } 00018 00019 void CStreamBootPushMulti::Register(__uint32 layer, CAddress host, CAddress source) 00020 { 00021 assert(layer < this->layers); 00022 this->hosts[layer].insert(pair<CAddress, CStreamBootEntry>(host, CStreamBootEntry(source))); 00023 } 00024 00025 void CStreamBootPushMulti::Deregister(__uint32 layer, CAddress host) 00026 { 00027 assert(layer < this->layers); 00028 this->hosts[layer].erase(host); 00029 } 00030 00031 bool CStreamBootPushMulti::IsDependent(__uint32 layer, CAddress host, CAddress parent) 00032 { 00033 assert(layer < this->layers); 00034 00035 // For all ancestors from the parent to the root 00036 for(CAddress ancestor = parent; ancestor != this->root;) 00037 { 00038 // If the host is an ancestor of the parent, return true 00039 if(ancestor == host) return true; 00040 00041 // Else, get the entry of the ancestor 00042 List::iterator entry = this->hosts[layer].find(ancestor); 00043 00044 // If there is not entry for the ancestor (the ancestor is orphan), return true 00045 if(this->hosts[layer].end() == entry) return true; 00046 00047 // Else, move the the source of the ancestor 00048 ancestor = entry->second.Source(); 00049 } 00050 return false; 00051 }
Last updated: February 8, 2011