/home/aconway/svn/qpid/cpp/src/qpid/client/ResponseHandler.h

00001 /*
00002  *
00003  * Licensed to the Apache Software Foundation (ASF) under one
00004  * or more contributor license agreements.  See the NOTICE file
00005  * distributed with this work for additional information
00006  * regarding copyright ownership.  The ASF licenses this file
00007  * to you under the Apache License, Version 2.0 (the
00008  * "License"); you may not use this file except in compliance
00009  * with the License.  You may obtain a copy of the License at
00010  * 
00011  *   http://www.apache.org/licenses/LICENSE-2.0
00012  * 
00013  * Unless required by applicable law or agreed to in writing,
00014  * software distributed under the License is distributed on an
00015  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00016  * KIND, either express or implied.  See the License for the
00017  * specific language governing permissions and limitations
00018  * under the License.
00019  *
00020  */
00021 #include "qpid/shared_ptr.h"
00022 #include "qpid/sys/Monitor.h"
00023 
00024 #ifndef _ResponseHandler_
00025 #define _ResponseHandler_
00026 
00027 namespace qpid {
00028 
00029 namespace framing {
00030 class AMQMethodBody;
00031 }
00032 
00033 namespace client {
00034 
00038 class ResponseHandler{
00039     typedef shared_ptr<framing::AMQMethodBody> MethodPtr;
00040     bool waiting;
00041     bool shutdownFlag;
00042     MethodPtr response;
00043     sys::Monitor monitor;
00044 
00045   public:
00046     ResponseHandler();
00047     ~ResponseHandler();
00048 
00050     bool isWaiting();
00051 
00053     void signalResponse(MethodPtr response);
00054 
00056     void expect();
00057 
00059     MethodPtr receive();
00060 
00062     MethodPtr receive(framing::ClassId, framing::MethodId);
00063 
00065     template <class BodyType>
00066     shared_ptr<BodyType> receive() {
00067         return shared_polymorphic_downcast<BodyType>(
00068             receive(BodyType::CLASS_ID, BodyType::METHOD_ID));
00069     }
00070 };
00071 
00072 }}
00073 
00074 
00075 #endif

Generated on Tue Apr 17 14:22:03 2007 for Qpid by  doxygen 1.4.7