MdCo.h

Go to the documentation of this file.
00001 #ifndef MD_CO_H
00002 #define MD_CO_H
00003 
00004 #include "y2storage/Container.h"
00005 #include "y2storage/Md.h"
00006 
00007 namespace storage
00008 {
00009 
00010 class EtcRaidtab;
00011 
00012 class MdCo : public Container
00013     {
00014     friend class Storage;
00015 
00016     public:
00017         MdCo( Storage * const s, bool detect );
00018         MdCo( const MdCo& rhs );
00019 
00020         virtual ~MdCo();
00021         static storage::CType const staticType() { return storage::MD; }
00022         friend std::ostream& operator<< (std::ostream&, const MdCo& );
00023 
00024         int createMd( unsigned num, storage::MdType type, 
00025                       const std::list<string>& devs );
00026         int removeMd( unsigned num, bool destroySb=true );
00027         int extendMd( unsigned num, const string& dev );
00028         int shrinkMd( unsigned num, const string& dev );
00029         int changeMdType( unsigned num, storage::MdType ptype );
00030         int changeMdChunk( unsigned num, unsigned long chunk );
00031         int changeMdParity( unsigned num, storage::MdParity ptype );
00032         int checkMd( unsigned num );
00033         bool equalContent( const MdCo& rhs ) const;
00034         void logDifference( const MdCo& d ) const;
00035 
00036         unsigned unusedNumber();
00037         void syncRaidtab();
00038 
00039 
00040         static void activate( bool val=true );
00041         int removeVolume( Volume* v );
00042         
00043     protected:
00044         // iterators over MD volumes
00045         // protected typedefs for iterators over MD volumes
00046         typedef CastIterator<VIter, Md *> MdInter;
00047         typedef CastIterator<CVIter, const Md *> MdCInter;
00048         template< class Pred >
00049             struct MdPI { typedef ContainerIter<Pred, MdInter> type; };
00050         template< class Pred >
00051             struct MdCPI { typedef ContainerIter<Pred, MdCInter> type; };
00052         typedef CheckFnc<const Md> CheckFncMd;
00053         typedef CheckerIterator< CheckFncMd, MdPI<CheckFncMd>::type,
00054                                  MdInter, Md > MdPIterator;
00055         typedef CheckerIterator< CheckFncMd, MdCPI<CheckFncMd>::type,
00056                                  MdCInter, const Md > MdCPIterator;
00057         typedef DerefIterator<MdPIterator,Md> MdIter;
00058         typedef DerefIterator<MdCPIterator,const Md> ConstMdIter;
00059         typedef IterPair<MdIter> MdPair;
00060         typedef IterPair<ConstMdIter> ConstMdPair;
00061 
00062         MdPair mdPair( bool (* Check)( const Md& )=NULL)
00063             {
00064             return( MdPair( mdBegin( Check ), mdEnd( Check ) ));
00065             }
00066         MdIter mdBegin( bool (* Check)( const Md& )=NULL)
00067             {
00068             IterPair<MdInter> p( (MdInter(begin())), (MdInter(end())) );
00069             return( MdIter( MdPIterator( p, Check )) );
00070             }
00071         MdIter mdEnd( bool (* Check)( const Md& )=NULL)
00072             {
00073             IterPair<MdInter> p( (MdInter(begin())), (MdInter(end())) );
00074             return( MdIter( MdPIterator( p, Check, true )) );
00075             }
00076 
00077         ConstMdPair mdPair( bool (* Check)( const Md& )=NULL) const
00078             {
00079             return( ConstMdPair( mdBegin( Check ), mdEnd( Check ) ));
00080             }
00081         ConstMdIter mdBegin( bool (* Check)( const Md& )=NULL) const
00082             {
00083             IterPair<MdCInter> p( (MdCInter(begin())), (MdCInter(end())) );
00084             return( ConstMdIter( MdCPIterator( p, Check )) );
00085             }
00086         ConstMdIter mdEnd( bool (* Check)( const Md& )=NULL) const
00087             {
00088             IterPair<MdCInter> p( (MdCInter(begin())), (MdCInter(end())) );
00089             return( ConstMdIter( MdCPIterator( p, Check, true )) );
00090             }
00091 
00092         MdCo( Storage * const s, const string& File );
00093 
00094         void getMdData();
00095         void getMdData( unsigned num );
00096         bool findMd( unsigned num, MdIter& i );
00097         bool findMd( unsigned num ); 
00098         bool findMd( const string& dev, MdIter& i );
00099         bool findMd( const string& dev ); 
00100         int checkUse( const string& dev );
00101         void addMd( Md* m );
00102         void checkMd( Md* m );
00103         void updateEntry( const Md* m );
00104         void initTab();
00105 
00106         void init();
00107 
00108         virtual void print( std::ostream& s ) const { s << *this; }
00109         virtual Container* getCopy() const { return( new MdCo( *this ) ); }
00110 
00111         int doCreate( Volume* v );
00112         int doRemove( Volume* v );
00113 
00114         void logData( const string& Dir );
00115 
00116         EtcRaidtab *tab;
00117 
00118         static bool active;
00119     };
00120 
00121 }
00122 
00123 #endif

Generated on Thu Jul 6 00:40:24 2006 for yast2-storage by  doxygen 1.4.6