3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
22 Mnemonic: msg_component.hpp
23 Abstract: Defines a message component type which is needed in order
24 to use smart pointers (unique) to point at bytes in the
25 RMR message (which are not directly allocated and cannot
26 be freed/deleted outside of RMR (require a special destruction
27 call in the smart pointer).
30 Author: E. Scott Daniels
33 #ifndef _MSG_COMPONENT_HPP
34 #define _MSG_COMPONENT_HPP
40 // -------------- smart pointer support --------------------------------
42 Pointers to a lot of things in the RMR message aren't directly
43 allocated and thus cannot be directly freed. To return a smart
44 pointer to these we have to ensure that no attempt to free/delete
45 the reference is made. This struct defines a type with a function
46 pointer (operator) that is 'registered' as the delete function for
47 such a smart pointer, and does _nothing_ when called.
50 void operator()( unsigned char * p ) const { /* empty to prevent free */ }
54 A 'generic' smart pointer to a component in the message which cannot
55 be directly freed (e.g. the payload, meid, etc).
57 using Msg_component = std::unique_ptr<unsigned char, unfreeable>;