DAVID4 SDK
1.8.7
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Groups
Pages
Common.h
1
//=============================================================================
2
// See License in Related Pages
3
//=============================================================================
4
5
#pragma once
6
7
#ifndef DAVID_SDK_COMMON_H
8
#define DAVID_SDK_COMMON_H
9
10
#include <stdint.h>
11
#include "davidSDK/Exceptions.h"
12
13
namespace
david {
14
15
//*****************************************************************************
16
/// @defgroup ManagerGroup Management
17
/// Important high level management functions and types.
18
//*****************************************************************************
19
20
//*****************************************************************************
21
/// @defgroup InterfaceGroup High Level Interfaces
22
/// High level Interface classes are listed here.
23
//*****************************************************************************
24
25
//*****************************************************************************
26
/// @defgroup LowLevelGroup Low Level Interfaces
27
/// Low level stuff is listet here.
28
//*****************************************************************************
29
30
31
//=============================================================================
32
// Global variables
33
//=============================================================================
34
35
/// Defines the version of the client.
36
/// The server checks this client version against its minimum required client version.
37
const
double
DAVID_SDK_ClientVersion
= 1.0;
38
39
/// Defines DAVID default port.
40
const
uint16_t
DAVID_SDK_DefaultPort
= 10500;
41
42
43
//=============================================================================
44
// PixelFormat
45
//=============================================================================
46
47
/// Describes different pixel formats.
48
enum
PixelFormat
49
{
50
UnknownPixelFormat
= 0,
///< Unknown pixel format
51
Y800
,
///< Standard 8bit grayscale format.
52
RGB24
,
///< Red, green, and blue 8bit color components for each pixel. Byte 0=8bit blue; Byte 1=8bit green; Byte 2=8bit red.
53
YUY2
,
///< 16bit color format. Byte 0=8-bit Y'0; Byte 1=8-bit Cb; Byte 2=8-bit Y'1; Byte 3=8-bit Cr.
54
BY8
,
///< 8bit bayer color format.
55
};
56
57
/// Get bits per pixel for given pixel format.
58
/// @param[in] pixelFormat Pixel format, see #PixelFormat.
59
/// @return Bits per pixel or zero.
60
int
GetBitsPerPixel
(
enum
PixelFormat
pixelFormat);
61
62
/// Get image size in bytes.
63
/// @param[in] width Width of the image in [px]
64
/// @param[in] height Height of the image in [px]
65
/// @param[in] pixelFormat See #PixelFormat.
66
/// @return Image size in bytes or zero.
67
size_t
GetImageSize
(
int
width,
int
height,
enum
PixelFormat
pixelFormat);
68
69
70
//=============================================================================
71
// Optional
72
//=============================================================================
73
74
/// The class template david::Optional manages an optional contained value, i.e. a value that semantically may not be present.
75
///
76
/// The value inside an optional object may be in either an initialized or uninitialized state.
77
/// An optional object with a value in initialized state is called engaged,
78
/// whereas if the value is in uninitialized state, the object is called disengaged.
79
///
80
/// Interface is similar to std::optional defined in C++14:
81
/// http://en.cppreference.com/w/cpp/utility/optional
82
///
83
template
<
class
T>
84
class
Optional
85
{
86
public
:
87
/// Standard constructor.
88
/// Value is not initialized.
89
Optional
() : m_engaged(false) {}
90
91
/// Constructor that initializes the value.
92
/// @param[in] value Value to assign to the contained value.
93
Optional
(
const
T&
value
) : m_value(value), m_engaged(true) {}
94
95
/// Get value.
96
/// @return Current value. Might be anything, if not initialized.
97
/// @exception david::Error_MissingObject (david::Exception) Value is not initialized.
98
const
T&
value
()
const
99
{
100
if
(!m_engaged)
throw
david::Exception
(
david::Error_MissingObject
,
"Value is not initialized."
,
"david::Optional::value"
);
101
return
m_value;
102
}
103
104
/// Checks whether *this is in engaged state, i.e. whether the contained value is initialized.
105
/// @return true if *this is in engaged state, false otherwise.
106
operator
bool()
const
{
return
m_engaged;}
107
108
private
:
109
T m_value;
///< Stores the value.
110
bool
m_engaged;
///< Is value initialized?
111
};
112
113
114
}
// namespace
115
116
#endif // DAVID_SDK_COMMON_H
davidSDK
Common.h
Generated on Tue May 17 2016 17:11:27 for DAVID4 SDK by
1.8.4