#include "StdAfx.h" #include "MBTNXXXObjMgr.h" CMBTNXXXObjMgr::CMBTNXXXObjMgr(void) { RemoveAllObj(); m_nRecords = 0; m_nTotalPages = 0; m_nCurPage = 0; m_nPageSize = 0; } CMBTNXXXObjMgr::~CMBTNXXXObjMgr(void) { RemoveAllObj(); } void CMBTNXXXObjMgr::GetObjMap( CMBTNXXXObjMap &mapObj) { mapObj.clear(); mapObj = m_mapObj; } // µÃµ½vector void CMBTNXXXObjMgr::GetObjVector( CMBTNXXXObjVector &vectorObj) { vectorObj.clear(); vectorObj = m_vectorObj; } CMBTNXXXObj *CMBTNXXXObjMgr::GetObjLastVerByFilter( CString strFilter,CString strFilterValue ) { CMBTNXXXObj *pRetTNXXXObj = NULL; CString strVer,strTmpVer; CMBTNXXXObjMap mapObj; CMBTNXXXObjMap::iterator it1; CMBTNXXXObj *pObj = NULL; //CMBTNXXXAttrMap::iterator it2; //CMBTNXXXAttr *pAttr = NULL; CMBTNXXXAttrMap mapAttr; for( it1 = m_mapObj.begin();it1 != m_mapObj.end();it1++ ) { pObj = it1->second; pObj->GetAttrMap( mapAttr); // ¹ýÂË if( !strFilter.IsEmpty() && !strFilterValue.IsEmpty() ) { CMBTNXXXAttr *pTn3XAttr = pObj->GetAttr(strFilter); if( NULL != pTn3XAttr ) { if(pTn3XAttr->m_strValue != strFilterValue) { continue; } } } CMBTNXXXAttr *pVerTn3XAttr = pObj->GetAttr(_T("S_VER")); if( NULL != pVerTn3XAttr ) { strTmpVer = pVerTn3XAttr->m_strValue; strTmpVer = strTmpVer.MakeLower(); if(strVer < strTmpVer ) { strVer = strTmpVer; pRetTNXXXObj = pObj; } } } // end for( it1 = m_mapObj.begin();it1 != m_mapObj.end();it1++ ) return pRetTNXXXObj; } CMBTNXXXObj *CMBTNXXXObjMgr::GetObj( CString strObjID ) { if( strObjID.IsEmpty() ) return NULL; CMBTNXXXObjMap::iterator it; CMBTNXXXObj *pObj = NULL; it = m_mapObj.find(strObjID); if( it!= m_mapObj.end() ) pObj = it->second; return pObj; } bool CMBTNXXXObjMgr::AddObj( CMBTNXXXObj *pObj ) { if( NULL == pObj || pObj->m_strObjID.IsEmpty() ) return false; CMBTNXXXObjMap::iterator it; CString strObjID; strObjID = pObj->m_strObjID; it = m_mapObj.find(strObjID); // Èç¹ûÕҵõ½ ·µ»Ø if( it != m_mapObj.end() ) return false; m_mapObj[strObjID] = pObj; m_vectorObj.push_back(pObj); return true; } bool CMBTNXXXObjMgr::RemoveAllObj() { CMBTNXXXObjMap::iterator it; CMBTNXXXObj *pObj = NULL; for( it = m_mapObj.begin();it != m_mapObj.end();it++ ) { pObj = it->second; delete pObj; pObj = NULL; } m_vectorObj.clear(); m_mapObj.clear(); return true; } //
//