00001 #ifndef DMMULTIPATH_CO_H
00002 #define DMMULTIPATH_CO_H
00003
00004 #include <list>
00005
00006 #include "y2storage/DmPartCo.h"
00007 #include "y2storage/Dmmultipath.h"
00008
00009 namespace storage
00010 {
00011
00012 class Storage;
00013 class SystemCmd;
00014 class ProcPart;
00015 class Region;
00016
00017 class DmmultipathCo : public DmPartCo
00018 {
00019 friend class Storage;
00020
00021 public:
00022 DmmultipathCo( Storage * const s, const string& Name, ProcPart& ppart );
00023 DmmultipathCo( Storage * const s, const string& Name, unsigned num,
00024 unsigned long long Size, ProcPart& ppart );
00025 DmmultipathCo( const DmmultipathCo& rhs );
00026 virtual ~DmmultipathCo();
00027
00028 static storage::CType staticType() { return storage::DMMULTIPATH; }
00029 friend std::ostream& operator<< (std::ostream&, const DmmultipathCo& );
00030 void getInfo( storage::DmmultipathCoInfo& info ) const;
00031 void setUdevData(const list<string>& id);
00032
00033 bool equalContent( const Container& rhs ) const;
00034 string getDiffString( const Container& d ) const;
00035 DmmultipathCo& operator= ( const DmmultipathCo& rhs );
00036
00037 protected:
00038
00039
00040
00041 typedef CastIterator<VIter, Dmmultipath *> DmmultipathInter;
00042 typedef CastIterator<CVIter, const Dmmultipath *> DmmultipathCInter;
00043 template< class Pred >
00044 struct DmmultipathPI { typedef ContainerIter<Pred, DmmultipathInter> type; };
00045 template< class Pred >
00046 struct DmmultipathCPI { typedef ContainerIter<Pred, DmmultipathCInter> type; };
00047 typedef CheckFnc<const Dmmultipath> CheckFncDmmultipath;
00048 typedef CheckerIterator< CheckFncDmmultipath, DmmultipathPI<CheckFncDmmultipath>::type,
00049 DmmultipathInter, Dmmultipath > DmmultipathPIterator;
00050 typedef CheckerIterator< CheckFncDmmultipath, DmmultipathCPI<CheckFncDmmultipath>::type,
00051 DmmultipathCInter, const Dmmultipath > DmmultipathCPIterator;
00052 typedef DerefIterator<DmmultipathPIterator,Dmmultipath> DmmultipathIter;
00053 typedef DerefIterator<DmmultipathCPIterator,const Dmmultipath> ConstDmmultipathIter;
00054 typedef IterPair<DmmultipathIter> DmmultipathPair;
00055 typedef IterPair<ConstDmmultipathIter> ConstDmmultipathPair;
00056
00057 DmmultipathPair dmmultipathPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00058 {
00059 return( DmmultipathPair( dmmultipathBegin( CheckDmmultipath ), dmmultipathEnd( CheckDmmultipath ) ));
00060 }
00061 DmmultipathIter dmmultipathBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00062 {
00063 IterPair<DmmultipathInter> p( (DmmultipathInter(begin())), (DmmultipathInter(end())) );
00064 return( DmmultipathIter( DmmultipathPIterator( p, CheckDmmultipath )) );
00065 }
00066 DmmultipathIter dmmultipathEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL)
00067 {
00068 IterPair<DmmultipathInter> p( (DmmultipathInter(begin())), (DmmultipathInter(end())) );
00069 return( DmmultipathIter( DmmultipathPIterator( p, CheckDmmultipath, true )) );
00070 }
00071
00072 ConstDmmultipathPair dmmultipathPair( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00073 {
00074 return( ConstDmmultipathPair( dmmultipathBegin( CheckDmmultipath ), dmmultipathEnd( CheckDmmultipath ) ));
00075 }
00076 ConstDmmultipathIter dmmultipathBegin( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00077 {
00078 IterPair<DmmultipathCInter> p( (DmmultipathCInter(begin())), (DmmultipathCInter(end())) );
00079 return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath )) );
00080 }
00081 ConstDmmultipathIter dmmultipathEnd( bool (* CheckDmmultipath)( const Dmmultipath& )=NULL) const
00082 {
00083 IterPair<DmmultipathCInter> p( (DmmultipathCInter(begin())), (DmmultipathCInter(end())) );
00084 return( ConstDmmultipathIter( DmmultipathCPIterator( p, CheckDmmultipath, true )) );
00085 }
00086
00087 DmmultipathCo( Storage * const s, const string& File );
00088 virtual void print( std::ostream& s ) const { s << *this; }
00089 virtual Container* getCopy() const { return( new DmmultipathCo( *this ) ); }
00090 void getMultipathData( const string& name );
00091 void addMultipath( const string& name );
00092 void addPv( Pv*& p );
00093 void newP( DmPart*& dm, unsigned num, Partition* p );
00094 string setDiskLabelText( bool doing ) const;
00095
00096 static string undevName( const string& name );
00097
00098 static void activate( bool val=true );
00099 static bool isActive() { return active; }
00100
00101 static void getMultipaths( std::list<string>& l );
00102 static bool multipathNotDeleted( const Dmmultipath&d ) { return( !d.deleted() ); }
00103
00104 void logData( const string& Dir );
00105
00106 string vendor;
00107 string model;
00108
00109 static bool active;
00110 };
00111
00112 }
00113
00114 #endif