CheckedResult.h

Go to the documentation of this file.
00001 /*
00002  *  BEEN: Benchmarking Environment
00003  *  ==============================
00004  *
00005  *  File author: Branislav Repcek
00006  *
00007  *  GNU Lesser General Public License Version 2.1
00008  *  ---------------------------------------------
00009  *  Copyright (C) 2004-2006 Distributed Systems Research Group,
00010  *  Faculty of Mathematics and Physics, Charles University in Prague
00011  *
00012  *  This library is free software; you can redistribute it and/or
00013  *  modify it under the terms of the GNU Lesser General Public
00014  *  License version 2.1, as published by the Free Software Foundation.
00015  *
00016  *  This library is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *  Lesser General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU Lesser General Public
00022  *  License along with this library; if not, write to the Free Software
00023  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024  *  MA  02111-1307  USA
00025  */
00026 
00034 #ifndef CHECKED_RESULT_INCLUDED
00035 #define CHECKED_RESULT_INCLUDED
00036 
00037 namespace hwdet
00038 {
00039 
00045     template< typename T >
00046     class CheckedResult
00047     {
00048     public:
00054         CheckedResult(bool call_success, const T &retval) :
00055         successfull(call_success),
00056         value(retval)
00057         {
00058         }
00059 
00066         CheckedResult(bool call_success = false) :
00067         successfull(call_success)
00068         {
00069         }
00070 
00075         CheckedResult(const CheckedResult &r1) :
00076         successfull(r1.successfull),
00077         value(r1.value)
00078         {
00079         }
00080 
00083         ~CheckedResult(void)
00084         {
00085         }
00086 
00091         bool Succeeded(void) const
00092         {
00093             return successfull;
00094         }
00095 
00100         bool Failed(void) const
00101         {
00102             return !successfull;
00103         }
00104 
00109         T &GetValue(void) const
00110         {
00111             return (T &) value;
00112         }
00113 
00114     private:
00116         bool successfull;
00117 
00119         T    value;
00120     };
00121 }
00122 
00123 #endif

Generated on Tue Dec 19 17:43:52 2006 for Detector for Windows by  doxygen 1.4.7