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
54 // ------------------------------------------------------------------------
58 rmr_mbuf_t* mbuf; // the underlying RMR message buffer
59 void* mrc; // message router context
60 std::shared_ptr<char> psp; // shared pointer to the payload to give out
63 static const int NO_CHANGE = -99; // indicates no change to a send/reply parameter
64 static const int NO_WHID = -1; // no wormhole id applies
65 static const int INVALID_MTYPE = -1;
66 static const int INVALID_STATUS = -1;
67 static const int INVALID_SUBID = -2;
68 static const int NO_SUBID = -1; // not all messages have a subid
70 static const int RESPONSE = 0; // send types
71 static const int MESSAGE = 1;
72 static const int WORMHOLE_MSG = 2;
74 Message( rmr_mbuf_t* mbuf, void* mrc ); // builders
75 Message( void* mrc, int payload_len );
76 Message( const Message& soi ); // copy cat
77 Message& operator=( const Message& soi ); // copy operator
78 Message( Message&& soi ); // mover
79 Message& operator=( Message&& soi ); // move operator
80 ~Message(); // destroyer
82 std::unique_ptr<unsigned char> Copy_payload( ); // copy the payload; deletable smart pointer
84 std::unique_ptr<unsigned char> Get_meid() const; // returns a copy of the meid bytes
85 int Get_available_size() const;
87 int Get_mtype() const;
88 Msg_component Get_payload() const;
89 std::unique_ptr<unsigned char> Get_src() const;
90 int Get_state( ) const;
91 int Get_subid() const;
93 void Set_meid( std::shared_ptr<unsigned char> new_meid );
94 void Set_mtype( int new_type );
95 void Set_subid( int new_subid );
96 void Set_len( int new_len );
100 bool Send( int mtype, int subid, int payload_len, unsigned char* payload, int stype, int whid );
102 bool Send_msg( int mtype, int subid, int payload_len, std::shared_ptr<unsigned char> payload );
103 bool Send_msg( int mtype, int subid, int payload_len, unsigned char* payload );
104 bool Send_msg( int payload_len, std::shared_ptr<unsigned char> payload );
105 bool Send_msg( int payload_len, unsigned char* payload );
107 bool Send_response( int mtype, int subid, int payload_len, std::shared_ptr<unsigned char> response );
108 bool Send_response( int mtype, int subid, int payload_len, unsigned char* response );
109 bool Send_response( int payload_len, std::shared_ptr<unsigned char> response );
110 bool Send_response( int payload_len, unsigned char* response );
112 bool Wormhole_send( int whid, int mtype, int subid, int payload_len, std::shared_ptr<unsigned char> payload );