/usr/include/caf/message_id.hpp is in libcaf-dev 0.13.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | /******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2015 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENSE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_MESSAGE_ID_HPP
#define CAF_MESSAGE_ID_HPP
#include <cstdint>
#include "caf/config.hpp"
#include "caf/message_priority.hpp"
#include "caf/detail/comparable.hpp"
namespace caf {
struct invalid_message_id_t {
constexpr invalid_message_id_t() {
// nop
}
};
constexpr invalid_message_id_t invalid_message_id = invalid_message_id_t{};
/**
* Denotes whether a message is asynchronous or synchronous
* @note Asynchronous messages always have an invalid message id.
*/
class message_id : detail::comparable<message_id> {
public:
static constexpr uint64_t response_flag_mask = 0x8000000000000000;
static constexpr uint64_t answered_flag_mask = 0x4000000000000000;
static constexpr uint64_t high_prioity_flag_mask = 0x2000000000000000;
static constexpr uint64_t request_id_mask = 0x1FFFFFFFFFFFFFFF;
constexpr message_id() : m_value(0) {
// nop
}
constexpr message_id(invalid_message_id_t) : m_value(0) {
// nop
}
message_id(message_id&&) = default;
message_id(const message_id&) = default;
message_id& operator=(message_id&&) = default;
message_id& operator=(const message_id&) = default;
inline message_id& operator++() {
++m_value;
return *this;
}
inline bool is_response() const {
return (m_value & response_flag_mask) != 0;
}
inline bool is_answered() const {
return (m_value & answered_flag_mask) != 0;
}
inline bool is_high_priority() const {
return (m_value & high_prioity_flag_mask) != 0;
}
inline bool valid() const {
return (m_value & request_id_mask) != 0;
}
inline bool is_request() const {
return valid() && !is_response();
}
inline message_id response_id() const {
return message_id{is_request() ? m_value | response_flag_mask : 0};
}
inline message_id request_id() const {
return message_id(m_value & request_id_mask);
}
inline message_id with_high_priority() const {
return message_id(m_value | high_prioity_flag_mask);
}
inline message_id with_normal_priority() const {
return message_id(m_value & ~high_prioity_flag_mask);
}
inline void mark_as_answered() {
m_value |= answered_flag_mask;
}
inline uint64_t integer_value() const {
return m_value;
}
static inline message_id from_integer_value(uint64_t value) {
message_id result;
result.m_value = value;
return result;
}
static inline message_id make(message_priority prio
= message_priority::normal) {
message_id res;
return prio == message_priority::high ? res.with_high_priority() : res;
}
long compare(const message_id& other) const {
return (m_value == other.m_value) ? 0
: (m_value < other.m_value ? -1 : 1);
}
private:
explicit inline message_id(uint64_t value) : m_value(value) {
// nop
}
uint64_t m_value;
};
} // namespace caf
#endif // CAF_MESSAGE_ID_HPP
|