1 #ifndef INSTMGRHELPER_H 2 #define INSTMGRHELPER_H 3 4 #include <lazyInstMgr.h> 5 #include <instmgr.h> 6 7 /** 8 * \file instMgrHelper.h helper classes for the lazyInstMgr. Allows use of SDAI_Application_instance class 9 * without modification. 10 */ 11 12 13 /** 14 * This class is used when creating SDAI_Application_instance's and using a lazyInstMgr. It is returned 15 * by instMgrAdapter. SDAI_Application_instance only uses the GetSTEPentity function. 16 */ 17 class mgrNodeHelper: public MgrNodeBase { 18 protected: 19 lazyInstMgr * _lim; 20 instanceID _id; 21 public: mgrNodeHelper(lazyInstMgr * lim)22 mgrNodeHelper( lazyInstMgr * lim ) { 23 _lim = lim; 24 _id = 0; 25 prev = next = 0; 26 } setInstance(instanceID id)27 inline void setInstance( instanceID id ) { 28 _id = id; 29 } GetSTEPentity()30 inline SDAI_Application_instance * GetSTEPentity() { 31 return _lim->loadInstance( _id, true ); 32 } 33 }; 34 35 36 /** 37 * This class is used when creating SDAI_Application_instance's and using a lazyInstMgr. 38 * 39 * Instances need an InstMgr to look up the instances they refer to. This class pretends to be a normal InstMgr; 40 * when an instance is looked up, this uses lazyInstMgr to load it, and then returns a pointer to it. 41 */ 42 43 class instMgrAdapter: public InstMgrBase { 44 protected: 45 mgrNodeHelper _mn; 46 public: instMgrAdapter(lazyInstMgr * lim)47 instMgrAdapter( lazyInstMgr * lim ): InstMgrBase(), _mn( lim ) {} 48 FindFileId(int fileId)49 inline mgrNodeHelper * FindFileId( int fileId ) { 50 //TODO check if fileId exists. if not, return null 51 _mn.setInstance( fileId ); 52 return &_mn; 53 } 54 }; 55 56 57 #endif //INSTMGRHELPER_H 58 59