ConfigurationVariable.cpp

00001 #include "ConfigurationVariable.h"
00002 #include "DefaultVariable.h"
00003 #include "Sct/SctParameters.h"
00004 
00005 namespace SctData {
00006 
00007 ConfigurationVariable::ConfigurationVariable(unsigned int typeVal, string variableName, string strategyDescription) : typeVal(typeVal), variableName(variableName), strategyDescription(strategyDescription) {
00008     getMap()[typeVal] = shared_ptr<ConfigurationVariable>(this);
00009 }
00010 
00011 map<unsigned short, shared_ptr<ConfigurationVariable> >& ConfigurationVariable::getMap() throw() {
00012     static VariableTypeMap* map = new VariableTypeMap();
00013     return *map;
00014 }
00015 
00016 bool ConfigurationVariable::operator== (const ConfigurationVariable& var) const throw() {
00017     return typeVal == var.typeVal;
00018 }
00019 
00020 bool ConfigurationVariable::operator!= (const ConfigurationVariable& var) const throw() {
00021     return typeVal != var.typeVal;
00022 }
00023 
00024 string ConfigurationVariable::getClassName() const throw() {
00025     return "SctData::ConfigurationVariable";
00026 }
00027     
00028 string ConfigurationVariable::getVariableName() const throw() {
00029     return variableName;
00030 }
00031 
00032 string ConfigurationVariable::getStrategyDescription() const throw() {
00033     return strategyDescription;
00034 }
00035 
00036 double ConfigurationVariable::getChipLogicalPoint(const ModuleConfiguration& config, unsigned int chip) const throw() {
00037     return getChipLogicalPoint(getChipActualPoint(config, chip), config, chip);
00038 }
00039 
00040 void ConfigurationVariable::setChipLogicalPoint(double logicalPt, ModuleConfiguration& config, unsigned int chip) const throw() {
00041     setChipActualPoint(getChipActualPoint(logicalPt, config, chip), config, chip);
00042 }
00043 
00044 double ConfigurationVariable::getModuleLogicalPoint(const ModuleConfiguration& config) const throw() {
00045     return getChipLogicalPoint(config, 0);
00046 }
00047 
00048 void ConfigurationVariable::setModuleLogicalPoint(double logicalPt, ModuleConfiguration& config) const throw() {
00049     for (unsigned int i=0; i<Sct::nChipModule; ++i) {
00050     setChipLogicalPoint(logicalPt, config, i);
00051     }
00052 }
00053 
00054 unsigned short ConfigurationVariableIOHelper::getTypeRep(const ConfigurationVariable& var) throw(){
00055     return var.typeVal;
00056 }
00057 
00058 shared_ptr<ConfigurationVariable> ConfigurationVariableIOHelper::getFromTypeRep(unsigned short typeRep) throw() {
00059     if (ConfigurationVariable::getMap().count(typeRep) == 0) {
00060     //Create a DefaultVariable instead (will be automagically added to the map)
00061     new DefaultVariable(typeRep);
00062     }
00063     return ConfigurationVariable::getMap()[typeRep];
00064 }
00065     
00066 }

Generated on Mon Feb 6 14:01:18 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6