PCMCPU.cpp
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 #include "../include/PCMCPU.h"
00029 
00030 namespace ParCompMark
00031 {
00032 
00033   
00034   
00035   
00036 
00037   CPU::CPU(const std::string & name, const OutputNode::NodeType & type):
00038         
00039   OutputNode(name               
00040            , type               
00041         )
00042         
00043         
00044         
00045         
00046         
00047         
00048         
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   
00070   
00071 
00072   CPU::Pointer CPU::parseXML(TiXmlElement * &tiCPU)
00073   {
00074 
00075         
00076         std::string cpuNamespace;
00077 
00078         
00079         std::string cpuName;
00080 
00081         
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         
00106         CPU::Pointer myCPU = CPU::Pointer(new CPU(cpuName, nspace));
00107 
00108         TiXmlElement *tiParam = tiCPU->FirstChildElement();
00109 
00110         
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   
00161   
00162 
00163   void CPU::refreshData()
00164   {
00165 
00166   }
00167 
00168  
00169 
00170 }