/[resiprocate]/branches/b-identity-0505/dum/Handle.hxx
ViewVC logotype

Annotation of /branches/b-identity-0505/dum/Handle.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2941 - (hide annotations) (download)
Mon Jun 7 00:44:01 2004 UTC (15 years, 7 months ago) by jason
Original Path: main/sip/resiprocate/dum/Handle.hxx
File size: 882 byte(s)
refactored Handle code
streamlined header includes

1 jason 2941 #if !defined(RESIP_HANDLE_HXX)
2     #define RESIP_HANDLE_HXX
3    
4     #include "resiprocate/dum/Handled.hxx"
5     #include "resiprocate/dum/HandleManager.hxx"
6    
7     namespace resip
8     {
9    
10     template <class T>
11     class Handle
12     {
13     public:
14     Handle(HandleManager& ham, Handled::Id id) : mHam(&ham), mId(id)
15     {
16     }
17    
18     bool isValid() const
19     {
20     return mHam->isValidHandle(mId);
21     }
22    
23     // throws if not found
24     T* get()
25     {
26     return static_cast<T*>(mHam->getHandled(mId));
27     }
28    
29     T* operator->()
30     {
31     return get();
32     }
33    
34     Handled::Id getId() const
35     {
36     return mId;
37     }
38    
39     protected:
40     Handle(HandleManager& ham, Handled* handled) : mHam(&ham), mId(mHam->create(this))
41     {
42     }
43    
44     private:
45     HandleManager* mHam;
46    
47     protected:
48     Handled::Id mId;
49    
50     friend class Handled;
51     };
52    
53     }
54    
55     #endif

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27