00001 #ifndef DM_CO_H
00002 #define DM_CO_H
00003
00004 #include "y2storage/PeContainer.h"
00005 #include "y2storage/Dm.h"
00006
00007 class DmCo : public PeContainer
00008 {
00009 friend class Storage;
00010
00011 public:
00012 DmCo( Storage * const s, bool detect );
00013 DmCo( const DmCo& rhs );
00014 virtual ~DmCo();
00015 static storage::CType const staticType() { return storage::DM; }
00016 friend std::ostream& operator<< (std::ostream&, const DmCo& );
00017 bool equalContent( const DmCo& rhs ) const;
00018 void logDifference( const DmCo& d ) const;
00019
00020 int removeDm( const string& table );
00021 int removeVolume( Volume* v );
00022
00023 protected:
00024
00025
00026 typedef CastIterator<VIter, Dm *> DmInter;
00027 typedef CastIterator<CVIter, const Dm *> DmCInter;
00028 template< class Pred >
00029 struct DmPI { typedef ContainerIter<Pred, DmInter> type; };
00030 template< class Pred >
00031 struct DmCPI { typedef ContainerIter<Pred, DmCInter> type; };
00032 typedef CheckFnc<const Dm> CheckFncDm;
00033 typedef CheckerIterator< CheckFncDm, DmPI<CheckFncDm>::type,
00034 DmInter, Dm > DmPIterator;
00035 typedef CheckerIterator< CheckFncDm, DmCPI<CheckFncDm>::type,
00036 DmCInter, const Dm > DmCPIterator;
00037 typedef DerefIterator<DmPIterator,Dm> DmIter;
00038 typedef DerefIterator<DmCPIterator,const Dm> ConstDmIter;
00039 typedef IterPair<DmIter> DmPair;
00040 typedef IterPair<ConstDmIter> ConstDmPair;
00041
00042 DmPair dmPair( bool (* Check)( const Dm& )=NULL)
00043 {
00044 return( DmPair( dmBegin( Check ), dmEnd( Check ) ));
00045 }
00046 DmIter dmBegin( bool (* Check)( const Dm& )=NULL)
00047 {
00048 IterPair<DmInter> p( (DmInter(begin())), (DmInter(end())) );
00049 return( DmIter( DmPIterator( p, Check )) );
00050 }
00051 DmIter dmEnd( bool (* Check)( const Dm& )=NULL)
00052 {
00053 IterPair<DmInter> p( (DmInter(begin())), (DmInter(end())) );
00054 return( DmIter( DmPIterator( p, Check, true )) );
00055 }
00056
00057 ConstDmPair dmPair( bool (* Check)( const Dm& )=NULL) const
00058 {
00059 return( ConstDmPair( dmBegin( Check ), dmEnd( Check ) ));
00060 }
00061 ConstDmIter dmBegin( bool (* Check)( const Dm& )=NULL) const
00062 {
00063 IterPair<DmCInter> p( (DmCInter(begin())), (DmCInter(end())) );
00064 return( ConstDmIter( DmCPIterator( p, Check )) );
00065 }
00066 ConstDmIter dmEnd( bool (* Check)( const Dm& )=NULL) const
00067 {
00068 IterPair<DmCInter> p( (DmCInter(begin())), (DmCInter(end())) );
00069 return( ConstDmIter( DmCPIterator( p, Check, true )) );
00070 }
00071
00072 DmCo( Storage * const s, const string& File );
00073
00074 void getDmData();
00075 void getDmData( unsigned num );
00076 bool findDm( unsigned num, DmIter& i );
00077 bool findDm( unsigned num );
00078 bool findDm( const string& dev, DmIter& i );
00079 bool findDm( const string& dev );
00080 void addDm( Dm* m );
00081 void checkDm( Dm* m );
00082 void updateEntry( const Dm* m );
00083
00084 void init();
00085
00086 virtual void print( std::ostream& s ) const { s << *this; }
00087
00088 int doRemove( Volume* v );
00089
00090 void logData( const string& Dir );
00091 };
00092
00093 #endif