Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LOW_network.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           LOW_network.cpp  -  description
00003                              -------------------
00004     begin                : Tue Jul 23 2002
00005     copyright            : (C) 2002 by Harald Roelle, Helmut Reiser
00006     email                : roelle@informatik.uni-muenchen.de, reiser@informatik.uni-muenchen.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "LOW_network.h"
00019 
00020 
00021 //=====================================================================================
00022 //
00023 // constructors
00024 //
00025   
00026 LOW_network::LOW_network()
00027 {
00028 }
00029 
00030 
00031 LOW_network::~LOW_network()
00032 {
00033   for( unsigned int a=0; a<segmentsList.size(); a++)
00034     delete segmentsList[a];
00035 }
00036 
00037 
00038 
00039 //=====================================================================================
00040 //
00041 // public methods
00042 //
00043   
00044 void LOW_network::addLink( LOW_link *inLink)
00045 {
00046   for( unsigned int a=0; a<linkList.size(); a++) {
00047     if ( *(linkList[a]) == *inLink )
00048       return;
00049   }
00050 
00051   linkList.push_back( inLink);
00052   addSegments( *inLink);
00053 }
00054 
00055 
00056 void LOW_network::removeLink( LOW_link *inLink)
00057 {
00058   for( unsigned int a=0; a<linkList.size(); a++) {
00059     if ( *(linkList[a]) == *inLink ) {
00060 
00061       // remove all segments on this link
00062       for( LOW_netSegment::netSegPtrVec_t::iterator b=segmentsList.begin(); b!=segmentsList.end();) {
00063         if ( (*b)->getLink() == *inLink ) {
00064           delete (*b);
00065           b = segmentsList.erase( b);
00066         }
00067         else
00068           ++b;
00069       }
00070 
00071       // remove the link from the list
00072       linkList.erase( linkList.begin()+a);
00073       return;
00074     }
00075   }
00076 
00077   throw network_error( "Link is not registered.", __FILE__, __LINE__);
00078 }
00079 
00080 
00081 LOW_netSegment::netSegPtrVec_t  LOW_network::getSegments() const
00082 {
00083   return segmentsList;
00084 }
00085 
00086 
00087 
00088 bool LOW_network::verifyDevice( const LOW_deviceID inDevID, const bool inOnlyAlarm) const
00089 {
00090   LOW_device* theDev;
00091   try {
00092     theDev = getDevice<LOW_device>( inDevID);
00093   }
00094   catch ( LOW_exception ex) {
00095     return false;
00096   }
00097 
00098   return theDev->verifyDevice( inOnlyAlarm);
00099 }
00100 
00101 
00102 
00103 //=====================================================================================
00104 //
00105 // protected methods
00106 //
00107 
00108 void LOW_network::addSegments( LOW_link &inLink)
00109 {
00110   LOW_netSegment::netSegPtrVec_t  newSegments;
00111   
00112   newSegments = LOW_netSegment::newSegmentsFromLink( inLink);
00113 
00114   for( unsigned int a=0; a<newSegments.size(); a++)
00115     segmentsList.push_back( newSegments[a]);
00116 }

Generated on Sun Jan 12 21:07:43 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001