itom 1.4.0
|
00001 /* ******************************************************************** 00002 itom software 00003 URL: http://www.uni-stuttgart.de/ito 00004 Copyright (C) 2013, Institut für Technische Optik (ITO), 00005 Universität 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 für 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 //---------------------------------------------------------------------------------------------------------------------------------- 00053 class ITOMCOMMON_EXPORT RetVal 00054 { 00055 private: 00056 tRetValue m_retValue; 00057 int m_retCode; 00058 ByteArray m_retMessage; 00059 00060 public: 00061 inline RetVal() : m_retValue(ito::retOk), m_retCode(0) {} 00062 00063 RetVal(tRetValue retValue) : m_retValue(retValue), m_retCode(0) {} 00064 00065 RetVal(int retValue) : m_retValue((tRetValue)retValue), m_retCode(0) {} 00066 00067 //RetVal(tRetValue retValue, int retCode, char *pRetMessage) 00075 RetVal(ito::tRetValue retValue, int retCode, const char *pRetMessage); 00076 00077 inline ~RetVal() {} 00078 00079 //RetVal & operator = (const RetVal &rhs); 00083 RetVal &operator=(const RetVal &rhs); 00084 00085 00086 //---------------------------------------------------------------------------------------------------------------------------------- 00092 RetVal & operator += (const RetVal &rhs); 00093 00094 //---------------------------------------------------------------------------------------------------------------------------------- 00099 RetVal operator + (const RetVal &rhs) 00100 { 00101 return (*this += rhs); 00102 } 00103 00104 //---------------------------------------------------------------------------------------------------------------------------------- 00108 inline char operator == (const RetVal &rhs) 00109 { 00110 return m_retValue == rhs.m_retValue; 00111 } 00112 00113 //---------------------------------------------------------------------------------------------------------------------------------- 00117 inline char operator != (const RetVal &rhs) 00118 { 00119 return !(m_retValue == rhs.m_retValue); 00120 } 00121 00122 //---------------------------------------------------------------------------------------------------------------------------------- 00126 inline char operator == (const tRetValue rhs) 00127 { 00128 return m_retValue == rhs; 00129 } 00130 00131 //---------------------------------------------------------------------------------------------------------------------------------- 00135 inline char operator != (const tRetValue rhs) 00136 { 00137 return !(m_retValue == rhs); 00138 } 00139 00140 //---------------------------------------------------------------------------------------------------------------------------------- 00141 void appendRetMessage(const char *addRetMessage); 00142 00143 //---------------------------------------------------------------------------------------------------------------------------------- 00144 inline int containsWarning() const { return (m_retValue & retWarning); } 00145 inline int containsError() const { return (m_retValue & retError); } 00146 inline int containsWarningOrError() const { return (m_retValue & (retError | retWarning)); } 00148 inline bool hasErrorMessage() const { return m_retMessage.size() > 0; } 00149 00150 inline int errorCode() const { return m_retCode; } 00151 00152 inline const char *errorMessage() const { return m_retMessage.data(); } 00154 //---------------------------------------------------------------------------------------------------------------------------------- 00155 static RetVal format(ito::tRetValue retValue, int retCode, const char *pRetMessage, ...); 00156 00157 }; 00158 00159 00160 } //end namespace ito 00161 00162 #ifdef __APPLE__ 00163 } 00164 #endif 00165 00166 #endif