ScaleOut Native C++ API Library  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
invoke_result.h
1 #pragma once
2 
3 #include <stdint.h>
4 #include <stdexcept>
5 #include <vector>
6 #include "boost/shared_ptr.hpp"
7 
8 #include "soss_client/pmicli_invoke_exception.h"
9 
10 #include "soss_pmicli.h"
11 
12 namespace sosscli {
13 
16 {
17 public:
18 
19  /* Constructors */
20 
22  InvokeResult(const int32_t return_code, boost::shared_ptr< std::vector<uint8_t> > object_ptr,
23  boost::shared_ptr< std::vector<sosscli::exceptions::PmiCliUserExceptionCode> > exceptions_ptr, const unsigned int num_successful, const unsigned int num_failed)
24  : return_code_(return_code), object_ptr_(object_ptr), exceptions_ptr_(exceptions_ptr), num_successful_(num_successful), num_failed_(num_failed) {}
25 
27  virtual ~InvokeResult() {};
28 
29  /* Accessors */
30 
33  boost::shared_ptr< std::vector<uint8_t> > object_ptr()
34  {
35  if (return_code_ < 1)
36  throw std::runtime_error("The invoke did not complete successfully. Check InvokeResult.return_code() for error info.");
37  return object_ptr_;
38  }
39 
42  boost::shared_ptr< std::vector<sosscli::exceptions::PmiCliUserExceptionCode> > exceptions_ptr()
43  {
44  if (return_code_ < 1)
45  throw std::runtime_error("The invoke did not complete successfully. Check InvokeResult.return_code() for error info.");
46  return exceptions_ptr_;
47  }
48 
50  int32_t return_code() const { return return_code_; }
51 
53  unsigned int num_successful() const { return num_successful_; }
54 
56  unsigned int num_failed() const { return num_failed_; }
57 
58 protected:
59 
60 private:
61  InvokeResult() {}
62 
63  int32_t return_code_;
64  unsigned int num_successful_;
65  unsigned int num_failed_;
66 
67  boost::shared_ptr< std::vector<uint8_t> > object_ptr_;
68  boost::shared_ptr< std::vector<sosscli::exceptions::PmiCliUserExceptionCode> > exceptions_ptr_;
69 };
70 
71 } // namespace