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-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 
26 #ifndef COMMON_RESULT_METHOD_RESULT_BUILDER_HPP
27 #define COMMON_RESULT_METHOD_RESULT_BUILDER_HPP
28 
29 #include <memory>
30 
31 #include "cargo/is-union.hpp"
32 
33 namespace vasum {
34 namespace api {
35 
40 public:
41  typedef std::shared_ptr<MethodResultBuilder> Pointer;
42 
43  virtual ~MethodResultBuilder() {}
44  virtual void setVoid() = 0;
45  virtual void setError(const std::string& name, const std::string& message) = 0;
46  virtual std::string getID() const = 0;
47 
48  template<typename Data>
49  void set(const std::shared_ptr<Data>& data)
50  {
51  static_assert(cargo::isVisitable<Data>::value, "Use only Cargo's structures");
52  setImpl(data);
53  }
54 
55 private:
56  virtual void setImpl(const std::shared_ptr<void>& data) = 0;
57 
58 };
59 
60 } // namespace api
61 } // namespace vasum
62 
63 #endif // COMMON_RESULT_METHOD_RESULT_BUILDER_HPP
virtual std::string getID() const =0
virtual void setError(const std::string &name, const std::string &message)=0
virtual void setImpl(const std::shared_ptr< void > &data)=0
virtual ~MethodResultBuilder()
Definition: method-result-builder.hpp:43
Internal configuration helper.
An interface used to set a result to a method call.
Definition: method-result-builder.hpp:39
char data[368]
Definition: initctl.cpp:41
Helper for compile-time checking against existance of template method 'accept'.
Definition: is-visitable.hpp:49
void set(const std::shared_ptr< Data > &data)
Definition: method-result-builder.hpp:49
std::shared_ptr< MethodResultBuilder > Pointer
Definition: method-result-builder.hpp:41