check_status.cpp
Go to the documentation of this file.
00001 /*
00002  *                         OpenSplice DDS
00003  *
00004  *   This software and documentation are Copyright 2006 to 2013 PrismTech
00005  *   Limited and its licensees. All rights reserved. See file:
00006  *
00007  *                     $OSPL_HOME/LICENSE
00008  *
00009  *   for full copyright notice and license terms.
00010  *
00011  */
00012 
00013 /************************************************************************
00014  * LOGICAL_NAME:    CheckStatus.cpp
00015  * FUNCTION:        OpenSplice NetworkPartitions example code.
00016  * MODULE:          NetworkPartitions example for the C++ programming language.
00017  * DATE             june 2007.
00018  ************************************************************************
00019  *
00020  * This file contains the implementation for the error handling operations.
00021  *
00022  ***/
00023 
00024 #include "opensplice_dds_comm/check_status.h"
00025 
00026 /* Array to hold the names for all ReturnCodes. */
00027 const char *RetCodeName[13] = {
00028     "DDS_RETCODE_OK",
00029     "DDS_RETCODE_ERROR",
00030     "DDS_RETCODE_UNSUPPORTED",
00031     "DDS_RETCODE_BAD_PARAMETER",
00032     "DDS_RETCODE_PRECONDITION_NOT_MET",
00033     "DDS_RETCODE_OUT_OF_RESOURCES",
00034     "DDS_RETCODE_NOT_ENABLED",
00035     "DDS_RETCODE_IMMUTABLE_POLICY",
00036     "DDS_RETCODE_INCONSISTENT_POLICY",
00037     "DDS_RETCODE_ALREADY_DELETED",
00038     "DDS_RETCODE_TIMEOUT",
00039     "DDS_RETCODE_NO_DATA",
00040     "DDS_RETCODE_ILLEGAL_OPERATION" };
00041 
00045 const char *getErrorName(DDS::ReturnCode_t status)
00046 {
00047     return RetCodeName[status];
00048 }
00049 
00053 void checkStatus(
00054     DDS::ReturnCode_t status,
00055     const char *info ) {
00056 
00057     if (status != DDS::RETCODE_OK && status != DDS::RETCODE_NO_DATA) {
00058         cerr << "Error in " << info << ": " << getErrorName(status) << endl;
00059         exit (1);
00060     }
00061 }
00062 
00066 void checkHandle(
00067     void *handle,
00068     const char *info ) {
00069 
00070      if (!handle) {
00071         cerr << "Error in " << info << ": Creation failed: invalid handle" << endl;
00072         exit (1);
00073      }
00074 }


opensplice_dds_comm
Author(s):
autogenerated on Sat May 27 2017 02:42:59