Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

sgmlist.cpp

Go to the documentation of this file.
00001 //**********************************************************************
00002 //                                                                     *
00003 //    Filename:      sgmlist.cpp                                       *
00004 //    Date:          30 Mar 2002                                       *
00005 //    File Version:  1                                                 *
00006 //                                                                     *
00007 //    Description:   List class to hold instances of Signalman class.  *
00008 //                                                                     *
00009 //    Author:        Chris White (whitecf@bcs.org.uk)                  *
00010 //    Company:       Monitor Computing Services Ltd.                   *
00011 //                                                                     *
00012 //**********************************************************************
00013 //                                                                     *
00014 //    Copyright (C) 2002  Monitor Computing Services Ltd.              *
00015 //                                                                     *
00016 //    This program is free software; you can redistribute it and/or    *
00017 //    modify it under the terms of the GNU General Public License      *
00018 //    as published by the Free Software Foundation; either version 2   *
00019 //    of the License, or any later version.                            *
00020 //                                                                     *
00021 //    This program is distributed in the hope that it will be useful,  *
00022 //    but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00023 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00024 //    GNU General Public License for more details.                     *
00025 //                                                                     *
00026 //    You should have received a copy of the GNU General Public        *
00027 //    License (http://www.gnu.org/copyleft/gpl.html) along with this   *
00028 //    program; if not, write to:                                       *
00029 //       The Free Software Foundation Inc.,                            *
00030 //       59 Temple Place - Suite 330,                                  *
00031 //       Boston, MA  02111-1307,                                       *
00032 //       USA.                                                          *
00033 //                                                                     *
00034 //**********************************************************************
00035 //                                                                     *
00036 //    Notes:                                                           *
00037 //                                                                     *
00038 //**********************************************************************
00039 
00040 #include <classlib\listimp.h>
00041 
00042 #include "mytrace.h"
00043 #include "sgnlman.h"
00044 
00045 #include "sgmlist.h"
00046 
00047 
00048 using namespace Monitor::BellMaster;
00049 
00050 
00051 
00052 SignalmanList::SignalmanList() :
00053     myList(0), listSize(0)
00054 {
00055     _USEMYTRACE_("SignalmanList::SignalmanList")
00056 }
00057 
00058 
00059 
00060 SignalmanList::~SignalmanList()
00061 {
00062     _USEMYTRACE_("SignalmanList::~SignalmanList")
00063 
00064     clear();
00065 }
00066 
00067 
00068 
00069 void
00070 SignalmanList::addSignalman(const Signalman    &newSignalman)
00071 {
00072     _USEMYTRACE_("SignalmanList::addSignalman")
00073 
00074     getList().Add(newSignalman);
00075     listSize++;
00076 }
00077 
00078 
00079 
00080 void
00081 SignalmanList::removeSignalman(const Signalman    &oldSignalman)
00082 {
00083     _USEMYTRACE_("SignalmanList::removeSignalman")
00084 
00085     getList().Detach(oldSignalman);
00086     listSize--;
00087 }
00088 
00089 
00090 
00091 void
00092 SignalmanList::clear()
00093 {
00094     _USEMYTRACE_("SignalmanList::clear")
00095 
00096     delete myList, myList = 0;
00097 }
00098 
00099 
00100 
00101 const unsigned&
00102 SignalmanList::size() const
00103 {
00104     return listSize;
00105 }
00106 
00107 
00108 
00109 Signalman&
00110 SignalmanList::operator[](int    index) const
00111 {
00112     TSListIteratorImp< Signalman >    signalmen(getList());
00113 
00114     while (0 < index)
00115     {
00116         index--;
00117         signalmen++;
00118     }
00119 
00120     return const_cast< Signalman& >(signalmen.Current());
00121 }
00122 
00123 
00124 
00125 TSListImp< Signalman >&
00126 SignalmanList::getList() const
00127 {
00128     if (0 == myList)
00129     {
00130         const_cast< SignalmanList* >(this)->myList =
00131             new TSListImp< Signalman >;
00132 
00133         const_cast< SignalmanList* >(this)->listSize = 0;
00134     }
00135 
00136     return *myList;
00137 }
00138 

Generated on Wed Oct 29 20:54:52 2003 for Bellmaster BC Common by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002