00001 /* 00002 * Copyright (c) [2004-2009] Novell, Inc. 00003 * 00004 * All Rights Reserved. 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of version 2 of the GNU General Public License as published 00008 * by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 * more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, contact Novell, Inc. 00017 * 00018 * To contact Novell about this file by physical or electronic mail, you may 00019 * find current contact information at www.novell.com. 00020 */ 00021 00022 00023 #ifndef OUTPUT_PROCESSOR_H 00024 #define OUTPUT_PROCESSOR_H 00025 00026 #include "y2storage/StorageInterface.h" 00027 00028 namespace storage 00029 { 00030 00031 class OutputProcessor 00032 { 00033 public: 00034 OutputProcessor() {} 00035 virtual ~OutputProcessor() {} 00036 virtual void reset() {} 00037 virtual void finished() {} 00038 virtual void process( const string& txt, bool stderr ); 00039 }; 00040 00041 class ScrollBarHandler : public OutputProcessor 00042 { 00043 public: 00044 ScrollBarHandler( const string& sid, storage::CallbackProgressBar cb ) 00045 { id=sid; first=true; callback=cb; cur=0; max=100; } 00046 virtual ~ScrollBarHandler() {} 00047 virtual void reset() { first=true; cur=0; } 00048 virtual void finished() { setCurValue( max ); } 00049 virtual void process( const string& txt, bool stderr ); 00050 void setMaxValue( unsigned val ) { max=val; } 00051 unsigned getMaxValue() { return( max ); } 00052 void setCurValue( unsigned val ); 00053 unsigned getCurValue() { return( cur ); } 00054 00055 protected: 00056 unsigned long max; 00057 unsigned long cur; 00058 bool first; 00059 string id; 00060 storage::CallbackProgressBar callback; 00061 }; 00062 00063 class Mke2fsScrollbar : public ScrollBarHandler 00064 { 00065 public: 00066 Mke2fsScrollbar( storage::CallbackProgressBar cb ) : 00067 ScrollBarHandler( "format", cb ) { done=false; } 00068 virtual void process( const string& txt, bool stderr ); 00069 protected: 00070 string seen; 00071 bool done; 00072 }; 00073 00074 class ReiserScrollbar : public ScrollBarHandler 00075 { 00076 public: 00077 ReiserScrollbar( storage::CallbackProgressBar cb ) : 00078 ScrollBarHandler( "format", cb ) { max=100; } 00079 virtual void process( const string& txt, bool stderr ); 00080 protected: 00081 string seen; 00082 }; 00083 00084 class DasdfmtScrollbar : public ScrollBarHandler 00085 { 00086 public: 00087 DasdfmtScrollbar( storage::CallbackProgressBar cb ) : 00088 ScrollBarHandler( "dasdfmt", cb ) { max=100; max_cyl=cur_cyl=0; } 00089 virtual void process( const string& txt, bool stderr ); 00090 protected: 00091 string seen; 00092 unsigned long cur_cyl; 00093 unsigned long max_cyl; 00094 }; 00095 00096 } 00097 00098 #endif
1.5.6