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

TypeCodeList.cpp

Go to the documentation of this file.
00001 // /******************************************************************************\
00002 // *
00003 // * File:          TypeCodeList.cpp
00004 // * Creation date: June 14, 2001 08:46
00005 // * Author:        ClassBuilder
00006 // *                XXXX
00007 // * Purpose:       Method implementations of class 'TypeCodeList'
00008 // *
00009 // * Modifications: @INSERT_MODIFICATIONS(* )
00010 // * June 19, 2001 12:44 WERS
00011 // *     Deleted method 'FindRecursion'
00012 // * June 19, 2001 10:45 WERS
00013 // *     Added method 'FindRecursion'
00014 // *     Updated return type of method 'FindRecursion'
00015 // * June 14, 2001 08:46 WERS
00016 // *     Added method 'DestructorInclude'
00017 // *     Added method 'ConstructorInclude'
00018 // *     Added method 'Exists'
00019 // *     Added method '~TypeCodeList'
00020 // *     Added method 'TypeCodeList'
00021 // *     Added relation 'TypeCodeList <>-->> TypeCodeElm'
00022 // *
00023 // *
00024 // \******************************************************************************/
00025 //@START_USER1
00030 /* --------------------------------------------------------------
00031 Copyright (C) 2001 LifeLine Networks BV <soap2corba@lifeline.nl>
00032 
00033 This program is free software; you can redistribute it and/or
00034 modify it under the terms of the GNU General Public License
00035 as published by the Free Software Foundation; either
00036 version 2 of the License, or (at your option) any later
00037 version.
00038 
00039 This program is distributed in the hope that it will be useful,
00040 but WITHOUT ANY WARRANTY; without even the implied warranty of
00041 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00042 GNU General Public License for more details.
00043 
00044 You should have received a copy of the GNU General Public License
00045 along with this program; if not, write to the Free Software
00046 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00047 -------------------------------------------------------------- */
00048 //@END_USER1
00049 
00050 
00051 // Master include file
00052 #include "RecurStop.h"
00053 
00054 
00055 //@START_USER2
00056 //@END_USER2
00057 
00058 
00059 // Static members
00060 
00061 
00065 TypeCodeList::TypeCodeList() //@INIT_179
00066 {//@CODE_179
00067     ConstructorInclude();
00068 
00069     // Put in your own code
00070 }//@CODE_179
00071 
00072 
00076 TypeCodeList::~TypeCodeList()
00077 {//@CODE_19
00078     DestructorInclude();
00079 
00080     // Put in your own code
00081 }//@CODE_19
00082 
00083 
00084 bool TypeCodeList::Exists(CORBA::TypeCode_ptr tc)
00085 {//@CODE_177
00086     bool value = false;
00087 
00088     TypeCodeElmIterator iTypeCodeElm(this);
00089     while (!value && ++iTypeCodeElm)
00090     {
00091         value = iTypeCodeElm->m_tc->equal (tc);
00092     }
00093     return value;
00094 }//@CODE_177
00095 
00096 
00097 //{{AFX DO NOT EDIT CODE BELOW THIS LINE !!!
00098 
00102 void TypeCodeList::ConstructorInclude()
00103 {
00104     // INIT_MULTI_OWNED_ACTIVE(TypeCodeList, TypeCodeList, TypeCodeElm, TypeCodeElm)
00105    
00106     _firstTypeCodeElm = (TypeCodeElm*)0;
00107     _lastTypeCodeElm = (TypeCodeElm*)0;
00108     _countTypeCodeElm = 0;
00109 }
00110 
00111 
00115 void TypeCodeList::DestructorInclude()
00116 {
00117     // EXIT_MULTI_OWNED_ACTIVE(TypeCodeList, TypeCodeList, TypeCodeElm, TypeCodeElm)
00118     { for (TypeCodeElm* item = GetFirstTypeCodeElm(); item; item = GetFirstTypeCodeElm())
00119           delete item; }
00120 }
00121 
00122 
00123 // Methods for the relation(s) of the class
00124 // METHODS_MULTI_OWNED_ACTIVE(TypeCodeList, TypeCodeList, TypeCodeElm, TypeCodeElm)
00125 void TypeCodeList::AddTypeCodeElmFirst(TypeCodeElm* item)
00126 {
00127     
00128     assert(this);
00129 
00130     assert(item);
00131     assert(item->_refTypeCodeList == (TypeCodeList*)0);
00132 
00133     _countTypeCodeElm++;
00134 
00135     item->_refTypeCodeList = this;
00136 
00137     if (_firstTypeCodeElm)
00138     {
00139         _firstTypeCodeElm->_prevTypeCodeList = item;
00140         item->_nextTypeCodeList = _firstTypeCodeElm;
00141         _firstTypeCodeElm = item;
00142     }
00143     else
00144         _firstTypeCodeElm = _lastTypeCodeElm = item; 
00145 }
00146 
00147 void TypeCodeList::AddTypeCodeElmLast(TypeCodeElm* item)
00148 {
00149     
00150     assert(this);
00151 
00152     assert(item);
00153     assert(item->_refTypeCodeList == (TypeCodeList*)0);
00154 
00155     _countTypeCodeElm++;
00156 
00157     item->_refTypeCodeList = this;
00158 
00159     if (_lastTypeCodeElm)
00160     {
00161         _lastTypeCodeElm->_nextTypeCodeList = item;
00162         item->_prevTypeCodeList = _lastTypeCodeElm;
00163         _lastTypeCodeElm = item;
00164     }
00165     else
00166         _firstTypeCodeElm = _lastTypeCodeElm = item; 
00167 }
00168 
00169 void TypeCodeList::AddTypeCodeElmAfter(TypeCodeElm* item, TypeCodeElm* pos)
00170 {
00171     
00172     assert(this);
00173 
00174     assert(item);
00175     assert(item->_refTypeCodeList == (TypeCodeList*)0);
00176 
00177     assert(pos);
00178     assert(pos->_refTypeCodeList == this);
00179 
00180     _countTypeCodeElm++;
00181 
00182     item->_refTypeCodeList = this;
00183     item->_prevTypeCodeList = pos;
00184     item->_nextTypeCodeList = pos->_nextTypeCodeList;
00185     pos->_nextTypeCodeList  = item;
00186 
00187     if (item->_nextTypeCodeList)
00188         item->_nextTypeCodeList->_prevTypeCodeList = item;
00189     else
00190         _lastTypeCodeElm = item; 
00191 }
00192 
00193 void TypeCodeList::AddTypeCodeElmBefore(TypeCodeElm* item, TypeCodeElm* pos)
00194 {
00195     
00196     assert(this);
00197 
00198     assert(item);
00199     assert(item->_refTypeCodeList == (TypeCodeList*)0);
00200 
00201     assert(pos);
00202     assert(pos->_refTypeCodeList == this);
00203 
00204     _countTypeCodeElm++;
00205 
00206     item->_refTypeCodeList = this;
00207     item->_nextTypeCodeList = pos;
00208     item->_prevTypeCodeList = pos->_prevTypeCodeList;
00209     pos->_prevTypeCodeList  = item;
00210 
00211     if (item->_prevTypeCodeList)
00212         item->_prevTypeCodeList->_nextTypeCodeList = item;
00213     else
00214         _firstTypeCodeElm = item; 
00215 }
00216 
00217 void TypeCodeList::RemoveTypeCodeElm(TypeCodeElm* item)
00218 {
00219     
00220     assert(this);
00221 
00222     assert(item);
00223     assert(item->_refTypeCodeList == this);
00224 
00225     TypeCodeList::TypeCodeElmIterator::Check(item);
00226 
00227     _countTypeCodeElm--;
00228 
00229     if (item->_nextTypeCodeList)
00230         item->_nextTypeCodeList->_prevTypeCodeList = item->_prevTypeCodeList;
00231     else
00232         _lastTypeCodeElm = item->_prevTypeCodeList;
00233 
00234     if (item->_prevTypeCodeList)
00235         item->_prevTypeCodeList->_nextTypeCodeList = item->_nextTypeCodeList;
00236     else
00237         _firstTypeCodeElm = item->_nextTypeCodeList;
00238 
00239     item->_prevTypeCodeList = (TypeCodeElm*)0;
00240     item->_nextTypeCodeList = (TypeCodeElm*)0;
00241     item->_refTypeCodeList = (TypeCodeList*)0; 
00242 }
00243 
00244 void TypeCodeList::DeleteAllTypeCodeElm()
00245 {
00246     
00247     assert(this);
00248 
00249     for (TypeCodeElm* item = GetFirstTypeCodeElm(); item; item = GetFirstTypeCodeElm())
00250           delete item; 
00251 }
00252 
00253 void TypeCodeList::ReplaceTypeCodeElm(TypeCodeElm* item, TypeCodeElm* newItem)
00254 {
00255     
00256     assert(this);
00257 
00258     assert(item);
00259     assert(item->_refTypeCodeList == this);
00260 
00261     assert(newItem);
00262     assert(newItem->_refTypeCodeList == (TypeCodeList*)0);
00263 
00264     TypeCodeList::TypeCodeElmIterator::Check(item, newItem);
00265 
00266     if (item->_nextTypeCodeList)
00267         item->_nextTypeCodeList->_prevTypeCodeList = newItem;
00268     else
00269         _lastTypeCodeElm = newItem;
00270 
00271     if (item->_prevTypeCodeList)
00272         item->_prevTypeCodeList->_nextTypeCodeList = newItem;
00273     else
00274         _firstTypeCodeElm = newItem;
00275 
00276     newItem->_nextTypeCodeList = item->_nextTypeCodeList;
00277     newItem->_prevTypeCodeList = item->_prevTypeCodeList;
00278     item->_nextTypeCodeList = (TypeCodeElm*)0;
00279     item->_prevTypeCodeList = (TypeCodeElm*)0;
00280 
00281     item->_refTypeCodeList = (TypeCodeList*)0;
00282     newItem->_refTypeCodeList = this; 
00283 }
00284 
00285 TypeCodeElm* TypeCodeList::GetFirstTypeCodeElm() const
00286 {
00287     
00288     assert(this);
00289     return _firstTypeCodeElm; 
00290 }
00291 
00292 TypeCodeElm* TypeCodeList::GetLastTypeCodeElm() const
00293 {
00294     
00295     assert(this);
00296     return _lastTypeCodeElm; 
00297 }
00298 
00299 TypeCodeElm* TypeCodeList::GetNextTypeCodeElm(TypeCodeElm* pos) const
00300 {
00301     
00302     assert(this);
00303 
00304     if (pos == (TypeCodeElm*)0)
00305         return _firstTypeCodeElm;
00306 
00307     assert(pos);
00308     assert(pos->_refTypeCodeList == this);
00309 
00310     return pos->_nextTypeCodeList; 
00311 }
00312 
00313 TypeCodeElm* TypeCodeList::GetPrevTypeCodeElm(TypeCodeElm* pos) const
00314 {
00315     
00316     assert(this);
00317 
00318     if (pos == (TypeCodeElm*)0)
00319         return _lastTypeCodeElm;
00320 
00321     assert(pos);
00322     assert(pos->_refTypeCodeList == this);
00323 
00324     return pos->_prevTypeCodeList; 
00325 }
00326 
00327 int TypeCodeList::GetTypeCodeElmCount() const
00328 {
00329     
00330     assert(this);
00331     return _countTypeCodeElm; 
00332 }
00333 
00334 void TypeCodeList::MoveTypeCodeElmFirst(TypeCodeElm* item)
00335 {
00336     
00337     assert(item);
00338     assert(item->_refTypeCodeList);
00339     item->_refTypeCodeList->RemoveTypeCodeElm(item);
00340     AddTypeCodeElmFirst(item); 
00341 }
00342 
00343 void TypeCodeList::MoveTypeCodeElmLast(TypeCodeElm* item)
00344 {
00345     
00346     assert(item);
00347     assert(item->_refTypeCodeList);
00348     item->_refTypeCodeList->RemoveTypeCodeElm(item);
00349     AddTypeCodeElmLast(item); 
00350 }
00351 
00352 void TypeCodeList::MoveTypeCodeElmAfter(TypeCodeElm* item, TypeCodeElm* pos)
00353 {
00354     
00355     assert(item);
00356     assert(item->_refTypeCodeList);
00357     item->_refTypeCodeList->RemoveTypeCodeElm(item);
00358     AddTypeCodeElmAfter(item, pos); 
00359 }
00360 
00361 void TypeCodeList::MoveTypeCodeElmBefore(TypeCodeElm* item, TypeCodeElm* pos)
00362 {
00363     
00364     assert(item);
00365     assert(item->_refTypeCodeList);
00366     item->_refTypeCodeList->RemoveTypeCodeElm(item);
00367     AddTypeCodeElmBefore(item, pos); 
00368 }
00369 
00370 void TypeCodeList::SortTypeCodeElm(int (*comp)(TypeCodeElm*, TypeCodeElm*))
00371 {
00372     
00373     for (TypeCodeElm* a = GetFirstTypeCodeElm(); a; a = GetNextTypeCodeElm(a))
00374     {
00375         TypeCodeElm* b = GetNextTypeCodeElm(a);
00376 
00377         while (b && (comp(a, b) > 0))
00378         {
00379             TypeCodeElm* c = GetPrevTypeCodeElm(a);
00380             while (c && (comp(c, b) > 0))
00381                 c = GetPrevTypeCodeElm(c);
00382 
00383             if (c)
00384                 MoveTypeCodeElmAfter(b, c);
00385             else
00386                 MoveTypeCodeElmFirst(b);
00387 
00388             b = GetNextTypeCodeElm(a);
00389         }
00390     } 
00391 }
00392 // METHODS_ITERATOR_MULTI_ACTIVE(TypeCodeList, TypeCodeList, TypeCodeElm, TypeCodeElm)
00393 TypeCodeList::TypeCodeElmIterator* TypeCodeList::TypeCodeElmIterator::_first = 0;
00394 TypeCodeList::TypeCodeElmIterator* TypeCodeList::TypeCodeElmIterator::_last = 0;
00395 
00396 TypeCodeList::TypeCodeElmIterator::TypeCodeElmIterator(
00397     const TypeCodeList* iterTypeCodeList,
00398     int (TypeCodeElm::*method)() const,
00399     TypeCodeElm* refTypeCodeElm)
00400 {
00401     assert(iterTypeCodeList);
00402 
00403     _iterTypeCodeList = iterTypeCodeList;
00404     _refTypeCodeElm = _prevTypeCodeElm = _nextTypeCodeElm = refTypeCodeElm;
00405     _prev = (TypeCodeElmIterator*)0;
00406     _next = (TypeCodeElmIterator*)0;
00407     _method = method;
00408     if (_last)
00409     {
00410         _last->_next = this;
00411         _prev = _last;
00412         _last = this;
00413     }
00414     else
00415         _first = _last = this;
00416 }
00417 
00418 TypeCodeList::TypeCodeElmIterator::TypeCodeElmIterator(
00419     const TypeCodeList& iterTypeCodeList,
00420     int (TypeCodeElm::*method)() const,
00421     TypeCodeElm* refTypeCodeElm)
00422 {
00423     assert(&iterTypeCodeList);
00424 
00425     _iterTypeCodeList = &iterTypeCodeList;
00426     _refTypeCodeElm = _prevTypeCodeElm = _nextTypeCodeElm = refTypeCodeElm;
00427     _prev = (TypeCodeElmIterator*)0;
00428     _next = (TypeCodeElmIterator*)0;
00429     _method = method;
00430     if (_last)
00431     {
00432         _last->_next = this;
00433         _prev = _last;
00434         _last = this;
00435     }
00436     else
00437         _first = _last = this;
00438 }
00439 
00440 TypeCodeList::TypeCodeElmIterator::TypeCodeElmIterator(
00441     const TypeCodeElmIterator& iterator,
00442     int (TypeCodeElm::*method)() const)
00443 {
00444     _iterTypeCodeList = iterator._iterTypeCodeList;
00445     _refTypeCodeElm = iterator._refTypeCodeElm;
00446     _prevTypeCodeElm = iterator._prevTypeCodeElm;
00447     _nextTypeCodeElm = iterator._nextTypeCodeElm;
00448     _prev = (TypeCodeElmIterator*)0;
00449     _next = (TypeCodeElmIterator*)0;
00450     _method = method;
00451     if (_last)
00452     {
00453         _last->_next = this;
00454         _prev = _last;
00455         _last = this;
00456     }
00457     else
00458         _first = _last = this;
00459 }
00460 
00461 TypeCodeList::TypeCodeElmIterator::~TypeCodeElmIterator()
00462 {
00463     if (_next)
00464         _next->_prev = _prev;
00465     else
00466         _last = _prev;
00467 
00468     if (_prev)
00469         _prev->_next = _next;
00470     else
00471         _first = _next;
00472 }
00473 
00474 void TypeCodeList::TypeCodeElmIterator::Check(TypeCodeElm* itemTypeCodeElm)
00475 {
00476     for (TypeCodeElmIterator* item = _first; item; item = item->_next)
00477     {
00478         if (item->_prevTypeCodeElm == itemTypeCodeElm)
00479         {
00480             item->_prevTypeCodeElm = item->_iterTypeCodeList->GetNextTypeCodeElm(item->_prevTypeCodeElm);
00481             item->_refTypeCodeElm = 0;
00482         }
00483         if (item->_nextTypeCodeElm == itemTypeCodeElm)
00484         {
00485             item->_nextTypeCodeElm = item->_iterTypeCodeList->GetPrevTypeCodeElm(item->_nextTypeCodeElm);
00486             item->_refTypeCodeElm = 0;
00487         }
00488     }
00489 }
00490 
00491 void TypeCodeList::TypeCodeElmIterator::Check(TypeCodeElm* itemTypeCodeElm, TypeCodeElm* newItemTypeCodeElm)
00492 {
00493     for (TypeCodeElmIterator* item = _first; item; item = item->_next)
00494     {
00495         if (item->_refTypeCodeElm == itemTypeCodeElm)
00496         {
00497             item->_refTypeCodeElm = item->_prevTypeCodeElm = item->_nextTypeCodeElm = newItemTypeCodeElm;
00498         }
00499         if (item->_prevTypeCodeElm == itemTypeCodeElm)
00500         {
00501             item->_prevTypeCodeElm = newItemTypeCodeElm;
00502             item->_refTypeCodeElm = 0;
00503         }
00504         if (item->_nextTypeCodeElm == itemTypeCodeElm)
00505         {
00506             item->_nextTypeCodeElm = newItemTypeCodeElm;
00507             item->_refTypeCodeElm = 0;
00508         }
00509     }
00510 }
00511 
00512 //}}AFX DO NOT EDIT CODE ABOVE THIS LINE !!!
00513 
00514 //@START_USER3
00515 

This documentation is part of the "SOAP to CORBA bridge" project
Copyright © 2000 by Lifeline Networks bv.
All rights are reserved.