/[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 3006 - (hide annotations) (download)
Sat Jun 19 01:10:02 2004 UTC (15 years, 7 months ago) by derek
Original Path: main/sip/resiprocate/dum/Handle.hxx
File size: 1180 byte(s)
small data structure fixes, end work sin accepting state
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 derek 2983 Handle() : mHam(0)
19     {
20     }
21    
22 jason 2941 bool isValid() const
23     {
24 derek 3006 if (!mHam)
25     {
26     return false;
27     }
28     else
29     {
30     return mHam->isValidHandle(mId);
31     }
32 jason 2941 }
33    
34     // throws if not found
35     T* get()
36     {
37     return static_cast<T*>(mHam->getHandled(mId));
38     }
39    
40     T* operator->()
41     {
42     return get();
43     }
44    
45     Handled::Id getId() const
46     {
47     return mId;
48     }
49    
50 derek 2965 static Handle<T> NotValid()
51     {
52     static Handle<T> notValid;
53     return notValid;
54     }
55    
56    
57 jason 2941 protected:
58     Handle(HandleManager& ham, Handled* handled) : mHam(&ham), mId(mHam->create(this))
59     {
60     }
61    
62 derek 2965 //for invalid handles
63    
64 jason 2941 private:
65     HandleManager* mHam;
66    
67     protected:
68     Handled::Id mId;
69    
70     friend class Handled;
71     };
72    
73     }
74    
75     #endif

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27