PCMCPU.cpp

Go to the documentation of this file.
00001 //
00002 // This source file is a part of ParCompMark
00003 // Parallel Compositing Benchmark Framework
00004 //
00005 // for latest info see http://parcompmark.sourceforge.net
00006 
00007 //
00008 // Copyright (C) 2006 IT2 ParCompMark Dev. Team
00009 // 
00010 // This program is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public License
00012 // as published by the Free Software Foundation; either version 2
00013 // of the License, or (at your option) any later version.
00014 // 
00015 // This program is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 // GNU General Public License for more details.
00019 // 
00020 // You should have received a copy of the GNU General Public License
00021 // along with this program; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023 
00024 //
00025 // Inner includes
00026 //
00027 
00028 #include "../include/PCMCPU.h"
00029 
00030 namespace ParCompMark
00031 {
00032 
00033   //
00034   // Constructors & destructor
00035   //
00036 
00037   CPU::CPU(const std::string & name, const OutputNode::NodeType & type):
00038         // Parent constructor call 
00039   OutputNode(name               /* Name of the node */
00040            , type               /* Type of the node */
00041         )
00042         // You have to initialize the following attributes:
00043         // - mVendor
00044         // - mModel
00045         // - mClock
00046         // - mCache
00047         // - mBogomips
00048         // - mFlags
00049   {
00050 
00051         mVendor = "";
00052         mModel = "";
00053         mClock = 0.0;
00054         mCache = 0;
00055         mBogomips = 0.0;
00056         mFlags = "";
00057 
00058   }
00059 
00060  /*----------------------------------------------------------------------*/
00061 
00062   CPU::~CPU()
00063   {
00064   }
00065 
00066  /*----------------------------------------------------------------------*/
00067 
00068   //
00069   // Class methods
00070   //
00071 
00072   CPU::Pointer CPU::parseXML(TiXmlElement * &tiCPU)
00073   {
00074 
00075         //namespace of current cpu
00076         std::string cpuNamespace;
00077 
00078         //name of current cpu
00079         std::string cpuName;
00080 
00081         //set value of current cpu name and namespace
00082         std::string cpuTag(tiCPU->Value());
00083         std::string::size_type pos = cpuTag.find_first_of(":");
00084         if(pos != std::string::npos)
00085         {
00086          cpuNamespace = cpuTag.substr(0, pos);
00087          cpuName = cpuTag.substr(pos + 1);
00088         } else
00089         {
00090          cpuNamespace = "info";
00091          cpuName = "NoNameCPU";
00092         }
00093 
00094         OutputNode::NodeType nspace;
00095 
00096         if(cpuNamespace == "def")
00097          nspace = OutputNode::DEFINITION;
00098         else if(cpuNamespace == "info")
00099          nspace = OutputNode::INFORMATION;
00100         else if(cpuNamespace == "ref")
00101          nspace = OutputNode::REFERENCE;
00102         else if(cpuNamespace == "stat")
00103          nspace = OutputNode::STATISTICS;
00104 
00105         //make a pointer to a newly created cpu with the use of cpu name and namespace
00106         CPU::Pointer myCPU = CPU::Pointer(new CPU(cpuName, nspace));
00107 
00108         TiXmlElement *tiParam = tiCPU->FirstChildElement();
00109 
00110         //saving cpu parameters
00111         for(; tiParam != NULL; tiParam = tiParam->NextSiblingElement())
00112         {
00113          std::string name(tiParam->Attribute("name"));
00114          std::string value(tiParam->Attribute("value"));
00115 
00116          if(name == "vendor-id")
00117          {
00118                 myCPU->mVendor = value;
00119          } else if(name == "model-name")
00120          {
00121                 myCPU->mModel = value;
00122          } else if(name == "cpu-mhz")
00123          {
00124                 std::stringstream strStream;
00125                 double dNum;
00126 
00127                 strStream << value;
00128                 strStream >> dNum;
00129 
00130                 myCPU->mClock = dNum;
00131          } else if(name == "bogomips")
00132          {
00133                 std::stringstream strStream;
00134                 double dNum;
00135 
00136                 strStream << value;
00137                 strStream >> dNum;
00138 
00139                 myCPU->mBogomips = dNum;
00140          } else if(name == "flags")
00141                 myCPU->mFlags = value;
00142          else if(name == "cache-size")
00143          {
00144                 std::stringstream strStream;
00145                 int iNum;
00146 
00147                 strStream << value;
00148                 strStream >> iNum;
00149 
00150                 myCPU->mCache = iNum;
00151          }
00152         }
00153 
00154         return CPU::Pointer(myCPU);
00155   }
00156 
00157  /*----------------------------------------------------------------------*/
00158 
00159   //
00160   // Methods
00161   //
00162 
00163   void CPU::refreshData()
00164   {
00165 
00166   }
00167 
00168  /*----------------------------------------------------------------------*/
00169 
00170 }