yast2-storage

NfsCo.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) [2004-2009] Novell, Inc.
00003  *
00004  * All Rights Reserved.
00005  *
00006  * This program is free software; you can redistribute it and/or modify it
00007  * under the terms of version 2 of the GNU General Public License as published
00008  * by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful, but WITHOUT
00011  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013  * more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, contact Novell, Inc.
00017  *
00018  * To contact Novell about this file by physical or electronic mail, you may
00019  * find current contact information at www.novell.com.
00020  */
00021 
00022 
00023 #ifndef NFS_CO_H
00024 #define NFS_CO_H
00025 
00026 #include "storage/Container.h"
00027 #include "storage/Nfs.h"
00028 
00029 namespace storage
00030 {
00031     class SystemInfo;
00032 
00033 
00034 class NfsCo : public Container
00035     {
00036     friend class Storage;
00037 
00038     public:
00039 
00040         NfsCo(Storage * const s);
00041         NfsCo(Storage * const s, const EtcFstab& fstab, SystemInfo& systeminfo);
00042         NfsCo(const NfsCo& c);
00043         virtual ~NfsCo();
00044 
00045         static storage::CType staticType() { return storage::NFSC; }
00046         friend std::ostream& operator<< ( std::ostream&, const NfsCo& );
00047         int addNfs(const string& nfsDev, unsigned long long sizeK, const string& opts, 
00048                    const string& mp, bool nfs4);
00049 
00050         int removeVolume( Volume* v );
00051         int doRemove( Volume* );
00052 
00053         bool equalContent( const Container& rhs ) const;
00054 
00055         virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
00056         
00057     protected:
00058         // iterators over NFS volumes
00059         // protected typedefs for iterators over NFS volumes
00060         typedef CastIterator<VIter, Nfs *> NfsInter;
00061         typedef CastIterator<CVIter, const Nfs *> NfsCInter;
00062         template< class Pred >
00063             struct NfsPI { typedef ContainerIter<Pred, NfsInter> type; };
00064         template< class Pred >
00065             struct NfsCPI { typedef ContainerIter<Pred, NfsCInter> type; };
00066         typedef CheckFnc<const Nfs> CheckFncNfs;
00067         typedef CheckerIterator< CheckFncNfs, NfsPI<CheckFncNfs>::type,
00068                                  NfsInter, Nfs > NfsPIterator;
00069         typedef CheckerIterator< CheckFncNfs, NfsCPI<CheckFncNfs>::type,
00070                                  NfsCInter, const Nfs > NfsCPIterator;
00071         typedef DerefIterator<NfsPIterator,Nfs> NfsIter;
00072         typedef DerefIterator<NfsCPIterator,const Nfs> ConstNfsIter;
00073         typedef IterPair<NfsIter> NfsPair;
00074         typedef IterPair<ConstNfsIter> ConstNfsPair;
00075 
00076         NfsPair nfsPair( bool (* Check)( const Nfs& )=NULL)
00077             {
00078             return( NfsPair( nfsBegin( Check ), nfsEnd( Check ) ));
00079             }
00080         NfsIter nfsBegin( bool (* Check)( const Nfs& )=NULL)
00081             {
00082             IterPair<NfsInter> p( (NfsInter(begin())), (NfsInter(end())) );
00083             return( NfsIter( NfsPIterator( p, Check )) );
00084             }
00085         NfsIter nfsEnd( bool (* Check)( const Nfs& )=NULL)
00086             {
00087             IterPair<NfsInter> p( (NfsInter(begin())), (NfsInter(end())) );
00088             return( NfsIter( NfsPIterator( p, Check, true )) );
00089             }
00090 
00091         ConstNfsPair nfsPair( bool (* Check)( const Nfs& )=NULL) const
00092             {
00093             return( ConstNfsPair( nfsBegin( Check ), nfsEnd( Check ) ));
00094             }
00095         ConstNfsIter nfsBegin( bool (* Check)( const Nfs& )=NULL) const
00096             {
00097             IterPair<NfsCInter> p( (NfsCInter(begin())), (NfsCInter(end())) );
00098             return( ConstNfsIter( NfsCPIterator( p, Check )) );
00099             }
00100         ConstNfsIter nfsEnd( bool (* Check)( const Nfs& )=NULL) const
00101             {
00102             IterPair<NfsCInter> p( (NfsCInter(begin())), (NfsCInter(end())) );
00103             return( ConstNfsIter( NfsCPIterator( p, Check, true )) );
00104             }
00105 
00106         bool findNfs( const string& dev, NfsIter& i );
00107         bool findNfs( const string& dev );
00108 
00109         static list<string> filterOpts(const list<string>& opts);
00110         void getNfsData(const EtcFstab& fstab, SystemInfo& systeminfo);
00111 
00112         virtual void print( std::ostream& s ) const { s << *this; }
00113         virtual Container* getCopy() const { return( new NfsCo( *this ) ); }
00114 
00115     private:
00116 
00117         NfsCo& operator=(const NfsCo&); // disallow
00118 
00119     };
00120 
00121 }
00122 
00123 #endif