4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <stdlib.h> /* size_t */
27 #define MAX_MSG_CAPACITY (32*1024)
28 #define MAX_HEADER_RESERVED 3
32 typedef struct message_header {
37 void *ancillary[MAX_HEADER_RESERVED] { nullptr };
42 template <class... Args>
43 static std::shared_ptr<message> create(Args&&... args)
44 noexcept(noexcept(message(std::forward<Args>(args)...)))
46 return std::shared_ptr<message>(new (std::nothrow) message(std::forward<Args>(args)...));
49 message(size_t capacity = MAX_MSG_CAPACITY);
50 message(const void *msg, size_t size);
51 message(const message &msg);
55 void enclose(const void *msg, const size_t size);
56 void enclose(int error);
57 void disclose(void *msg, const size_t size);
60 void set_type(uint32_t type);
68 message_header *header(void);
72 message_header m_header;
81 #endif /* __MESSAGE_H__ */