PCMGPU.cpp

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 
00025 //
00026 // Inner includes
00027 //
00028 
00029 #include "../include/PCMGPU.h"
00030 
00031 namespace ParCompMark
00032 {
00033 
00034   //
00035   // Constructors & destructor
00036   //
00037 
00038   GPU::GPU(const std::string & name, const OutputNode::NodeType & type):
00039         // Parent constructor call 
00040   OutputNode(name               /* Name of the node */
00041            , type               /* Type of the node */
00042         )
00043         // You have to initialize the following attributes:
00044         // - mVendor
00045         // - mModel
00046         // - mMemorySize
00047         // - mLoadPerSecond
00048   {
00049 
00050         mVendor = "";
00051         mModel = "";
00052         mMemorySize = 0;
00053         mLoadPerSecond = 0.0;
00054 
00055   }
00056 
00057  /*----------------------------------------------------------------------*/
00058 
00059   GPU::~GPU()
00060   {
00061   }
00062 
00063  /*----------------------------------------------------------------------*/
00064 
00065   //
00066   // Class methods
00067   //
00068 
00069   GPU::Pointer GPU::parseXML(TiXmlElement * &tiGPU)
00070   {
00071 
00072         std::string gpuNamespace;
00073         std::string gpuName;
00074 
00075         std::string gpuTag(tiGPU->Value());
00076         std::string::size_type pos = gpuTag.find_first_of(":");
00077         if(pos != std::string::npos)
00078         {
00079          gpuNamespace = gpuTag.substr(0, pos);
00080          gpuName = gpuTag.substr(pos + 1);
00081         } else
00082         {
00083          gpuNamespace = "info";
00084          gpuName = "NoNameGPU";
00085         }
00086 
00087         OutputNode::NodeType nspace;
00088 
00089         if(gpuNamespace == "def")
00090          nspace = OutputNode::DEFINITION;
00091         else if(gpuNamespace == "info")
00092          nspace = OutputNode::INFORMATION;
00093         else if(gpuNamespace == "ref")
00094          nspace = OutputNode::REFERENCE;
00095         else if(gpuNamespace == "stat")
00096          nspace = OutputNode::STATISTICS;
00097 
00098         GPU::Pointer myGPU = GPU::Pointer(new GPU(gpuName, nspace));
00099 
00100         TiXmlElement *tiParam = tiGPU->FirstChildElement();
00101 
00102         for(; tiParam != NULL; tiParam = tiParam->NextSiblingElement())
00103         {
00104          std::string name(tiParam->Attribute("name"));
00105          std::string value(tiParam->Attribute("value"));
00106 
00107          //TODO: store GPU information
00108 
00109         }
00110 
00111         return GPU::Pointer(myGPU);
00112   }
00113 
00114  /*----------------------------------------------------------------------*/
00115 
00116   //
00117   // Methods
00118   //
00119 
00120   void GPU::refreshData()
00121   {
00122 
00123         XDisplay::Pointer display(new XDisplay(""));
00124 
00125         display->initialize();
00126 
00127         int num = ScreenCount(display->getDisplay());
00128 
00129         OutputNode::Pointer p = createChildNode("screen-number", OutputNode::INFORMATION);
00130 
00131         p->setAttribute("screen-number", StringConverter::toString(num));
00132 
00133   }
00134 
00135  /*----------------------------------------------------------------------*/
00136 
00137 }