plan.cpp
Go to the documentation of this file.00001 /*************************************************************************** 00002 file : $URL: https://frepple.svn.sourceforge.net/svnroot/frepple/trunk/src/model/plan.cpp $ 00003 version : $LastChangedRevision: 746 $ $LastChangedBy: jdetaeye $ 00004 date : $LastChangedDate: 2008-04-19 11:23:51 +0200 (Sat, 19 Apr 2008) $ 00005 ***************************************************************************/ 00006 00007 /*************************************************************************** 00008 * * 00009 * Copyright (C) 2007 by Johan De Taeye * 00010 * * 00011 * This library is free software; you can redistribute it and/or modify it * 00012 * under the terms of the GNU Lesser General Public License as published * 00013 * by the Free Software Foundation; either version 2.1 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This library is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * 00019 * General Public License for more details. * 00020 * * 00021 * You should have received a copy of the GNU Lesser General Public * 00022 * License along with this library; if not, write to the Free Software * 00023 * Foundation Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA * 00024 * * 00025 ***************************************************************************/ 00026 00027 00028 #define FREPPLE_CORE 00029 #include "frepple/model.h" 00030 00031 namespace frepple 00032 { 00033 00034 00035 DECLARE_EXPORT Plan* Plan::thePlan; 00036 00037 00038 DECLARE_EXPORT Plan::~Plan() 00039 { 00040 // Closing the logfile 00041 Environment::setLogFile(""); 00042 00043 // Clear the pointer to this singleton object 00044 thePlan = NULL; 00045 } 00046 00047 00048 DECLARE_EXPORT void Plan::setCurrent (Date l) 00049 { 00050 // Update the time 00051 cur_Date = l; 00052 00053 // Let all operationplans check for new ProblemBeforeCurrent and 00054 // ProblemBeforeFence problems. 00055 for (Operation::iterator i = Operation::begin(); i != Operation::end(); ++i) 00056 i->setChanged(); 00057 } 00058 00059 00060 DECLARE_EXPORT void Plan::writeElement (XMLOutput *o, const Keyword& tag, mode m) const 00061 { 00062 // No references 00063 assert(m != REFERENCE); 00064 00065 // Opening tag 00066 if (m!=NOHEADER) o->BeginObject(tag); 00067 00068 // Write all own fields 00069 o->writeElement(Tags::tag_name, name); 00070 o->writeElement(Tags::tag_description, descr); 00071 o->writeElement(Tags::tag_current, cur_Date); 00072 o->writeElement(Tags::tag_logfile, Environment::getLogFile()); 00073 Plannable::writeElement(o, tag); 00074 00075 // Persist all categories 00076 MetaCategory::persist(o); 00077 00078 o->EndObject(tag); 00079 } 00080 00081 00082 DECLARE_EXPORT void Plan::endElement (XMLInput& pIn, const Attribute& pAttr, const DataElement& pElement) 00083 { 00084 if (pAttr.isA(Tags::tag_current)) 00085 setCurrent(pElement.getDate()); 00086 else if (pAttr.isA(Tags::tag_description)) 00087 pElement >> descr; 00088 else if (pAttr.isA(Tags::tag_name)) 00089 pElement >> name; 00090 else if (pAttr.isA(Tags::tag_logfile)) 00091 Environment::setLogFile(pElement.getString()); 00092 else 00093 Plannable::endElement(pIn, pAttr, pElement); 00094 } 00095 00096 00097 DECLARE_EXPORT void Plan::beginElement (XMLInput& pIn, const Attribute& pAttr) 00098 { 00099 if (pAttr.isA(Tags::tag_commands)) 00100 // Handling of commands, a category which doesn't have a category reader 00101 pIn.readto(&(pIn.getCommands())); 00102 else 00103 { 00104 const MetaCategory *cat = MetaCategory::findCategoryByGroupTag(pIn.getParentElement().first.getHash()); 00105 if (cat) 00106 { 00107 if (cat->readFunction) 00108 // Hand over control to a registered read controller 00109 pIn.readto(cat->readFunction(*cat,pIn.getAttributes())); 00110 else 00111 // There is no controller available. 00112 // This piece of code will be used to skip pieces of the XML file that 00113 // Frepple doesn't need to be understand 00114 pIn.IgnoreElement(); 00115 } 00116 } 00117 } 00118 00119 00120 }
Documentation generated by
