00001 #ifndef MODULEDEFECTIOHELPER_H
00002 #define MODULEDEFECTIOHELPER_H
00003
00004 #include "ModuleDefect.h"
00005 #include "Sct/LogicErrors.h"
00006
00007 namespace SctData {
00008 class ModuleDefectIOHelper {
00009 public:
00010 int getRepresentation(const ModuleDefect& defect) const throw();
00011 const ModuleDefect& getFromRep(int id) const throw(Sct::LogicError);
00012 };
00013
00014
00015 inline int ModuleDefectIOHelper::getRepresentation(const ModuleDefect& defect) const throw() {
00016 return defect.id;
00017 }
00018
00019 inline const ModuleDefect& ModuleDefectIOHelper::getFromRep(int id) const throw(Sct::LogicError) {
00020 if (ModuleDefect::defectMap.find(id)==ModuleDefect::defectMap.end() ){
00021 ostringstream os; os<<"ModuleDefectIOHelper::getFromRep : no representation "<<id;
00022 throw Sct::InvariantViolatedError(os.str(), __FILE__, __LINE__);
00023 }
00024 return *ModuleDefect::defectMap[id];
00025 }
00026
00027 }
00028 #endif //#ifndef MODULEDEFECTIOHELPER_H