Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
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 00022 #ifndef _Future_ 00023 #define _Future_ 00024 00025 #include <boost/bind.hpp> 00026 #include <boost/shared_ptr.hpp> 00027 #include "qpid/Exception.h" 00028 #include "qpid/framing/SequenceNumber.h" 00029 #include "qpid/framing/StructHelper.h" 00030 #include "FutureCompletion.h" 00031 #include "FutureResult.h" 00032 #include "SessionImpl.h" 00033 #include "ClientImportExport.h" 00034 00035 namespace qpid { 00036 namespace client { 00037 00039 class Future : private framing::StructHelper 00040 { 00041 framing::SequenceNumber command; 00042 boost::shared_ptr<FutureResult> result; 00043 bool complete; 00044 00045 public: 00046 Future() : complete(false) {} 00047 Future(const framing::SequenceNumber& id) : command(id), complete(false) {} 00048 00049 template <class T> void decodeResult(T& value, SessionImpl& session) 00050 { 00051 if (result) { 00052 decode(value, result->getResult(session)); 00053 } else { 00054 throw Exception("Result not expected"); 00055 } 00056 } 00057 00058 QPID_CLIENT_EXTERN void wait(SessionImpl& session); 00059 QPID_CLIENT_EXTERN bool isComplete(SessionImpl& session); 00060 QPID_CLIENT_EXTERN void setFutureResult(boost::shared_ptr<FutureResult> r); 00061 }; 00062 00063 }} 00064 00065 #endif