PCMOutputNode.h

Go to the documentation of this file.
00001 
00002 //
00003 // This source file is a part of ParCompMark
00004 // Parallel Compositing Benchmark Framework
00005 //
00006 // for latest info see http://parcompmark.sourceforge.net
00007 
00008 //
00009 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00010 // 
00011 // This program is free software; you can redistribute it and/or
00012 // modify it under the terms of the GNU General Public License
00013 // as published by the Free Software Foundation; either version 2
00014 // of the License, or (at your option) any later version.
00015 // 
00016 // This program 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
00019 // GNU General Public License for more details.
00020 // 
00021 // You should have received a copy of the GNU General Public License
00022 // along with this program; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00024 
00027 
00028 #ifndef __PCM_OUTPUTNODE_H__
00029 #  define __PCM_OUTPUTNODE_H__
00030 
00031 //
00032 // Inner includes
00033 //
00034 
00035 #  include "PCMPremeditations.h"
00036 
00037 #  include "PCMName.h"
00038 
00039 #  include "PCMStringConverter.h"
00040 
00041 //
00042 // Outer includes
00043 //
00044 
00045 #  include <string>
00046 
00047 #  include <sstream>
00048 
00049 #  include <list>
00050 
00051 #  include <map>
00052 
00053 #  include <algorithm>
00054 
00055 namespace ParCompMark
00056 {
00057 
00062   class OutputNode:public Name
00063   {
00064 
00065         //
00066         // Unit test class
00067         //
00068 #  ifdef PARCOMPMARK_TEST
00069         friend class ParCompMarkTest::TestOutputNode;
00070 #  endif
00071 
00072         //
00073         // Enumerations
00074         //
00075 
00076    public:
00077 
00079         enum NodeType
00080         {
00081 
00083          DEFINITION,
00084 
00086          INFORMATION,
00087 
00089          REFERENCE,
00090 
00092          STATISTICS,
00093 
00095          TEXT,
00096 
00098          CDATA
00099         };
00100 
00101         //
00102         // Typedefs
00103         //
00104 
00105    public:
00106 
00108         typedef Pointer < OutputNode,
00109         Mutex > Pointer;
00110 
00112         typedef std::list < OutputNode::Pointer > ChildNodeList;
00113 
00115         typedef ChildNodeList::iterator ChildNodeListIterator;
00116 
00118         typedef std::map < std::string,
00119         std::string > AttributeMap;
00120 
00122         typedef AttributeMap::const_iterator AttributeMapIterator;
00123 
00124         //
00125         // Class constants
00126         //
00127 
00129 
00130 
00131    protected:
00132 
00138         static const std::string TEXTNODENAME;
00139 
00141 
00142         //
00143         // Variables
00144         //
00145 
00147 
00148 
00149    protected:
00150 
00156         NodeType mType;
00157 
00163         AttributeMap mAttributes;
00164 
00170         ChildNodeList mChildren;
00171 
00177         std::string mText;
00178 
00180 
00181         //
00182         // Constructors & destructor
00183         //
00184 
00186 
00187 
00188    public:
00189 
00195         OutputNode(const std::string & name, const NodeType & type);
00196 
00201         OutputNode(const std::string & text);
00202 
00206         virtual ~ OutputNode();
00207 
00209 
00210         //
00211         // Getters & setters
00212         //
00213 
00215 
00216 
00217    public:
00218 
00224         static const std::string & getEXTNODENAME();
00225 
00231         const OutputNode::NodeType & getType() const;
00232 
00238         const std::string & getText() const;
00239 
00245         void setText(const std::string & text);
00246 
00248 
00249         //
00250         // Class methods
00251         //
00252 
00254 
00255 
00256    public:
00257 
00263         static OutputNode::Pointer parseFromXML(std::string & xmlDocument);
00264 
00265    protected:
00266 
00272         static bool _testXMLName(const std::string & name);
00273 
00279         static std::string _convertSpecialChars(const std::string & string);
00280 
00282 
00283         //
00284         // Methods
00285         //
00286 
00288 
00289 
00290    public:
00291 
00298         virtual OutputNode::Pointer createChildNode(const std::string & name, const NodeType & type);
00299 
00305         virtual OutputNode::Pointer createChildNode(const std::string & text);
00306 
00311         virtual void addChildNode(OutputNode::Pointer child);
00312 
00317         virtual u32 getChildCount();
00318 
00323         virtual OutputNode::Pointer getFirstChildNode();
00324 
00330         virtual bool hasAttribute(const std::string & attribute) const;
00331 
00337         virtual const std::string & getAttribute(const std::string & attribute) const;
00338 
00344         virtual void setAttribute(const std::string & attribute, const std::string & value);
00345 
00351         virtual std::ostringstream & serialize2XML(std::ostringstream & osstr);
00352 
00357         virtual std::string serialize2XML();
00358 
00362         virtual void refreshData();
00363 
00367         virtual void clean();
00368 
00370 
00371   };
00372 
00373   //
00374   // Include header implementation
00375   //
00376 
00377 #  include "PCMOutputNode_impl.h"
00378 
00379 }
00380 
00381 #endif