1 karl 1.11 //%2004////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.11 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.9 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.11 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 mike 1.2 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
11 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 kumpf 1.4 //
|
17 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
20 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Chip Vincent (cvincent@us.ibm.com)
29 //
|
30 kumpf 1.7 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
31 mike 1.2 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include "ResponseHandler.h"
|
35 chuck 1.5 #include "ResponseHandlerRep.h"
|
36 kumpf 1.7 #include "InternalException.h"
37 #include "HashTable.h"
38 #include "IPC.h"
|
39 mike 1.2
40 PEGASUS_NAMESPACE_BEGIN
|
41 kumpf 1.4
|
42 kumpf 1.7 PEGASUS_TEMPLATE_SPECIALIZATION struct HashFunc<void*>
43 {
|
44 kumpf 1.8 static Uint32 hash(void* x) { return Uint32((unsigned long)x) + 13; }
|
45 kumpf 1.7 };
46
47 typedef HashTable<ResponseHandler*, ResponseHandlerRep*,
48 EqualFunc<void*>,
49 HashFunc<void*> > RepTable;
50
51 static RepTable repTable(512);
52 static Mutex repTableMutex;
53
54 ResponseHandlerRep* _newRep(
55 ResponseHandler* object)
56 {
57 ResponseHandlerRep* newRep = new ResponseHandlerRep();
58
|
59 kumpf 1.10 AutoMutex lock(repTableMutex);
|
60 kumpf 1.7 repTable.insert(object, newRep);
61 return newRep;
62 }
63
64 ResponseHandlerRep* _newRep(
65 ResponseHandler* object,
66 const ResponseHandlerRep* rep)
67 {
68 ResponseHandlerRep* newRep = new ResponseHandlerRep(*rep);
69
|
70 kumpf 1.10 AutoMutex lock(repTableMutex);
|
71 kumpf 1.7 repTable.insert(object, newRep);
72 return newRep;
73 }
74
75 ResponseHandlerRep* _getRep(
76 const ResponseHandler* object)
77 {
78 ResponseHandlerRep* rep;
79 Boolean found;
80
|
81 kumpf 1.10 AutoMutex lock(repTableMutex);
|
82 kumpf 1.7 found = repTable.lookup(const_cast<ResponseHandler*>(object), rep);
83 PEGASUS_ASSERT(found == true);
84 return rep;
85 }
86
87 void _deleteRep(
88 ResponseHandler* object)
89 {
90 ResponseHandlerRep* rep;
91 Boolean found;
92
|
93 kumpf 1.10 AutoMutex lock(repTableMutex);
|
94 kumpf 1.7 found = repTable.lookup(object, rep);
95 PEGASUS_ASSERT(found == true);
96 delete rep;
97 repTable.remove(object);
98 }
99
100
|
101 chuck 1.5 ResponseHandler::ResponseHandler()
102 {
|
103 kumpf 1.7 _newRep(this);
|
104 chuck 1.5 }
105
|
106 kumpf 1.6 ResponseHandler::ResponseHandler(const ResponseHandler& handler)
107 {
|
108 kumpf 1.7 _newRep(this, _getRep(&handler));
|
109 kumpf 1.6 }
110
111 ResponseHandler& ResponseHandler::operator=(const ResponseHandler& handler)
112 {
|
113 kumpf 1.7 if (&handler != this)
|
114 kumpf 1.6 {
|
115 kumpf 1.7 _deleteRep(this);
116 _newRep(this, _getRep(&handler));
|
117 kumpf 1.6 }
118 return *this;
119 }
120
|
121 kumpf 1.4 ResponseHandler::~ResponseHandler()
122 {
|
123 kumpf 1.7 _deleteRep(this);
|
124 chuck 1.5 }
125
126 OperationContext ResponseHandler::getContext(void) const
127 {
|
128 kumpf 1.7 return(_getRep(this)->getContext());
|
129 chuck 1.5 }
130
131 void ResponseHandler::setContext(const OperationContext & context)
132 {
|
133 kumpf 1.7 _getRep(this)->setContext(context);
|
134 kumpf 1.4 }
|
135 mike 1.2
136 PEGASUS_NAMESPACE_END
|