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


proxy_common
Author(s): Ronny Hartanto
autogenerated on Mon Oct 6 2014 06:54:18