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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2983 - (show annotations) (download)
Sun Jun 13 04:52:56 2004 UTC (15 years, 7 months ago) by derek
Original Path: main/sip/resiprocate/dum/Handle.hxx
File size: 1073 byte(s)
many issues found as a result of the basic call test almost working
1 #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 Handle() : mHam(0)
19 {
20 }
21
22 bool isValid() const
23 {
24 return mHam->isValidHandle(mId);
25 }
26
27 // throws if not found
28 T* get()
29 {
30 return static_cast<T*>(mHam->getHandled(mId));
31 }
32
33 T* operator->()
34 {
35 return get();
36 }
37
38 Handled::Id getId() const
39 {
40 return mId;
41 }
42
43 static Handle<T> NotValid()
44 {
45 static Handle<T> notValid;
46 return notValid;
47 }
48
49
50 protected:
51 Handle(HandleManager& ham, Handled* handled) : mHam(&ham), mId(mHam->create(this))
52 {
53 }
54
55 //for invalid handles
56
57 private:
58 HandleManager* mHam;
59
60 protected:
61 Handled::Id mId;
62
63 friend class Handled;
64 };
65
66 }
67
68 #endif

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27