CVR-Lib last update 20 Sep 2009

cvrProgressInfo.h

Go to the documentation of this file.
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   cvrProgressInfo.h
00043  *         Contains the class progressInfo, base class for progress information
00044  * \author Pablo Alvarado
00045  * \author Peter Doerfler
00046  * \date   10.08.2000
00047  *
00048  * $Id: cvrProgressInfo.h,v 1.2 2005/07/22 15:59:17 doerfler Exp $
00049  */
00050 
00051 #ifndef _CVR_PROGRESS_INFO_H_
00052 #define _CVR_PROGRESS_INFO_H_
00053 
00054 #include <string>
00055 
00056 #include "cvrObject.h"
00057 
00058 namespace cvr {
00059 
00060   /**
00061    * This class can be overloaded to display the training progress of
00062    * a process. It is mostly used for classifiers, where training can
00063    * take a long time.
00064    */
00065   class progressInfo : public object {
00066   public:
00067     /**
00068      * Default constructor.
00069      *
00070      * The default are empty title and 100 maximum steps. These are
00071      * rarely the correct settings. For informative progress
00072      * information set these values either with the constructor or the
00073      * setMaximumSteps() and setTitle() functions.
00074      *
00075      * @param title the name of the progressInfo object
00076      * @param maximumSteps the maximum number of steps of the process
00077      */
00078     progressInfo(const std::string& title = "",
00079                  const int maximumSteps = 100);
00080 
00081     /**
00082      * Copy constructor
00083      */
00084     progressInfo(const progressInfo& other);
00085 
00086     /**
00087      * Destructor
00088      */
00089     virtual ~progressInfo();
00090 
00091     /**
00092      * Set the title of the progress info block
00093      */
00094     virtual void setTitle(const std::string& theTitle);
00095 
00096     /**
00097      * Maximal number of steps
00098      */
00099     virtual void setMaxSteps(const int maximalSteps);
00100 
00101     /**
00102      * Detail level of substep information. Level 1 is equal to that
00103      * of normal steps.
00104      */
00105     virtual void setDetailLevel(const int level);
00106 
00107     /**
00108      * Return the used detail level of substep information
00109      */
00110     virtual int getDetailLevel() const;
00111 
00112     /**
00113      * Report one step done
00114      * @param progressInfo string with some text information for the step
00115      */
00116     virtual void step(const std::string& progressInfo)=0;
00117 
00118     /**
00119      * Report additional information for a step, with the given detail
00120      * level.
00121      *
00122      * The given information will be displayed only if the current detail level
00123      * is higher or equal than the detail specified in this method.
00124      *
00125      * @param detail is the detail level. The lowest (as in step()) is 1.
00126      * @param info the string displayed for the substep
00127      */
00128     virtual void substep(const int detail,
00129                          const std::string& info)=0;
00130 
00131     /**
00132      * Reset progress information
00133      */
00134     virtual void reset();
00135 
00136     /**
00137      * Returns true if someone wants the caller of this progress info
00138      * object to terminate. This function is mostly useful for GUI
00139      * progressInfo implementations.
00140      *
00141      * This default implementation always returns false.
00142      */
00143     virtual bool breakRequested() const;
00144 
00145     /**
00146      * The copy member
00147      */
00148     progressInfo& copy(const progressInfo& other);
00149 
00150     /**
00151      * Returns the name of the class.
00152      */
00153     const std::string& name() const;
00154 
00155     /**
00156      * The clone member
00157      */
00158     virtual progressInfo* clone() const=0;
00159 
00160     /**
00161      * The new instance member
00162      */
00163     virtual progressInfo* newInstance() const=0;
00164 
00165   protected:
00166     /**
00167      * Title for this progress info
00168      */
00169     std::string title_;
00170 
00171     /**
00172      * Maximum number of steps expected
00173      */
00174     int maxSteps_;
00175 
00176     /**
00177      * Detail level used for the substeps
00178      */
00179     int detailLevel_;
00180 
00181     /**
00182      * Last processed step
00183      */
00184     int lastStep_;
00185 
00186   };
00187 
00188 
00189 }
00190 
00191 #endif
00192 

Generated on Sun Sep 20 22:08:00 2009 for CVR-Lib by Doxygen 1.5.8