Skip to content
Snippets Groups Projects
Commit 6962af71 authored by Chikuma Kato's avatar Chikuma Kato
Browse files

removing m_currentItem from MdtMapBase to make Map functions const

parent d52b480d
No related merge requests found
......@@ -57,7 +57,7 @@ template<class T> class MdtMapBase
bool addItem(uint8_t itemId, T* item);
/** get function - fast, used for online->offline conversion */
T* getItem(uint8_t itemId);
T* getItem(uint8_t itemId) const;
private:
......@@ -65,21 +65,21 @@ template<class T> class MdtMapBase
const std::string m_itemName;
/** pointer to the current item */
T* m_currentItem;
//T* m_currentItem;
/** map containing the items */
MapOfItems* m_mapOfItems;
/** private access function */
T* findItem(uint8_t itemId);
T* findItem(uint8_t itemId) const;
};
/** default constructor */
template<class T> MdtMapBase<T>::MdtMapBase(uint8_t moduleId, const std::string itemName) :
m_moduleId(moduleId), m_itemName(itemName), m_currentItem(NULL)
m_moduleId(moduleId), m_itemName(itemName)//, m_currentItem(NULL)
{
// m_mapOfItems = new std::map< uint8_t, T*, std::less<uint8_t> >();
m_mapOfItems = new MapOfItems();
......@@ -124,7 +124,7 @@ template<class T> void MdtMapBase<T>::clear()
}
m_mapOfItems->clear();
m_currentItem=NULL;
//m_currentItem=NULL;
}
/** Add an item to the map */
......@@ -160,8 +160,8 @@ template<class T> bool MdtMapBase<T>::addItem(uint8_t itemId, T* item) {
/** return the item for a given access key (onlineId) */
template<class T> T* MdtMapBase<T>::getItem(uint8_t itemId) {
template<class T> T* MdtMapBase<T>::getItem(uint8_t itemId) const{
/*
if ( m_currentItem ) {
if ( itemId == m_currentItem->moduleId() ) {
return m_currentItem;
......@@ -173,15 +173,16 @@ template<class T> T* MdtMapBase<T>::getItem(uint8_t itemId) {
else {
return findItem(itemId);
}
*/
return findItem(itemId);
}
/** find the item in the datamember map */
template<class T> T* MdtMapBase<T>::findItem(uint8_t itemId) {
template<class T> T* MdtMapBase<T>::findItem(uint8_t itemId) const{
typename MapOfItems::const_iterator it = m_mapOfItems->find(itemId);
/*
if (it!=m_mapOfItems->end()) {
m_currentItem = (*it).second;
}
......@@ -189,9 +190,14 @@ template<class T> T* MdtMapBase<T>::findItem(uint8_t itemId) {
// *m_log << MSG::ERROR << m_itemName << " with Id: " << MSG::hex << itemId
// << MSG::dec << " not found " << endmsg;
m_currentItem=NULL;
}
}
return m_currentItem;
*/
if (it!=m_mapOfItems->end()) {
return (*it).second;
} else {
return NULL;
}
}
......
......@@ -63,7 +63,7 @@ class MuonMDT_CablingMap : public MdtMapBase<MdtSubdetectorMap> {
int tdcId, int channelZero);
/** Get function */
MdtSubdetectorMap* getSubdetectorMap(uint8_t subdetectorId);
MdtSubdetectorMap* getSubdetectorMap(uint8_t subdetectorId) const;
/** return the ROD id of a given chamber, given station, eta, phi */
uint32_t getROBId(int station, int eta, int phi);
......@@ -84,7 +84,7 @@ class MuonMDT_CablingMap : public MdtMapBase<MdtSubdetectorMap> {
bool getOfflineId(uint8_t subdetectorId,uint8_t rodId,uint8_t csmId,
uint8_t tdcId,uint8_t channelId,
int& stationName, int& stationEta, int& stationPhi,
int& multiLayer, int& layer, int& tube);
int& multiLayer, int& layer, int& tube) const;
/** return the online id given the offline id */
bool getOnlineId(int stationName, int stationEta, int stationPhi,
......
......@@ -299,7 +299,7 @@ bool MuonMDT_CablingMap::addMezzanine( int mezType, int station, int eta, int ph
MdtSubdetectorMap* MuonMDT_CablingMap::getSubdetectorMap(uint8_t subdetectorId) {
MdtSubdetectorMap* MuonMDT_CablingMap::getSubdetectorMap(uint8_t subdetectorId) const{
return getItem(subdetectorId);
}
......@@ -475,7 +475,7 @@ bool MuonMDT_CablingMap::getOfflineId(uint8_t subdetectorId,
uint8_t tdcId,
uint8_t channelId,
int& stationName, int& stationEta, int& stationPhi,
int& multiLayer, int& layer, int& tube)
int& multiLayer, int& layer, int& tube) const
{
// get the subdetector
......
......@@ -152,17 +152,17 @@ bool MdtTestCabling::testMap()
int tube=0;
m_chronoSvc->chronoStart(m_chrono1);
/*
bool cabling = m_cablingSvc->getOfflineId(subdetectorId,rodId,csmId,
amtId,chanId,
station,eta,phi,multi,
layer,tube);
/*
*/
bool cabling = readCdo->getOfflineId(subdetectorId,rodId,csmId,
amtId,chanId,
station,eta,phi,multi,
layer,tube);
*/
m_chronoSvc->chronoStop(m_chrono1);
if (!cabling) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment