This repository was archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckStatus.cpp
More file actions
75 lines (66 loc) · 1.95 KB
/
CheckStatus.cpp
File metadata and controls
75 lines (66 loc) · 1.95 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* OpenSplice DDS
*
* This software and documentation are Copyright 2006 to 2009 PrismTech
* Limited and its licensees. All rights reserved. See file:
*
* $OSPL_HOME/LICENSE
*
* for full copyright notice and license terms.
*
*/
/************************************************************************
* LOGICAL_NAME: CheckStatus.cpp
* FUNCTION: OpenSplice Tutorial example code.
* MODULE: Tutorial for the C++ programming language.
* DATE june 2007.
************************************************************************
*
* This file contains the implementation for the error handling operations.
*
***/
#include "CheckStatus.h"
/* Array to hold the names for all ReturnCodes. */
char *RetCodeName[13] = {
"DDS_RETCODE_OK",
"DDS_RETCODE_ERROR",
"DDS_RETCODE_UNSUPPORTED",
"DDS_RETCODE_BAD_PARAMETER",
"DDS_RETCODE_PRECONDITION_NOT_MET",
"DDS_RETCODE_OUT_OF_RESOURCES",
"DDS_RETCODE_NOT_ENABLED",
"DDS_RETCODE_IMMUTABLE_POLICY",
"DDS_RETCODE_INCONSISTENT_POLICY",
"DDS_RETCODE_ALREADY_DELETED",
"DDS_RETCODE_TIMEOUT",
"DDS_RETCODE_NO_DATA",
"DDS_RETCODE_ILLEGAL_OPERATION" };
/**
* Returns the name of an error code.
**/
char *getErrorName(DDS::ReturnCode_t status)
{
return RetCodeName[status];
}
/**
* Check the return status for errors. If there is an error, then terminate.
**/
void checkStatus(
DDS::ReturnCode_t status,
const char *info ) {
if (status != DDS::RETCODE_OK && status != DDS::RETCODE_NO_DATA) {
cerr << "Error in " << info << ": " << getErrorName(status) << endl;
exit (0);
}
}
/**
* Check whether a valid handle has been returned. If not, then terminate.
**/
void checkHandle(
void *handle,
const char *info ) {
if (!handle) {
cerr << "Error in " << info << ": Creation failed: invalid handle" << endl;
exit (0);
}
}