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 Mnemonic: messenger.hpp
24 Abstract: Headers for the messenger class
27 Author: E. Scott Daniels
30 #ifndef _messenger_hpp
31 #define _messenger_hpp
42 #include "message.hpp"
44 #include "metrics.hpp"
57 std::map<int,Callback*> cb_hash; // callback functions associated with message types
58 std::mutex* gate; // overall mutex should we need searialisation
60 bool callbacks = false; // true if callbacks are defined
61 void* mrc; // message router context
62 char* listen_port; // port we ask msg router to listen on
64 // copy and assignment are PRIVATE so that they fail if xapp tries; messenger cannot be copied!
65 Messenger( const Messenger& soi );
66 Messenger& operator=( const Messenger& soi );
69 // -- constants which need an instance; that happens as a global in the .cpp file (wtf C++)
70 static const int MAX_PAYLOAD; // max message size we'll handle
71 static const int DEFAULT_CALLBACK; // parm for add callback to set default
73 Messenger( const char* port, bool wait4table ); // builder
74 Messenger( Messenger&& soi ); // move construction
75 Messenger& operator=( Messenger&& soi ); // move operator
76 ~Messenger(); // destroyer
78 void Add_msg_cb( int mtype, user_callback fun_name, void* data );
80 std::unique_ptr<Message> Alloc_msg( int payload_size ); // message allocation
82 std::unique_ptr<xapp::Alarm> Alloc_alarm( ); // alarm allocation
83 std::unique_ptr<xapp::Alarm> Alloc_alarm( const std::string& meid );
84 std::unique_ptr<xapp::Alarm> Alloc_alarm( int prob_id, const std::string& meid );
86 std::unique_ptr<xapp::Metrics> Alloc_metrics( ); // metrics allocation
87 std::unique_ptr<xapp::Metrics> Alloc_metrics( const std::string& source );
88 std::unique_ptr<xapp::Metrics> Alloc_metrics( const std::string& reporter, const std::string& source );
90 void Listen( ); // lisen driver
91 std::unique_ptr<Message> Receive( int timeout ); // receive 1 message
92 void Stop( ); // force to stop
93 bool Wait_for_cts( int max_wait );
95 int Wormhole_open( const std::string& endpoint );