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

  1 martin 1.56 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.57 //
  3 martin 1.56 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.57 //
 10 martin 1.56 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.57 //
 17 martin 1.56 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.57 //
 20 martin 1.56 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.57 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.56 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.57 //
 28 martin 1.56 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_AsyncOpNode_h
 33             #define Pegasus_AsyncOpNode_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36 kumpf  1.50 #include <Pegasus/Common/Linkage.h>
 37             #include <Pegasus/Common/Linkable.h>
 38             #include <Pegasus/Common/AutoPtr.h>
 39 mike   1.2  #include <Pegasus/Common/Message.h>
 40 kumpf  1.52 #include <Pegasus/Common/MessageQueue.h>
 41 kumpf  1.50 #include <Pegasus/Common/Thread.h>
 42 mike   1.2  
 43             PEGASUS_NAMESPACE_BEGIN
 44 mike   1.5  
 45 mike   1.2  #define ASYNC_OPFLAGS_UNKNOWN           0x00000000
 46 venkat.puvvada 1.54 #define ASYNC_OPFLAGS_FIRE_AND_FORGET   0x00000001
 47                     #define ASYNC_OPFLAGS_CALLBACK          0x00000002
 48                     #define ASYNC_OPFLAGS_PSEUDO_CALLBACK   0x00000004
 49 mike           1.2  
 50                     #define ASYNC_OPSTATE_UNKNOWN           0x00000000
 51 venkat.puvvada 1.54 #define ASYNC_OPSTATE_COMPLETE          0x00000001
 52 mike           1.2  
 53 mike           1.48 class PEGASUS_COMMON_LINKAGE AsyncOpNode : public Linkable
 54 mike           1.2  {
 55 kumpf          1.50 public:
 56                     
 57                         AsyncOpNode();
 58                         ~AsyncOpNode();
 59 mday           1.26 
 60 kumpf          1.50     void setRequest(Message* request);
 61                         Message* getRequest();
 62                         Message* removeRequest();
 63                     
 64                         void setResponse(Message* response);
 65                         Message* getResponse();
 66                         Message* removeResponse();
 67 venkat.puvvada 1.54     void complete();
 68 kumpf          1.50     Uint32 getState();
 69                     private:
 70                         AsyncOpNode(const AsyncOpNode&);
 71                         AsyncOpNode& operator=(const AsyncOpNode&);
 72                     
 73                         Semaphore _client_sem;
 74                         AutoPtr<Message> _request;
 75                         AutoPtr<Message> _response;
 76                     
 77                         Uint32 _state;
 78                         Uint32 _flags;
 79                         MessageQueue *_op_dest;
 80                     
 81                         void (*_async_callback)(AsyncOpNode *, MessageQueue *, void *);
 82                     
 83                         // pointers for async callbacks  - don't use
 84                         AsyncOpNode *_callback_node;
 85                         MessageQueue *_callback_response_q;
 86                         void *_callback_ptr;
 87                     
 88                         friend class cimom;
 89 kumpf          1.50     friend class MessageQueueService;
 90                         friend class ProviderManagerService;
 91 mike           1.2  };
 92                     
 93                     
 94 kumpf          1.50 inline void AsyncOpNode::setRequest(Message* request)
 95 mike           1.2  {
 96 kumpf          1.50     PEGASUS_ASSERT(_request.get() == 0);
 97                         PEGASUS_ASSERT(request != 0);
 98                         _request.reset(request);
 99 mike           1.2  }
100                     
101 kumpf          1.50 inline Message* AsyncOpNode::getRequest()
102 mike           1.2  {
103 kumpf          1.50     PEGASUS_ASSERT(_request.get() != 0);
104                         return _request.get();
105 mike           1.2  }
106                     
107 kumpf          1.50 inline Message* AsyncOpNode::removeRequest()
108 mike           1.2  {
109 kumpf          1.50     PEGASUS_ASSERT(_request.get() != 0);
110                         Message* request = _request.get();
111                         _request.release();
112                         return request;
113 mike           1.2  }
114                     
115 kumpf          1.50 inline void AsyncOpNode::setResponse(Message* response)
116 mike           1.2  {
117 kumpf          1.50     PEGASUS_ASSERT(_response.get() == 0);
118                         PEGASUS_ASSERT(response != 0);
119                         _response.reset(response);
120 mike           1.2  }
121                     
122 kumpf          1.50 inline Message* AsyncOpNode::getResponse()
123 mike           1.2  {
124 kumpf          1.50     PEGASUS_ASSERT(_response.get() != 0);
125                         return _response.get();
126 mike           1.2  }
127                     
128 kumpf          1.50 inline Message* AsyncOpNode::removeResponse()
129 mike           1.2  {
130 kumpf          1.50     PEGASUS_ASSERT(_response.get() != 0);
131                         Message* response = _response.get();
132                         _response.release();
133                         return response;
134 mike           1.2  }
135                     
136 kumpf          1.50 inline void AsyncOpNode::complete()
137 mike           1.2  {
138 venkat.puvvada 1.54     _state = ASYNC_OPSTATE_COMPLETE;
139 mike           1.2  }
140 chip           1.30 
141 venkat.puvvada 1.54 inline Uint32 AsyncOpNode::getState()
142 mike           1.2  {
143 venkat.puvvada 1.54     return _state;
144 chip           1.30 }
145 mike           1.2  
146                     PEGASUS_NAMESPACE_END
147                     
148                     #endif //Pegasus_AsyncOpNode_h

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2