OnixS C++ CME MDP Conflated TCP Handler  1.3.6
API Documentation
Defines.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
5 *
6 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
7 * and international copyright treaties.
8 *
9 * Access to and use of the software is governed by the terms of the applicable OnixS Software
10 * Services Agreement (the Agreement) and Customer end user license agreements granting
11 * a non-assignable, non-transferable and non-exclusive license to use the software
12 * for it's own data processing purposes under the terms defined in the Agreement.
13 *
14 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
15 * of this source code or associated reference material to any other location for further reproduction
16 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
17 *
18 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
19 * the terms of the Agreement is a violation of copyright law.
20 */
21 
24 
25 #include <vector>
26 #include <string>
27 #include <set>
28 #include <memory>
29 
30 #if defined(_WIN32) // Windows platform.
31 
32 #if !defined(STRICT)
33 #define STRICT
34 #endif
35 
36 #include <winsock2.h>
37 
38 #endif
39 
40 namespace OnixS {
41 namespace CME {
42 namespace ConflatedTCP {
43 
44 typedef unsigned short Port;
45 /// Type alias for byte.
46 typedef unsigned char Byte;
47 
48 /// Sequence of bytes.
49 typedef std::vector<Byte> Bytes;
50 
51 #if defined (_WIN32)
52 /// Type alias for socket handle.
53 typedef SOCKET Handle;
54 #else
55 /// Type alias for socket handle.
56 typedef int Handle;
57 #endif
58 
59 /// Socket option.
60 struct SocketOption {
63 
64  SocketOption(int optionLevel, int optionName, void* optionValue, int optionLength) ONIXS_CONFLATEDTCP_NOTHROW
65  : level(optionLevel), optname(optionName), optval(optionValue), optlen(optionLength) {}
66 
67  int level;
68  int optname;
69  void * optval;
70  int optlen;
71 };
72 
73 typedef size_t CpuIndex;
74 typedef std::set<CpuIndex> CpuIndexes;
75 
76 /// Socket options.
77 typedef std::vector<SocketOption> SocketOptions;
78 
79 struct ThreadParams {
80  std::string name;
81  CpuIndexes affinity;
82  int priority;
83  int policy;
84 
86  : priority(0)
87  , policy(0)
88  {
89  }
90 };
91 
93  enum Enum {
94  UndefinedPriorityAndPolicy = 255
95  };
96 };
97 
98 template <typename T>
99 struct PtrTraits
100 {
101 #if defined(ONIXS_CONFLATEDTCP_CXX11)
102  typedef std::unique_ptr<T> UniquePtr;
103 #else
104  typedef std::auto_ptr<T> UniquePtr;
105 #endif
106 };
107 
108 }
109 }
110 }
unsigned short Port
Definition: Defines.h:44
#define ONIXS_CONFLATEDTCP_NOTHROW
Definition: Compiler.h:176
std::unique_ptr< T > UniquePtr
Definition: Defines.h:102
int Handle
Type alias for socket handle.
Definition: Defines.h:56
std::vector< SocketOption > SocketOptions
Socket options.
Definition: Defines.h:77
Definition: Defines.h:40
std::vector< Byte > Bytes
Sequence of bytes.
Definition: Defines.h:49
std::set< CpuIndex > CpuIndexes
Definition: Defines.h:74
SocketOption(int optionLevel, int optionName, void *optionValue, int optionLength) noexcept
Definition: Defines.h:64
unsigned char Byte
Type alias for byte.
Definition: Defines.h:46
#define ONIXS_CONFLATEDTCP_NULLPTR
Definition: Compiler.h:182