summaryrefslogtreecommitdiff
path: root/SDL_Core/src/components/protocol_handler/src/message_priority.cc
blob: 7a9c30d688d3e8d4038ef2cdc60e8a79056d2e61 (plain)
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
#include "protocol_handler/service_type.h"
#include "protocol_handler/message_priority.h"

#include "utils/logger.h"
#include "utils/macro.h"

namespace {
log4cxx::LoggerPtr g_logger = log4cxx::LoggerPtr(
    log4cxx::Logger::getLogger("ConnectionHandler"));
}

namespace protocol_handler {

// static
const MessagePriority MessagePriority::kDefault = MessagePriority(0);

// static
MessagePriority MessagePriority::FromServiceType(ServiceType service_type) {
  size_t message_priority_value = size_t(service_type);
  DCHECK(message_priority_value <= 0xFF);
  // According to Applink Protocol Specification v5 service with numerically
  // lower service type identifiers have higher priority
  return MessagePriority(0xFF - service_type);
}

} // namespace protocol_handler