YAMI4 C++
outgoing_message_manager.h
1 // Copyright Maciej Sobczak 2008-2019.
2 // This file is part of YAMI4.
3 //
4 // YAMI4 is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // YAMI4 is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef YAMICPP_OUTGOING_MESSAGE_MANAGER_H_INCLUDED
18 #define YAMICPP_OUTGOING_MESSAGE_MANAGER_H_INCLUDED
19 
20 #include "parameters.h"
21 #include <map>
22 #include <memory>
23 #include <vector>
24 
25 // selected per platform
26 #include <mutex.h>
27 
28 namespace yami
29 {
30 
31 namespace details
32 {
33 
34 struct outgoing_message_info;
35 
36 class outgoing_message_manager
37 {
38 public:
39  outgoing_message_manager();
40  ~outgoing_message_manager();
41 
42  void put(long long message_id, outgoing_message_info * outgoing);
43 
44  bool remove(long long message_id);
45 
46  void report_replied(long long message_id,
47  std::unique_ptr<parameters> & body);
48  void report_replied(long long message_id,
49  std::unique_ptr<std::vector<char> > & raw_buffer);
50 
51  void report_rejected(long long message_id, const std::string & reason);
52 
53 private:
54  outgoing_message_manager(const outgoing_message_manager &);
55  void operator=(const outgoing_message_manager &);
56 
57  typedef std::map<long long, outgoing_message_info *> map_type;
58 
59  bool do_remove(map_type::iterator it);
60 
61  map_type map_;
62  mutex mtx_;
63 };
64 
65 } // namespace details
66 
67 } // namespace yami
68 
69 #endif // YAMICPP_OUTGOING_MESSAGE_MANAGER_H_INCLUDED
Namespace devoted to everything related to YAMI4.
Definition: activity_statistics_monitor.cpp:27