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

  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            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #include "ResponseHandler.h"
 35 chuck 1.5  #include "ResponseHandlerRep.h"
 36 kumpf 1.7  #include "InternalException.h"
 37            #include "HashTable.h"
 38 mike  1.15 #include "Mutex.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 w.otsuka 1.14     ResponseHandlerRep* rep = 0;
 79 kumpf    1.7      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 w.otsuka 1.14     ResponseHandlerRep* rep = 0;
 91 kumpf    1.7      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 kumpf    1.16 OperationContext ResponseHandler::getContext() const
127 chuck    1.5  {
128 kumpf    1.16     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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2