ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
pmicli_invoke_result.h
1 /*
2  Copyright (c) 2013 by ScaleOut Software, Inc.
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include <stdint.h>
20 #include <stdexcept>
21 #include <vector>
22 #include "boost/shared_ptr.hpp"
23 
24 #include "soss_client/pmicli_invoke_exception.h"
25 
26 #include "soss_pmicli.h"
27 
28 namespace sosscli {
29 
32 {
33 public:
34 
35  /* Constructors */
36 
38  PmicliInvokeResult(const int32_t return_code, boost::shared_ptr< std::vector<uint8_t> > object_ptr,
39  boost::shared_ptr< std::vector<sosscli::exceptions::PmiCliUserExceptionCode> > exceptions_ptr, const unsigned int num_successful, const unsigned int num_failed)
40  : return_code_(return_code), object_ptr_(object_ptr), exceptions_ptr_(exceptions_ptr), num_successful_(num_successful), num_failed_(num_failed) {}
41 
43  virtual ~PmicliInvokeResult() {};
44 
45  /* Accessors */
46 
49  boost::shared_ptr< std::vector<uint8_t> > object_ptr()
50  {
51  if (return_code_ < 1)
52  throw std::runtime_error("The invoke did not complete successfully. Check PmicliInvokeResult.return_code() for error info.");
53  return object_ptr_;
54  }
55 
58  boost::shared_ptr< std::vector<sosscli::exceptions::PmiCliUserExceptionCode> > exceptions_ptr()
59  {
60  if (return_code_ < 1)
61  throw std::runtime_error("The invoke did not complete successfully. Check PmicliInvokeResult.return_code() for error info.");
62  return exceptions_ptr_;
63  }
64 
66  int32_t return_code() const { return return_code_; }
67 
69  unsigned int num_successful() const { return num_successful_; }
70 
72  unsigned int num_failed() const { return num_failed_; }
73 
74 protected:
75 
76 private:
78 
79  int32_t return_code_;
80  unsigned int num_successful_;
81  unsigned int num_failed_;
82 
83  boost::shared_ptr< std::vector<uint8_t> > object_ptr_;
84  boost::shared_ptr< std::vector<sosscli::exceptions::PmiCliUserExceptionCode> > exceptions_ptr_;
85 };
86 
87 } // namespace