在documentToBeActivated函数下添加监视器的话,会不会有重复添加的可能?这样改后是不是好些
- [FONT=courier new]
- template <class T> class AsdkDataManager : public AcApDocManagerReactor
- {
- public:
- AsdkDataManager()
- {
- acDocManager->addReactor(this);
- this->m_pIPM = new CFengyuanIPM();
- AcApDocumentIterator *docIter;
- docIter = acDocManager->newAcApDocumentIterator();
- while(!docIter->done())
- {
- AcApDocument* pDoc = docIter->document();
- if(pDoc->inputPointManager())
- {
- pDoc->inputPointManager()->addPointMonitor(m_pIPM);
- }
- docIter->step();
- }
- delete docIter;
- }
-
- ~AsdkDataManager()
- {
- acDocManager->removeReactor(this);
- AcApDocumentIterator *docIter;
- docIter = acDocManager->newAcApDocumentIterator();
- while(!docIter->done())
- {
- AcApDocument* pDoc = docIter->document();
- if(pDoc->inputPointManager())
- {
- pDoc->inputPointManager()->removePointMonitor(m_pIPM);
- }
- docIter->step();
- }
- delete docIter;
- delete m_pIPM;
- }
- virtual void documentCreated(AcApDocument* pDoc)
- {
- if(pDoc->inputPointManager())
- {
- pDoc->inputPointManager()->addPointMonitor(m_pIPM);
- }
- }
- virtual void documentToBeDestroyed( AcApDocument *pDoc )
- {
- // 移除输入点监视器
- if (pDoc)
- {
- if(pDoc->inputPointManager())
- {
- pDoc->inputPointManager()->removePointMonitor(m_pIPM);
- }
- }
- m_dataMap.erase(pDoc);
- }
-
- T& docData(AcApDocument* pDoc)
- {
- std::map<AcApDocument*, T>::iterator i;
- i = m_dataMap.find(pDoc);
- if (i==m_dataMap.end())
- return m_dataMap[ pDoc ];
- else
- return (*i).second;
- }
- T& docData()
- {
- return docData(acDocManager->curDocument());
- }
-
- private:
- std::map<AcApDocument*, T> m_dataMap;
- CFengyuanIPM* m_pIPM;
- }; [/FONT]
|