Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
result-builder.hpp
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Contact: Jan Olszak <j.olszak@samsung.com>
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
17 */
18 
25 #ifndef CARGO_IPC_INTERNALS_RESULT_BUILDER_HPP
26 #define CARGO_IPC_INTERNALS_RESULT_BUILDER_HPP
27 
28 #include "cargo-ipc/result.hpp"
29 #include <functional>
30 #include <exception>
31 #include <memory>
32 
33 namespace cargo {
34 namespace ipc {
35 
37 public:
39  : mData(nullptr),
40  mExceptionPtr(nullptr)
41  {}
42 
43  explicit ResultBuilder(const std::exception_ptr& exceptionPtr)
44  : mData(nullptr),
45  mExceptionPtr(exceptionPtr)
46  {}
47 
48  explicit ResultBuilder(const std::shared_ptr<void>& data)
49  : mData(data),
50  mExceptionPtr(nullptr)
51 
52  {}
53 
54  template<typename Data>
56  {
57  return Result<Data>(std::move(std::static_pointer_cast<Data>(mData)),
58  std::move(mExceptionPtr));
59  }
60 
61 private:
62  std::shared_ptr<void> mData;
63  std::exception_ptr mExceptionPtr;
64 };
65 
66 typedef std::function<void(ResultBuilder&)> ResultBuilderHandler;
67 
68 
69 } // namespace ipc
70 } // namespace cargo
71 
72 #endif // CARGO_IPC_INTERNALS_RESULT_BUILDER_HPP
std::function< void(ResultBuilder &)> ResultBuilderHandler
Definition: result-builder.hpp:66
Result< Data > build()
Definition: result-builder.hpp:55
ResultBuilder()
Definition: result-builder.hpp:38
std::shared_ptr< void > mData
Definition: result-builder.hpp:62
Class for storing result of a method - data or exception.
ResultBuilder(const std::shared_ptr< void > &data)
Definition: result-builder.hpp:48
Definition: result.hpp:36
char data[368]
Definition: initctl.cpp:41
Definition: result-builder.hpp:36
std::exception_ptr mExceptionPtr
Definition: result-builder.hpp:63
ResultBuilder(const std::exception_ptr &exceptionPtr)
Definition: result-builder.hpp:43