00001 #ifndef OUTPUT_PROCESSOR_H 00002 #define OUTPUT_PROCESSOR_H 00003 00004 #include "y2storage/StorageInterface.h" 00005 00006 namespace storage 00007 { 00008 00009 class OutputProcessor 00010 { 00011 public: 00012 OutputProcessor() {} 00013 virtual ~OutputProcessor() {} 00014 virtual void reset() {} 00015 virtual void finished() {} 00016 virtual void process( const string& txt, bool stderr ); 00017 }; 00018 00019 class ScrollBarHandler : public OutputProcessor 00020 { 00021 public: 00022 ScrollBarHandler( const string& sid, storage::CallbackProgressBar cb ) 00023 { id=sid; first=true; callback=cb; cur=0; max=100; } 00024 virtual ~ScrollBarHandler() {} 00025 virtual void reset() { first=true; cur=0; } 00026 virtual void finished() { setCurValue( max ); } 00027 virtual void process( const string& txt, bool stderr ); 00028 void setMaxValue( unsigned val ) { max=val; } 00029 unsigned getMaxValue() { return( max ); } 00030 void setCurValue( unsigned val ); 00031 unsigned getCurValue() { return( cur ); } 00032 00033 protected: 00034 unsigned long max; 00035 unsigned long cur; 00036 bool first; 00037 string id; 00038 storage::CallbackProgressBar callback; 00039 }; 00040 00041 class Mke2fsScrollbar : public ScrollBarHandler 00042 { 00043 public: 00044 Mke2fsScrollbar( storage::CallbackProgressBar cb ) : 00045 ScrollBarHandler( "format", cb ) { done=false; } 00046 virtual void process( const string& txt, bool stderr ); 00047 protected: 00048 string seen; 00049 bool done; 00050 }; 00051 00052 class ReiserScrollbar : public ScrollBarHandler 00053 { 00054 public: 00055 ReiserScrollbar( storage::CallbackProgressBar cb ) : 00056 ScrollBarHandler( "format", cb ) { max=100; } 00057 virtual void process( const string& txt, bool stderr ); 00058 protected: 00059 string seen; 00060 }; 00061 00062 class DasdfmtScrollbar : public ScrollBarHandler 00063 { 00064 public: 00065 DasdfmtScrollbar( storage::CallbackProgressBar cb ) : 00066 ScrollBarHandler( "dasdfmt", cb ) { max=100; max_cyl=cur_cyl=0; } 00067 virtual void process( const string& txt, bool stderr ); 00068 protected: 00069 string seen; 00070 unsigned long cur_cyl; 00071 unsigned long max_cyl; 00072 }; 00073 00074 } 00075 00076 #endif