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 ==================================================================================
23 Abstract: Headers for the message class.
24 This class provides an interface to the user application
25 when information from the message is needed.
28 Author: E. Scott Daniels
40 #include "msg_component.hpp"
41 #include "callback.hpp"
42 #include "default_cb.hpp"
45 #define RMR_NO_CLONE 0
52 // ------------------------------------------------------------------------
56 rmr_mbuf_t* mbuf; // the underlying RMR message buffer
57 void* mrc; // message router context
58 std::shared_ptr<char> psp; // shared pointer to the payload to give out
61 static const int NO_CHANGE = -99; // indicates no change to a send/reply parameter
62 static const int INVALID_MTYPE = -1;
63 static const int INVALID_STATUS = -1;
64 static const int INVALID_SUBID = -2;
65 static const int NO_SUBID = -1; // not all messages have a subid
67 static const int RESPONSE = 0; // send types
68 static const int MESSAGE = 1;
70 Message( rmr_mbuf_t* mbuf, void* mrc ); // builders
71 Message( void* mrc, int payload_len );
72 Message( const Message& soi ); // copy cat
73 Message& operator=( const Message& soi ); // copy operator
74 Message( Message&& soi ); // mover
75 Message& operator=( Message&& soi ); // move operator
76 ~Message(); // destroyer
78 std::unique_ptr<unsigned char> Copy_payload( ); // copy the payload; deletable smart pointer
80 std::unique_ptr<unsigned char> Get_meid(); // returns a copy of the meid bytes
81 int Get_available_size();
84 Msg_component Get_payload();
85 std::unique_ptr<unsigned char> Get_src();
89 void Set_meid( std::shared_ptr<unsigned char> new_meid );
90 void Set_mtype( int new_type );
91 void Set_subid( int new_subid );
92 void Set_len( int new_len );
96 bool Send( int mtype, int subid, int payload_len, unsigned char* payload, int stype );
98 bool Send_msg( int mtype, int subid, int payload_len, std::shared_ptr<unsigned char> payload );
99 bool Send_msg( int mtype, int subid, int payload_len, unsigned char* payload );
100 bool Send_msg( int payload_len, std::shared_ptr<unsigned char> payload );
101 bool Send_msg( int payload_len, unsigned char* payload );
103 bool Send_response( int mtype, int subid, int payload_len, std::shared_ptr<unsigned char> response );
104 bool Send_response( int mtype, int subid, int payload_len, unsigned char* response );
105 bool Send_response( int payload_len, std::shared_ptr<unsigned char> response );
106 bool Send_response( int payload_len, unsigned char* response );