00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef PEEKABOT_CLIENT_RESULT_HH_INCLUDED
00012 #define PEEKABOT_CLIENT_RESULT_HH_INCLUDED
00013
00014
00015 #include <stdexcept>
00016 #include <boost/shared_ptr.hpp>
00017
00018 #include "../Any.hh"
00019 #include "OperationResult.hh"
00020 #include "Status.hh"
00021
00022
00023 namespace peekabot
00024 {
00025 namespace client
00026 {
00036 template<class T>
00037 class Result : public Status
00038 {
00039 public:
00044 Result() : Status() {}
00045
00046 virtual ~Result() {}
00047
00051 Result(boost::shared_ptr<OperationResult> result)
00052 : Status(result),
00053 m_result(result)
00054 {
00055 }
00056
00066 const T get_result() const
00067 {
00068 try
00069 {
00070 return any_cast<T>(m_result->get_result());
00071 }
00072 catch(BadAnyCast &)
00073 {
00074 throw std::runtime_error(
00075 "The specified and actual result types mismatch");
00076 }
00077 }
00078
00079 private:
00088 boost::shared_ptr<OperationResult> m_result;
00089 };
00090 }
00091 }
00092
00093
00094 #endif // PEEKABOT_CLIENT_RESULT_HH_INCLUDED