Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cargo-fd.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Pawel Kubik (p.kubik@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 CARGO_FD_CARGO_FD_HPP
27 #define CARGO_FD_CARGO_FD_HPP
28 
31 
32 
33 namespace cargo {
34 
43 template <class Cargo>
44 void loadFromFD(const int fd, Cargo& visitable)
45 {
46  static_assert(isVisitable<Cargo>::value, "Use CARGO_REGISTER macro");
47 
48  FromFDStoreVisitor visitor(fd);
49  visitable.accept(visitor);
50 }
51 
58 template <class Cargo>
59 void saveToFD(const int fd, const Cargo& visitable)
60 {
61  static_assert(isVisitable<Cargo>::value, "Use CARGO_REGISTER macro");
62 
63  ToFDStoreVisitor visitor(fd);
64  visitable.accept(visitor);
65 }
66 
67 } // namespace cargo
68 
71 #endif // CARGO_FD_CARGO_FD_HPP
Definition: to-fdstore-visitor.hpp:44
void loadFromFD(const int fd, Cargo &visitable)
Load binary data from a file/socket/pipe represented by the fd.
Definition: cargo-fd.hpp:44
Visitor for saving to FDStore.
Visitor for loading from FDStore.
Definition: from-fdstore-visitor.hpp:40
Helper for compile-time checking against existance of template method 'accept'.
Definition: is-visitable.hpp:49
void saveToFD(const int fd, const Cargo &visitable)
Save binary data to a file/socket/pipe represented by the fd.
Definition: cargo-fd.hpp:59