00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef DMRAID_CO_H
00024 #define DMRAID_CO_H
00025
00026 #include <list>
00027
00028 #include "y2storage/DmPartCo.h"
00029 #include "y2storage/Dmraid.h"
00030
00031 namespace storage
00032 {
00033
00034 class Storage;
00035 class SystemCmd;
00036 class ProcPart;
00037 class Region;
00038
00039 class DmraidCo : public DmPartCo
00040 {
00041 friend class Storage;
00042
00043 public:
00044 DmraidCo( Storage * const s, const string& Name, ProcPart& ppart );
00045 DmraidCo( Storage * const s, const string& Name, unsigned num,
00046 unsigned long long Size, ProcPart& ppart );
00047 DmraidCo( const DmraidCo& rhs );
00048 virtual ~DmraidCo();
00049
00050 static storage::CType staticType() { return storage::DMRAID; }
00051 friend std::ostream& operator<< (std::ostream&, const DmraidCo& );
00052 void getInfo( storage::DmraidCoInfo& info ) const;
00053 void setUdevData(const list<string>& id);
00054
00055 bool equalContent( const Container& rhs ) const;
00056 string getDiffString( const Container& d ) const;
00057 DmraidCo& operator= ( const DmraidCo& rhs );
00058
00059 protected:
00060
00061
00062
00063 typedef CastIterator<VIter, Dmraid *> DmraidInter;
00064 typedef CastIterator<CVIter, const Dmraid *> DmraidCInter;
00065 template< class Pred >
00066 struct DmraidPI { typedef ContainerIter<Pred, DmraidInter> type; };
00067 template< class Pred >
00068 struct DmraidCPI { typedef ContainerIter<Pred, DmraidCInter> type; };
00069 typedef CheckFnc<const Dmraid> CheckFncDmraid;
00070 typedef CheckerIterator< CheckFncDmraid, DmraidPI<CheckFncDmraid>::type,
00071 DmraidInter, Dmraid > DmraidPIterator;
00072 typedef CheckerIterator< CheckFncDmraid, DmraidCPI<CheckFncDmraid>::type,
00073 DmraidCInter, const Dmraid > DmraidCPIterator;
00074 typedef DerefIterator<DmraidPIterator,Dmraid> DmraidIter;
00075 typedef DerefIterator<DmraidCPIterator,const Dmraid> ConstDmraidIter;
00076 typedef IterPair<DmraidIter> DmraidPair;
00077 typedef IterPair<ConstDmraidIter> ConstDmraidPair;
00078
00079 DmraidPair dmraidPair( bool (* CheckDmraid)( const Dmraid& )=NULL)
00080 {
00081 return( DmraidPair( dmraidBegin( CheckDmraid ), dmraidEnd( CheckDmraid ) ));
00082 }
00083 DmraidIter dmraidBegin( bool (* CheckDmraid)( const Dmraid& )=NULL)
00084 {
00085 IterPair<DmraidInter> p( (DmraidInter(begin())), (DmraidInter(end())) );
00086 return( DmraidIter( DmraidPIterator( p, CheckDmraid )) );
00087 }
00088 DmraidIter dmraidEnd( bool (* CheckDmraid)( const Dmraid& )=NULL)
00089 {
00090 IterPair<DmraidInter> p( (DmraidInter(begin())), (DmraidInter(end())) );
00091 return( DmraidIter( DmraidPIterator( p, CheckDmraid, true )) );
00092 }
00093
00094 ConstDmraidPair dmraidPair( bool (* CheckDmraid)( const Dmraid& )=NULL) const
00095 {
00096 return( ConstDmraidPair( dmraidBegin( CheckDmraid ), dmraidEnd( CheckDmraid ) ));
00097 }
00098 ConstDmraidIter dmraidBegin( bool (* CheckDmraid)( const Dmraid& )=NULL) const
00099 {
00100 IterPair<DmraidCInter> p( (DmraidCInter(begin())), (DmraidCInter(end())) );
00101 return( ConstDmraidIter( DmraidCPIterator( p, CheckDmraid )) );
00102 }
00103 ConstDmraidIter dmraidEnd( bool (* CheckDmraid)( const Dmraid& )=NULL) const
00104 {
00105 IterPair<DmraidCInter> p( (DmraidCInter(begin())), (DmraidCInter(end())) );
00106 return( ConstDmraidIter( DmraidCPIterator( p, CheckDmraid, true )) );
00107 }
00108
00109 DmraidCo( Storage * const s, const string& File );
00110 virtual void print( std::ostream& s ) const { s << *this; }
00111 virtual Container* getCopy() const { return( new DmraidCo( *this ) ); }
00112 static void activate( bool val );
00113 void getRaidData( const string& name );
00114 void addRaid( const string& name );
00115 void addPv( Pv*& p );
00116 void newP( DmPart*& dm, unsigned num, Partition* p );
00117 string removeText( bool doing ) const;
00118 string setDiskLabelText( bool doing ) const;
00119
00120 static string undevName( const string& name );
00121
00122 static bool isActivated(const string& name);
00123 static list<string> getRaids();
00124
00125 static bool raidNotDeleted( const Dmraid&d ) { return( !d.deleted() ); }
00126
00127 int doRemove();
00128
00129 void logData( const string& Dir );
00130
00131 string raidtype;
00132 string controller;
00133
00134 static bool active;
00135 };
00136
00137 }
00138
00139 #endif