OnixS C++ B3 BOE Binary Order Entry  1.2.0
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 
23 #include <OnixS/B3/BOE/Compiler.h>
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 B3 {
42 namespace BOE {
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 of the SOL_SOCKET level
60 struct SocketOption {
63 
64  SocketOption(int optionName, const void* optionValue, int optionLength) ONIXS_B3_BOE_NOTHROW
65  : optname(optionName), optval(optionValue), optlen(optionLength) {}
66 
67  int optname;
68  const void * optval;
69  int optlen;
70 };
71 
72 typedef size_t CpuIndex;
73 typedef std::set<CpuIndex> CpuIndexes;
74 typedef std::pair<Port, Port> PortRange;
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_B3_BOE_CXX11)
102  typedef std::unique_ptr<T> UniquePtr;
103 #else
104  typedef std::auto_ptr<T> UniquePtr;
105 #endif
106 };
107 
108 }
109 }
110 }
std::pair< Port, Port > PortRange
Definition: Defines.h:74
std::vector< Byte > Bytes
Sequence of bytes.
Definition: Defines.h:49
std::unique_ptr< T > UniquePtr
Definition: Defines.h:102
#define ONIXS_B3_BOE_NULLPTR
Definition: Compiler.h:188
#define ONIXS_B3_BOE_NOTHROW
Definition: Compiler.h:182
SocketOption(int optionName, const void *optionValue, int optionLength) noexcept
Definition: Defines.h:64
Definition: Defines.h:40
unsigned char Byte
Type alias for byte.
Definition: Defines.h:46
std::set< CpuIndex > CpuIndexes
Definition: Defines.h:73
unsigned short Port
Definition: Defines.h:44
std::vector< SocketOption > SocketOptions
Socket options.
Definition: Defines.h:77
size_t CpuIndex
Definition: Defines.h:72
Socket option of the SOL_SOCKET level.
Definition: Defines.h:60
int Handle
Type alias for socket handle.
Definition: Defines.h:56