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