Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
method-result.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_METHOD_RESULT_HPP
26 #define CARGO_IPC_METHOD_RESULT_HPP
27 
28 #include "cargo-ipc/types.hpp"
29 #include "logger/logger.hpp"
30 #include <memory>
31 
32 namespace cargo {
33 namespace ipc {
34 
35 class Processor;
36 
45 class MethodResult {
46 public:
47  typedef std::shared_ptr<MethodResult> Pointer;
48 
49  MethodResult(Processor& processor,
50  const MethodID methodID,
51  const MessageID& messageID,
52  const PeerID& peerID);
53 
54 
55  template<typename Data>
56  void set(const std::shared_ptr<Data>& data)
57  {
58  setInternal(data);
59  }
60 
61  void setVoid();
62  void setError(const int code, const std::string& message);
63  PeerID getPeerID() const;
64 
65 private:
70 
71  void setInternal(const std::shared_ptr<void>& data);
72 };
73 
74 template<typename SentDataType, typename ReceivedDataType>
75 struct MethodHandler {
76  typedef std::function <bool(PeerID peerID,
77  std::shared_ptr<ReceivedDataType>& data,
78  MethodResult::Pointer methodResult) > type;
79 };
80 
81 } // namespace ipc
82 } // namespace cargo
83 
84 #endif // CARGO_IPC_METHOD_RESULT_HPP
MethodResult(Processor &processor, const MethodID methodID, const MessageID &messageID, const PeerID &peerID)
Definition: method-result.cpp:33
std::shared_ptr< MethodResult > Pointer
Definition: method-result.hpp:47
std::string PeerID
Definition: types.hpp:45
Types definitions.
void setError(const int code, const std::string &message)
Definition: method-result.cpp:53
void set(const std::shared_ptr< Data > &data)
Definition: method-result.hpp:56
void setVoid()
Definition: method-result.cpp:48
char data[368]
Definition: initctl.cpp:41
MessageID mMessageID
Definition: method-result.hpp:69
PeerID getPeerID() const
Definition: method-result.cpp:58
MethodID mMethodID
Definition: method-result.hpp:67
Definition: method-result.hpp:75
unsigned int MethodID
Definition: types.hpp:43
PeerID mPeerID
Definition: method-result.hpp:68
Class used to obtain method call result code.
Definition: method-result.hpp:45
std::function< bool(PeerID peerID, std::shared_ptr< ReceivedDataType > &data, MethodResult::Pointer methodResult) > type
Definition: method-result.hpp:78
This class wraps communication via UX sockets.
Definition: processor.hpp:88
Processor & mProcessor
Definition: method-result.hpp:66
void setInternal(const std::shared_ptr< void > &data)
Definition: method-result.cpp:43
std::string MessageID
Definition: types.hpp:44