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 00034 namespace qpid { 00035 namespace client { 00036 00038 class Future : private framing::StructHelper 00039 { 00040 framing::SequenceNumber command; 00041 boost::shared_ptr<FutureResult> result; 00042 bool complete; 00043 00044 public: 00045 Future() : complete(false) {} 00046 Future(const framing::SequenceNumber& id) : command(id), complete(false) {} 00047 00048 template <class T> void decodeResult(T& value, SessionImpl& session) 00049 { 00050 if (result) { 00051 decode(value, result->getResult(session)); 00052 } else { 00053 throw Exception("Result not expected"); 00054 } 00055 } 00056 00057 void wait(SessionImpl& session); 00058 bool isComplete(SessionImpl& session); 00059 void setFutureResult(boost::shared_ptr<FutureResult> r); 00060 }; 00061 00062 }} 00063 00064 #endif