src/material-benefit-list.cpp

00001 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
00002 /*
00003  * frpuniverse
00004  * Copyright (C) Peter L. Berghold 2008 <Peter@Berghold.net>
00005  * 
00006  * frpuniverse is free software.
00007  * 
00008  * You may redistribute it and/or modify it under the terms of the
00009  * GNU General Public License, as published by the Free Software
00010  * Foundation; either version 2 of the License, or (at your option)
00011  * any later version.
00012  * 
00013  * frpuniverse is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with frpuniverse.  If not, write to:
00020  *      The Free Software Foundation, Inc.,
00021  *      51 Franklin Street, Fifth Floor
00022  *      Boston, MA  02110-1301, USA.
00023  */
00024 #include <string.h>
00025 
00026 #include "material-benefit-list.hpp"
00027 #include "xmlutils.hpp"
00028 
00029 #define MBLTAG "material-benefit-list"
00030 
00031 materialBenefitList::materialBenefitList():slinkList(){
00032 }
00033 
00034 void materialBenefitList::addBenefit(materialBenefit *p){
00035 #ifdef DEBUG_ON
00036         FILE* diaglog = fopen("diaglog.log","a+");
00037 #endif
00038         materialBenefit *r = (materialBenefit*) getRoot();
00039 #ifdef DEBUG_ON
00040         fprintf(diaglog,"Adding a \"%s\" to our benefits\n",p->getSignature());
00041 #endif
00042         
00043         while (r->getNext() != (materialBenefit*)0){
00044                 r = (materialBenefit*)r->getNext();
00045                 if ( strcmp(p->getSignature(),r->getSignature()) == 0 ) {
00046 #ifdef DEBUG_ON
00047                         fprintf(diaglog,"\tMerging...\n");
00048 #endif
00049                         r->merge(p);
00050                         return;
00051                 }
00052         }
00053         
00055 #ifdef DEBUG_ON
00056         fprintf(diaglog,"\tappending..\n");
00057         fclose(diaglog);
00058 #endif
00059         this->append(p);
00060 }
00061 
00062 void materialBenefitList::XMLout(FILE* fout){
00063         materialBenefit* r=(materialBenefit*) getRoot();
00064         
00065         fprintf(fout,"\t%s\n",createStartElement(MBLTAG));
00066         while(r->getNext() != (materialBenefit*)0){
00067                 r = (materialBenefit*) r->getNext();
00068                 r->XMLout(fout);
00069         }
00070         fprintf(fout,"\t%s\n",createEndElement(MBLTAG));
00071 }
00072 
00073 

Generated on Fri Mar 7 16:40:53 2008 for frpuniverse by  doxygen 1.4.7