YARP
Yet Another Robot Platform
QosStyle.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef YARP_OS_QOSSTYLE_H
10 #define YARP_OS_QOSSTYLE_H
11 
12 #include <yarp/os/api.h>
13 
14 #include <string>
15 
16 namespace yarp {
17 namespace os {
18 
26 {
27 public:
33  {
34  PacketPriorityInvalid = -1,
35  PacketPriorityNormal = 0,
36  PacketPriorityLow = 10,
37  PacketPriorityHigh = 36,
38  PacketPriorityCritical = 44,
39  PacketPriorityUndefined = 0x7FFF
40  };
41 
42 
48  {
49  DSCP_Invalid = -1,
50  DSCP_CS0 = 0,
51  DSCP_CS1 = 8,
52  DSCP_CS2 = 16,
53  DSCP_CS3 = 24,
54  DSCP_CS4 = 32,
55  DSCP_CS5 = 40,
56  DSCP_CS6 = 48,
57  DSCP_CS7 = 56,
58  DSCP_AF11 = 10,
59  DSCP_AF12 = 12,
60  DSCP_AF13 = 14,
61  DSCP_AF21 = 18,
62  DSCP_AF22 = 20,
63  DSCP_AF23 = 22,
64  DSCP_AF31 = 26,
65  DSCP_AF32 = 28,
66  DSCP_AF33 = 30,
67  DSCP_AF41 = 34,
68  DSCP_AF42 = 36,
69  DSCP_AF43 = 38,
70  DSCP_VA = 44,
71  DSCP_EF = 46,
72  DSCP_Undefined = 0x7FFF
73  };
74 
75 
79  explicit QosStyle();
80 
81 
86  void setPacketPriorityByDscp(PacketPriorityDSCP dscp);
87 
88 
93  void setPacketPriorityByLevel(PacketPriorityLevel level);
94 
95 
101  {
102  packetPriority = tos;
103  }
104 
105 
123  bool setPacketPriority(const std::string& priority);
124 
125 
130  void setThreadPriority(int priority)
131  {
132  threadPriority = priority;
133  }
134 
135 
140  void setThreadPolicy(int policy)
141  {
142  threadPolicy = policy;
143  }
144 
145 
151  {
152  return packetPriority;
153  }
154 
155 
160  PacketPriorityDSCP getPacketPriorityAsDSCP() const;
161 
162 
167  PacketPriorityLevel getPacketPriorityAsLevel() const;
168 
169 
174  int getThreadPriority() const
175  {
176  return threadPriority;
177  }
178 
179 
184  int getThreadPolicy() const
185  {
186  return threadPolicy;
187  }
188 
189 
195  static PacketPriorityDSCP getDSCPByVocab(int vocab);
196 
197 
203  static PacketPriorityLevel getLevelByVocab(int vocab);
204 
205 
206 private:
207  int threadPriority;
208  int threadPolicy;
209  int packetPriority;
210 };
211 
212 } // namespace os
213 } // namespace yarp
214 
215 #endif // YARP_OS_QOSSTYLE_H
yarp::os::QosStyle
Preferences for the port's Quality of Service.
Definition: QosStyle.h:26
yarp::os::QosStyle::getThreadPriority
int getThreadPriority() const
returns the communication thread priority level
Definition: QosStyle.h:174
yarp::os::QosStyle::getThreadPolicy
int getThreadPolicy() const
returns the communication thread scheduling policy
Definition: QosStyle.h:184
api.h
YARP_os_API
#define YARP_os_API
Definition: api.h:19
yarp::os::QosStyle::setThreadPriority
void setThreadPriority(int priority)
sets the communication thread priority level
Definition: QosStyle.h:130
yarp::os::QosStyle::PacketPriorityDSCP
PacketPriorityDSCP
The PacketPriorityDSCP defines the packets quality of service (priority) using DSCP.
Definition: QosStyle.h:48
yarp::os::QosStyle::getPacketPriorityAsTOS
int getPacketPriorityAsTOS() const
returns the packet TOS value
Definition: QosStyle.h:150
yarp::os::QosStyle::setThreadPolicy
void setThreadPolicy(int policy)
sets the communication thread scheduling policy
Definition: QosStyle.h:140
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::os::QosStyle::PacketPriorityLevel
PacketPriorityLevel
The PacketPriorityLevel defines the packets quality of service (priority) levels.
Definition: QosStyle.h:33
yarp::os::QosStyle::setPacketPrioritybyTOS
void setPacketPrioritybyTOS(int tos)
sets the packet priority given as TOS value
Definition: QosStyle.h:100