Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

TestResult.cpp

00001 #include "TestResult.h"
00002 #include "FitScanResult.h"
00003 #include "RawScanResult.h"
00004 #include "ConfigurationVariable.h"
00005 #include "NullVariable.h"
00006 #include "UniqueID.h"
00007 #include "Sct/SctNames.h"
00008 #include "Sct/IS/IOManagerIS.h"
00009 #include "Sct/IS/IONameIS.h"
00010 #include <algorithm>
00011 #include <sstream>
00012 
00013 using namespace std;
00014 using namespace Sct;
00015 using namespace Sct::IS;
00016 using namespace boost;
00017 
00018 namespace SctData {
00019 
00020 TestResult::TestResult(const unsigned int runNumber, const string & moduleName,
00021                const ConfigurationVariable& testVariable, const ConfigurationVariable& scanVariable) throw ()
00022                        : header(0, runNumber, moduleName, scanVariable), testVariable(&testVariable),
00023                passed(false), problem(false) {
00024 }
00025 
00026 
00027 TestResult::TestResult() throw() : testVariable(&NullVariable::instance()),
00028     passed(false), problem(false) {
00029 }
00030 
00031 const ResultHeader& TestResult::getHeader() const {
00032     return header;
00033 }
00034     
00035 ResultHeader& TestResult::getHeader() {
00036     return header;
00037 }
00038 
00039 unsigned int TestResult::getRunNumber() const throw() {
00040     return getHeader().getRunNumber();
00041 }
00042 
00043 void TestResult::setRunNumber(unsigned int runNumber) throw() {
00044     getHeader().setRunNumber(runNumber);
00045 }
00046 
00047 string TestResult::getModuleName() const throw() {
00048     return getHeader().getModuleName();
00049 }
00050 
00051 void TestResult::setModuleName(string name) throw() {
00052     getHeader().setModuleName(name);
00053 }
00054 
00055 const DefectList& TestResult::getDefects() const throw() {
00056     return defects;
00057 }
00058 
00059 DefectList& TestResult::getDefects() throw() {
00060     return defects;
00061 }
00062 
00063 const ConfigurationVariable& TestResult::getScanVariable() const throw() {
00064     return getHeader().getVariable();
00065 }
00066 
00067 void TestResult::setScanVariable(const ConfigurationVariable& scanVariable) throw() {
00068     getHeader().setVariable(scanVariable);
00069 }
00070 
00071 const ConfigurationVariable& TestResult::getTestVariable() const throw() {
00072     return *testVariable;
00073 }
00074 
00075 void TestResult::setTestVariable(const ConfigurationVariable& testVariable) throw() {
00076     this->testVariable = &testVariable;
00077 }
00078 
00079 bool TestResult::getPassed() const throw() {
00080     return passed;
00081 }
00082 
00083 void TestResult::setPassed(bool passed) throw() {
00084     this->passed = passed;
00085 }
00086 
00087 bool TestResult::getProblem() const throw() {
00088     return problem;
00089 }
00090 
00091 void TestResult::setProblem(bool problem) throw() {
00092     this->problem = problem;
00093 }
00094 
00095 vector<string> TestResult::getComments() const throw() {
00096     return comments;
00097 }
00098 
00099 void TestResult::addComment(string comment) throw() {
00100     comments.push_back(comment);
00101 }
00102 
00103 void TestResult::addScan(const unsigned int scanNumber, const double testPoint) throw(LogicError) {
00104     if (data.size() == 0) {
00105     getHeader().setScanNumber(scanNumber);
00106     }
00107     data.push_back(ScanData(scanNumber, testPoint));
00108     sort(data.begin(), data.end());
00109 }
00110 
00111 string TestResult::getUniqueID() const throw(LogicError) {
00112     if (data.size() > 0) {
00113         return getHeader().getUniqueID();
00114     }
00115     throw IllegalStateError("TestResult::getUniqueID() : empty test result", __FILE__, __LINE__);
00116 }
00117 
00118 unsigned TestResult::getScanNumberAt(unsigned int i) const throw(LogicError) {
00119     if ( i>=data.size() )
00120         throw OutOfRangeError<unsigned>("TestPoint::getScanNumberAt", __FILE__, __LINE__,i,0,data.size()-1);
00121     return data[i].scanNumber;
00122 }
00123 
00124 double TestResult::getTestPointAt(unsigned int i) const throw(LogicError) {
00125     if ( i>=data.size() )
00126         throw OutOfRangeError<unsigned>("TestPoint::getTestPointAt", __FILE__, __LINE__,i,0,data.size()-1);
00127     return data[i].testPoint;
00128 }
00129 
00130 unsigned int TestResult::getIndex(unsigned int scanNumber) const throw(LogicError) {
00131     vector<ScanData>::const_iterator i=find(data.begin(), data.end(), scanNumber);
00132     if (i==data.end() ) {
00133         ostringstream text;
00134         text << "TestResult::findScanData scan not found scanNumber="<< scanNumber;
00135         throw InvalidArgumentError( text.str(), __FILE__, __LINE__ );
00136     }
00137     return i-data.begin();
00138 }
00139 
00141 TestResult::ScanData::ScanData(const unsigned int scanNumber, const double testPoint) throw()
00142         : scanNumber(scanNumber), testPoint(testPoint) {}
00143 
00144 bool TestResult::ScanData::operator<(const ScanData& s) const throw() {
00145     if (this->scanNumber<s.scanNumber)
00146         return true;
00147     return false;
00148 }
00149 
00150 bool TestResult::ScanData::operator>(const ScanData& s) const throw() {
00151     if (this->scanNumber>s.scanNumber)
00152         return true;
00153     return false;
00154 }
00155 
00156 bool TestResult::ScanData::operator==(const unsigned int aScanNumber) const throw() {
00157     if (this->scanNumber==aScanNumber)
00158         return true;
00159     return false;
00160 }
00161 
00162 void  TestResult::setDcsData(boost::shared_ptr<const DcsData> data){
00163   m_dcsData = data;
00164 }
00165 
00166 boost::shared_ptr<const DcsData> TestResult::getDcsData() const {
00167   return m_dcsData;
00168 }
00169 
00170 }

Generated on Thu Jul 15 09:51:00 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5