Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

Generated on Wed Sep 14 11:27:07 2005 for yast2-storage by  doxygen 1.4.4