(file) Return to ResponseHandler.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2