NfsCo.h

Go to the documentation of this file.
00001 #ifndef NFS_CO_H
00002 #define NFS_CO_H
00003 
00004 #include "y2storage/Container.h"
00005 #include "y2storage/Nfs.h"
00006 
00007 namespace storage
00008 {
00009 class NfsCo : public Container
00010     {
00011     friend class Storage;
00012 
00013     public:
00014         NfsCo( Storage * const s, ProcMounts& mounts );
00015         NfsCo( Storage * const s );
00016         NfsCo( const NfsCo& rhs );
00017 
00018         virtual ~NfsCo();
00019         static storage::CType staticType() { return storage::NFSC; }
00020         friend std::ostream& operator<< ( std::ostream&, const NfsCo& );
00021         int addNfs( const string& nfsDev, unsigned long long sizeK,
00022                     const string& mp );
00023 
00024         static bool isNfsDev( const string& dev );
00025         int removeVolume( Volume* v );
00026         int doRemove( Volume* );
00027 
00028         bool equalContent( const Container& rhs ) const;
00029         void logDifference( const Container& d ) const;
00030         
00031     protected:
00032         // iterators over NFS volumes
00033         // protected typedefs for iterators over NFS volumes
00034         typedef CastIterator<VIter, Nfs *> NfsInter;
00035         typedef CastIterator<CVIter, const Nfs *> NfsCInter;
00036         template< class Pred >
00037             struct NfsPI { typedef ContainerIter<Pred, NfsInter> type; };
00038         template< class Pred >
00039             struct NfsCPI { typedef ContainerIter<Pred, NfsCInter> type; };
00040         typedef CheckFnc<const Nfs> CheckFncNfs;
00041         typedef CheckerIterator< CheckFncNfs, NfsPI<CheckFncNfs>::type,
00042                                  NfsInter, Nfs > NfsPIterator;
00043         typedef CheckerIterator< CheckFncNfs, NfsCPI<CheckFncNfs>::type,
00044                                  NfsCInter, const Nfs > NfsCPIterator;
00045         typedef DerefIterator<NfsPIterator,Nfs> NfsIter;
00046         typedef DerefIterator<NfsCPIterator,const Nfs> ConstNfsIter;
00047         typedef IterPair<NfsIter> NfsPair;
00048         typedef IterPair<ConstNfsIter> ConstNfsPair;
00049 
00050         NfsPair nfsPair( bool (* Check)( const Nfs& )=NULL)
00051             {
00052             return( NfsPair( nfsBegin( Check ), nfsEnd( Check ) ));
00053             }
00054         NfsIter nfsBegin( bool (* Check)( const Nfs& )=NULL)
00055             {
00056             IterPair<NfsInter> p( (NfsInter(begin())), (NfsInter(end())) );
00057             return( NfsIter( NfsPIterator( p, Check )) );
00058             }
00059         NfsIter nfsEnd( bool (* Check)( const Nfs& )=NULL)
00060             {
00061             IterPair<NfsInter> p( (NfsInter(begin())), (NfsInter(end())) );
00062             return( NfsIter( NfsPIterator( p, Check, true )) );
00063             }
00064 
00065         ConstNfsPair nfsPair( bool (* Check)( const Nfs& )=NULL) const
00066             {
00067             return( ConstNfsPair( nfsBegin( Check ), nfsEnd( Check ) ));
00068             }
00069         ConstNfsIter nfsBegin( bool (* Check)( const Nfs& )=NULL) const
00070             {
00071             IterPair<NfsCInter> p( (NfsCInter(begin())), (NfsCInter(end())) );
00072             return( ConstNfsIter( NfsCPIterator( p, Check )) );
00073             }
00074         ConstNfsIter nfsEnd( bool (* Check)( const Nfs& )=NULL) const
00075             {
00076             IterPair<NfsCInter> p( (NfsCInter(begin())), (NfsCInter(end())) );
00077             return( ConstNfsIter( NfsCPIterator( p, Check, true )) );
00078             }
00079 
00080         NfsCo( Storage * const s, const string& File );
00081 
00082         bool findNfs( const string& dev, NfsIter& i );
00083         bool findNfs( const string& dev );
00084         void getNfsData( ProcMounts& mounts );
00085         void init();
00086 
00087         virtual void print( std::ostream& s ) const { s << *this; }
00088         virtual Container* getCopy() const { return( new NfsCo( *this ) ); }
00089 
00090         void logData( const string& Dir );
00091     };
00092 
00093 }
00094 
00095 #endif

Generated on Wed Apr 30 15:02:08 2008 for yast2-storage by  doxygen 1.4.6