[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / messaging / ThreadMessage.h
blob1a277ffcd4edb04494848f03f9e5417d7a6de0f8
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <memory>
12 #include <string>
13 #include <utility>
14 #include <vector>
16 class CEvent;
18 namespace KODI
20 namespace MESSAGING
23 class CApplicationMessenger;
25 class ThreadMessage
27 friend CApplicationMessenger;
28 public:
29 ThreadMessage()
30 : ThreadMessage{ 0, -1, -1, nullptr }
34 explicit ThreadMessage(uint32_t messageId)
35 : ThreadMessage{ messageId, -1, -1, nullptr }
39 ThreadMessage(uint32_t messageId, int64_t p3)
40 : ThreadMessage{ messageId, -1, -1, nullptr, p3 }
44 ThreadMessage(uint32_t messageId, int p1, int p2, void* payload, int64_t p3 = 0)
45 : dwMessage{ messageId }
46 , param1{ p1 }
47 , param2{ p2 }
48 , param3{ p3 }
49 , lpVoid{ payload }
53 ThreadMessage(uint32_t messageId,
54 int p1,
55 int p2,
56 void* payload,
57 std::string param,
58 std::vector<std::string> vecParams)
59 : dwMessage{messageId},
60 param1{p1},
61 param2{p2},
62 param3{0},
63 lpVoid{payload},
64 strParam(std::move(param)),
65 params(std::move(vecParams))
69 ThreadMessage(const ThreadMessage& other) = default;
71 ThreadMessage(ThreadMessage&& other) noexcept
72 : dwMessage(other.dwMessage),
73 param1(other.param1),
74 param2(other.param2),
75 param3(other.param3),
76 lpVoid(other.lpVoid),
77 strParam(std::move(other.strParam)),
78 params(std::move(other.params)),
79 waitEvent(std::move(other.waitEvent)),
80 result(std::move(other.result))
84 ThreadMessage& operator=(const ThreadMessage& other)
86 if (this == &other)
87 return *this;
88 dwMessage = other.dwMessage;
89 param1 = other.param1;
90 param2 = other.param2;
91 param3 = other.param3;
92 lpVoid = other.lpVoid;
93 strParam = other.strParam;
94 params = other.params;
95 waitEvent = other.waitEvent;
96 result = other.result;
97 return *this;
100 ThreadMessage& operator=(ThreadMessage&& other) noexcept
102 if (this == &other)
103 return *this;
104 dwMessage = other.dwMessage;
105 param1 = other.param1;
106 param2 = other.param2;
107 param3 = other.param3;
108 lpVoid = other.lpVoid;
109 strParam = std::move(other.strParam);
110 params = std::move(other.params);
111 waitEvent = std::move(other.waitEvent);
112 result = std::move(other.result);
113 return *this;
116 uint32_t dwMessage;
117 int param1;
118 int param2;
119 int64_t param3;
120 void* lpVoid;
121 std::string strParam;
122 std::vector<std::string> params;
125 * \brief set the message return value, will only be returned when
126 * the message is sent using SendMsg
127 * \param [in] res the return value or a result status code that is returned to the caller
129 void SetResult(int res) const
131 //On posted messages result will be zero, since they can't
132 //retrieve the response we silently ignore this to let message
133 //handlers not have to worry about it
134 if (result)
135 *result = res;
137 protected:
138 std::shared_ptr<CEvent> waitEvent;
139 std::shared_ptr<int> result;