![]() |
last update 20 Sep 2009 |
![]() |
00001 /* 00002 * Copyright (C) 1998 - 2005 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * 00006 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00007 * 00008 * The CVR-Lib is free software; you can redistribute it and/or 00009 * modify it under the terms of the BSD License. 00010 * 00011 * All rights reserved. 00012 * 00013 * Redistribution and use in source and binary forms, with or without 00014 * modification, are permitted provided that the following conditions are met: 00015 * 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 00023 * 3. Neither the name of the authors nor the names of its contributors may be 00024 * used to endorse or promote products derived from this software without 00025 * specific prior written permission. 00026 * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00028 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00029 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00030 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00031 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00032 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00033 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00034 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00035 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00036 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00037 * POSSIBILITY OF SUCH DAMAGE. 00038 */ 00039 00040 00041 /** 00042 * \file cvrStreamProgressInfo.h 00043 * Contains the class streamProgressInfo, which prints 00044 * progress information to a string 00045 * \author Pablo Alvarado 00046 * \author Peter Doerfler 00047 * \date 10.08.2000 00048 * 00049 * $Id: cvrStreamProgressInfo.h,v 1.3 2006/09/14 15:14:02 doerfler Exp $ 00050 */ 00051 00052 #ifndef _CVR_STREAM_PROGRESS_INFO_H_ 00053 #define _CVR_STREAM_PROGRESS_INFO_H_ 00054 00055 #include <string> 00056 #include <iostream> 00057 00058 #include "cvrProgressInfo.h" 00059 00060 namespace cvr { 00061 00062 /** 00063 * This class is a default implementation for the progress info 00064 * interface. It dumps the progress information to a std::ostream, 00065 * or std::cout if you do not give one. 00066 */ 00067 class streamProgressInfo : public progressInfo { 00068 public: 00069 /** 00070 * Default constructor 00071 * @param title the name of the progressInfo object 00072 * @param maximumSteps the maximum number of steps of the process 00073 */ 00074 streamProgressInfo(const std::string& title = "", 00075 const int maximumSteps = 100); 00076 00077 /** 00078 * Default constructor 00079 * @param outStream output stream, where the progress information will 00080 * be written. 00081 * @param title the name of the progressInfo object 00082 * @param maximumSteps the maximum number of steps of the process 00083 */ 00084 streamProgressInfo(std::ostream& outStream, 00085 const std::string& title = "", 00086 const int maximumSteps = 100); 00087 00088 00089 /** 00090 * Copy constructor 00091 */ 00092 streamProgressInfo(const streamProgressInfo& other); 00093 00094 /** 00095 * Destructor 00096 */ 00097 virtual ~streamProgressInfo(); 00098 00099 /** 00100 * Set a new stream. The streamProgressInfo keeps a pointer to the 00101 * stream. 00102 */ 00103 virtual void useStream(std::ostream& stream); 00104 00105 /** 00106 * Set the endline string used. The default is "\n". 00107 */ 00108 void setEndline(const std::string& endline); 00109 00110 /** 00111 * Report one step done 00112 * @param progressInfo string with some text information for the step 00113 */ 00114 virtual void step(const std::string& progressInfo); 00115 00116 /** 00117 * Report additional information for a step, with the given detail 00118 * level. 00119 * 00120 * The given information will be displayed only if the current detail level 00121 * is higher or equal than the detail specified in this method. 00122 */ 00123 virtual void substep(const int detail, 00124 const std::string& info); 00125 00126 /** 00127 * The copy member 00128 */ 00129 streamProgressInfo& copy(const streamProgressInfo& other); 00130 00131 /** 00132 * alias for copy 00133 */ 00134 streamProgressInfo& operator=(const streamProgressInfo& other); 00135 00136 /** 00137 * Returns the name of the class 00138 */ 00139 const std::string& name() const; 00140 00141 /** 00142 * The clone member 00143 */ 00144 virtual streamProgressInfo* clone() const; 00145 00146 /** 00147 * The newInstance member 00148 */ 00149 virtual streamProgressInfo* newInstance() const; 00150 00151 protected: 00152 /** 00153 * Stream being used 00154 */ 00155 std::ostream *out_; 00156 00157 /** 00158 * The sequence that is used for end-of-line when emitting 00159 * steps. 00160 */ 00161 std::string endline_; 00162 }; 00163 00164 00165 } 00166 00167 #endif