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