DmCo.h

Go to the documentation of this file.
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         void updateDmMaps();
00024 
00025         int removeDm( const string& table );
00026         int removeVolume( Volume* v );
00027         
00028     protected:
00029         // iterators over DM volumes
00030         // protected typedefs for iterators over DM volumes
00031         typedef CastIterator<VIter, Dm *> DmInter;
00032         typedef CastIterator<CVIter, const Dm *> DmCInter;
00033         template< class Pred >
00034             struct DmPI { typedef ContainerIter<Pred, DmInter> type; };
00035         template< class Pred >
00036             struct DmCPI { typedef ContainerIter<Pred, DmCInter> type; };
00037         typedef CheckFnc<const Dm> CheckFncDm;
00038         typedef CheckerIterator< CheckFncDm, DmPI<CheckFncDm>::type,
00039                                  DmInter, Dm > DmPIterator;
00040         typedef CheckerIterator< CheckFncDm, DmCPI<CheckFncDm>::type,
00041                                  DmCInter, const Dm > DmCPIterator;
00042         typedef DerefIterator<DmPIterator,Dm> DmIter;
00043         typedef DerefIterator<DmCPIterator,const Dm> ConstDmIter;
00044         typedef IterPair<DmIter> DmPair;
00045         typedef IterPair<ConstDmIter> ConstDmPair;
00046 
00047         DmPair dmPair( bool (* Check)( const Dm& )=NULL)
00048             {
00049             return( DmPair( dmBegin( Check ), dmEnd( Check ) ));
00050             }
00051         DmIter dmBegin( bool (* Check)( const Dm& )=NULL)
00052             {
00053             IterPair<DmInter> p( (DmInter(begin())), (DmInter(end())) );
00054             return( DmIter( DmPIterator( p, Check )) );
00055             }
00056         DmIter dmEnd( bool (* Check)( const Dm& )=NULL)
00057             {
00058             IterPair<DmInter> p( (DmInter(begin())), (DmInter(end())) );
00059             return( DmIter( DmPIterator( p, Check, true )) );
00060             }
00061 
00062         ConstDmPair dmPair( bool (* Check)( const Dm& )=NULL) const
00063             {
00064             return( ConstDmPair( dmBegin( Check ), dmEnd( Check ) ));
00065             }
00066         ConstDmIter dmBegin( bool (* Check)( const Dm& )=NULL) const
00067             {
00068             IterPair<DmCInter> p( (DmCInter(begin())), (DmCInter(end())) );
00069             return( ConstDmIter( DmCPIterator( p, Check )) );
00070             }
00071         ConstDmIter dmEnd( bool (* Check)( const Dm& )=NULL) const
00072             {
00073             IterPair<DmCInter> p( (DmCInter(begin())), (DmCInter(end())) );
00074             return( ConstDmIter( DmCPIterator( p, Check, true )) );
00075             }
00076 
00077         DmCo( Storage * const s, const string& File );
00078 
00079         void getDmData( ProcPart& ppart );
00080         void getDmData( unsigned num );
00081         bool findDm( unsigned num, DmIter& i );
00082         bool findDm( unsigned num ); 
00083         bool findDm( const string& dev, DmIter& i );
00084         bool findDm( const string& dev ); 
00085         void addDm( Dm* m );
00086         void checkDm( Dm* m );
00087         void updateEntry( const Dm* m );
00088         virtual Container* getCopy() const { return( new DmCo( *this ) ); }
00089 
00090         void init();
00091 
00092         virtual void print( std::ostream& s ) const { s << *this; }
00093 
00094         int doRemove( Volume* v );
00095 
00096         void logData( const string& Dir );
00097     };
00098 
00099 }
00100 
00101 #endif

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