190 likes | 284 Views
Proxy Mechanism of BESF. Zhangxy Huangxt Dec 17 ,2003. Content. Introduction. Implementation. Processing. Example. Summary. Introduction. Proxy is another way of data management system in our BesIII framework(BESF), learned from B A B AR .
E N D
Proxy Mechanism of BESF ZhangxyHuangxt Dec 17 ,2003
Content • Introduction. • Implementation. • Processing. • Example. • Summary
Introduction • Proxy is another way of data management system in our • BesIII framework(BESF), learned from BABAR. • The separation of Transient Event and Persistent Event is • commonly used in other frameworks. • If the object associated with the Transient Event exists, Clients can get it directly from proxy.
Introduction • If the object does’t exist, Proxy can create and then return it to Clients by calling its member function : virtual T* faultHandler ( IfdProxyDict *, const IfdKey & ); • Proxy can put and get objects from the Transient Event in a type_safe fashion by virtue of template , hash table and wrap mechanism.
Implementation • Transient Object • Proxy Interface • Proxy Dictionary • Keys • Accessor
Implementation • Transient Object • Single instance • The class must inherit from BesDataObject. • Multi-instances • The class must inherit from BesContainedObject. m_parent BesObjectContainedBase BesObjectList<T> BesObjectVector<T>
Implementation • Proxy Interface • Single object proxy T *ifdl = new T; IfdDataProxy<T> *proxy = new IfdDataProxy<T>( ifdl );
Implementation • List object proxy BesObjectList<T> *ifdl = new BesObjectList<T>; BesObjectListProxy<T> *proxy = new BesObjectListProxy<T>( ifdl );
Implementation • Above action has been done automatically by • BesEvent member function.Clients only need to • define the argument of the template functions. bool put( const IfdDictKey* key, IfdProxyIFace* proxy); template<class T> void GetObjList (BesObjectVector< T > *&list); template<class T> void GetObjList (BesObjectVector< T > *&list, const IfdKey &k); template<class T> void GetObjList (BesObjectList< T > *&list); template<class T> void GetObjList (BesObjectList< T > *&list, const IfdKey &k); template<class T> void GetObj (T *&obj); template<class T> void GetObj (T *&obj, const IfdKey &k); void clear();
Implementation • Proxy Dictionary • The transient event store is implemented with Proxy Dictionary. • The Proxy Dictionary is implemented with a hash table and singly linked list. 1031
Implementation • Access “object” from Dictionary • according to the hash value or • recursive comparison. • The hash value is given by the keys • BesEvent is a instance of the Dictionary.
Implementation • Keys • In order to select the wanted object when • multiple instances of objects from the same • class “stored” in BesEvent or Proxy Dictionary. • Collision • Composite Key + Move Bit + Mod()
The integer keys and string keys are interested for • clients, while other keys are used automatically.
Implementation • Accessor • Ifd<T> class provides only and • type-safe access to the objects or • lists within BesEvent. • Identified by a key or characters to differentiate • them from other instances of the same class.
Processing BesEventHeader* header = new BesaEventHeader(); first typekey proxy IfdDataProxy<BesEventHeader> *proxy = new IfdDataProxy<BesEventHeader>( header ); dictkey true Find() false next put
Processing 1. Get the object from Transient event identified with string. T* Ifd<T>::Get(IfdProxyDict * Dict, const char* str) 2. Create valid Key. IfdstrKey k(str); 3. Call another member funtion. T* Ifd<T>::Get(IfdProxyDict* Dict, const IfdKey &K); 4. Create TypeKey and composite Key,that’s , Dictionary Key. static IfdTypeKey<Ifd<T> > tk; static IfdDictKey* dictkey=IfdProxyDictFrontEnd::newDictKey( tk); dictKey -> add( K); 5. Get the object according dictkey. (T*) Dict -> get( dictKey ) 6. Find the Proxy IfdProxyIface *p = Dict -> find( dictkey);
Processing 7. Find the ProxyEntry. IfdSimpleProxyDictEntry *e = Dict -> findEntry( dictkey ); 8. Recursive Comparison. IfSimpleProxyDictEntry* e = _myData[dictkey._hashVal]; if ( 0==e) { return 0;} else if ( *e->key == dictkey ) { return e; } else while ( 0 != (e=e->next ) ) { if (*e->key == k) { return e;} } 9 Return object wanted return p->_myt; return T* t=p->defaulthandler(Dict, dictKey);
Example • BESF makes the transient event available to BesMoudles • as an argument to the following member function: • virtual BesStatusExecute ( BesEvent *evt, Int_t *status) • virtual void event ( BesEvent *evt, Int_t *status) • Clients can conveniently get objects from BesEvent. void NDSTunpackModule::event ( BesEvent * anEvent, int * status ) { NDSTtrack * aTrack ; NDSTEventHeader *eventPtr ; BesObjectVector<NDSTtrack>* trklist; anEvent->GetObjList( trklist ); anEvent->GetObj( eventPtr ); …… }
Summary • Simple and type safe. • Easier to use than others.