/[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 2965 - (hide annotations) (download)
Thu Jun 10 23:45:20 2004 UTC (15 years, 7 months ago) by derek
Original Path: main/sip/resiprocate/dum/Handle.hxx
File size: 1072 byte(s)
ClientInviteSession largely complete
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 derek 2965 static Handle<T> NotValid()
40     {
41     static Handle<T> notValid;
42     return notValid;
43     }
44    
45    
46 jason 2941 protected:
47     Handle(HandleManager& ham, Handled* handled) : mHam(&ham), mId(mHam->create(this))
48     {
49     }
50    
51 derek 2965 //for invalid handles
52     Handle() : mHam(0)
53     {
54     }
55    
56 jason 2941 private:
57     HandleManager* mHam;
58    
59     protected:
60     Handled::Id mId;
61    
62     friend class Handled;
63     };
64    
65     }
66    
67     #endif

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27