itom 2.2.1
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2016, Institut fuer Technische Optik (ITO), 00005 Universitaet Stuttgart, Germany 00006 00007 This file is part of itom and its software development toolkit (SDK). 00008 00009 itom is free software; you can redistribute it and/or modify it 00010 under the terms of the GNU Library General Public Licence as published by 00011 the Free Software Foundation; either version 2 of the Licence, or (at 00012 your option) any later version. 00013 00014 In addition, as a special exception, the Institut fuer Technische 00015 Optik (ITO) gives you certain additional rights. 00016 These rights are described in the ITO LGPL Exception version 1.0, 00017 which can be found in the file LGPL_EXCEPTION.txt in this package. 00018 00019 itom is distributed in the hope that it will be useful, but 00020 WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library 00022 General Public Licence for more details. 00023 00024 You should have received a copy of the GNU Library General Public License 00025 along with itom. If not, see <http://www.gnu.org/licenses/>. 00026 *********************************************************************** */ 00027 00028 #ifndef RETVAL_H 00029 #define RETVAL_H 00030 00031 #ifdef __APPLE__ 00032 extern "C++" { 00033 #endif 00034 00035 /* includes */ 00036 #include "commonGlobal.h" 00037 #include "typeDefs.h" 00038 #include "byteArray.h" 00039 00040 #include <stdarg.h> 00041 00042 namespace ito 00043 { 00044 00045 //---------------------------------------------------------------------------------------------------------------------------------- 00054 class ITOMCOMMON_EXPORT RetVal 00055 { 00056 private: 00057 tRetValue m_retValue; 00058 int m_retCode; 00059 ByteArray m_retMessage; 00061 public: 00063 inline RetVal() : m_retValue(ito::retOk), m_retCode(0) {} 00064 00066 RetVal(tRetValue retValue) : m_retValue(retValue), m_retCode(0) {} 00067 00069 RetVal(int retValue) : m_retValue((tRetValue)retValue), m_retCode(0) {} 00070 00071 //RetVal(tRetValue retValue, int retCode, char *pRetMessage) 00079 RetVal(ito::tRetValue retValue, int retCode, const char *pRetMessage); 00080 00082 inline ~RetVal() {} 00083 00084 //RetVal & operator = (const RetVal &rhs); 00088 RetVal &operator=(const RetVal &rhs); 00089 00090 00091 //---------------------------------------------------------------------------------------------------------------------------------- 00097 RetVal & operator += (const RetVal &rhs); 00098 00099 //---------------------------------------------------------------------------------------------------------------------------------- 00104 RetVal operator + (const RetVal &rhs) 00105 { 00106 return (*this += rhs); 00107 } 00108 00109 //---------------------------------------------------------------------------------------------------------------------------------- 00113 inline char operator == (const RetVal &rhs) 00114 { 00115 return m_retValue == rhs.m_retValue; 00116 } 00117 00118 //---------------------------------------------------------------------------------------------------------------------------------- 00122 inline char operator != (const RetVal &rhs) 00123 { 00124 return !(m_retValue == rhs.m_retValue); 00125 } 00126 00127 //---------------------------------------------------------------------------------------------------------------------------------- 00131 inline char operator == (const tRetValue rhs) 00132 { 00133 return m_retValue == rhs; 00134 } 00135 00136 //---------------------------------------------------------------------------------------------------------------------------------- 00140 inline char operator != (const tRetValue rhs) 00141 { 00142 return !(m_retValue == rhs); 00143 } 00144 00145 //---------------------------------------------------------------------------------------------------------------------------------- 00146 void appendRetMessage(const char *addRetMessage); 00147 00148 //---------------------------------------------------------------------------------------------------------------------------------- 00149 inline int containsWarning() const { return (m_retValue & retWarning); } 00150 inline int containsError() const { return (m_retValue & retError); } 00151 inline int containsWarningOrError() const { return (m_retValue & (retError | retWarning)); } 00153 inline bool hasErrorMessage() const { return m_retMessage.size() > 0; } 00155 inline int errorCode() const { return m_retCode; } 00157 inline const char *errorMessage() const { return m_retMessage.data(); } 00159 //---------------------------------------------------------------------------------------------------------------------------------- 00161 00168 static RetVal format(ito::tRetValue retValue, int retCode, const char *pRetMessage, ...); 00169 00170 }; 00171 00172 00173 } //end namespace ito 00174 00175 #ifdef __APPLE__ 00176 } 00177 #endif 00178 00179 #endif