yast2-storage

TmpfsCo.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) [2004-2011] 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 TMPFS_CO_H
00024 #define TMPFS_CO_H
00025 
00026 #include "storage/Container.h"
00027 #include "storage/Tmpfs.h"
00028 
00029 
00030 namespace storage
00031 {
00032     class SystemInfo;
00033 
00034 
00035 class TmpfsCo : public Container
00036     {
00037     friend class Storage;
00038 
00039     public:
00040 
00041         TmpfsCo(Storage * const s);
00042         TmpfsCo(Storage * const s, const EtcFstab& fstab, SystemInfo& systeminfo);
00043         TmpfsCo(const TmpfsCo& c);
00044         virtual ~TmpfsCo();
00045 
00046         int addTmpfs( const string& mp, const string &opts );
00047         int removeTmpfs( const string& mp, bool silent=false );
00048 
00049         int doRemove( Volume* v );
00050 
00051         static storage::CType staticType() { return storage::TMPFSC; }
00052         friend std::ostream& operator<< (std::ostream&, const TmpfsCo& );
00053 
00054         int removeVolume( Volume* v );
00055         int removeVolume( Volume* v, bool quiet );
00056         bool equalContent( const Container& rhs ) const;
00057         void saveData(xmlNode* node) const;
00058 
00059         virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const;
00060         virtual void logData(const string& Dir) const;
00061 
00062         
00063     protected:
00064         // iterators over TMPFS volumes
00065         // protected typedefs for iterators over TMPFS volumes
00066         typedef CastIterator<VIter, Tmpfs *> TmpfsInter;
00067         typedef CastIterator<CVIter, const Tmpfs *> TmpfsCInter;
00068         template< class Pred >
00069             struct TmpfsPI { typedef ContainerIter<Pred, TmpfsInter> type; };
00070         template< class Pred >
00071             struct TmpfsCPI { typedef ContainerIter<Pred, TmpfsCInter> type; };
00072         typedef CheckFnc<const Tmpfs> CheckFncTmpfs;
00073         typedef CheckerIterator< CheckFncTmpfs, TmpfsPI<CheckFncTmpfs>::type,
00074                                  TmpfsInter, Tmpfs > TmpfsPIterator;
00075         typedef CheckerIterator< CheckFncTmpfs, TmpfsCPI<CheckFncTmpfs>::type,
00076                                  TmpfsCInter, const Tmpfs > TmpfsCPIterator;
00077         typedef DerefIterator<TmpfsPIterator,Tmpfs> TmpfsIter;
00078         typedef DerefIterator<TmpfsCPIterator,const Tmpfs> ConstTmpfsIter;
00079         typedef IterPair<TmpfsIter> TmpfsPair;
00080         typedef IterPair<ConstTmpfsIter> ConstTmpfsPair;
00081 
00082         TmpfsPair tmpfsPair( bool (* Check)( const Tmpfs& )=NULL)
00083             {
00084             return( TmpfsPair( tmpfsBegin( Check ), tmpfsEnd( Check ) ));
00085             }
00086         TmpfsIter tmpfsBegin( bool (* Check)( const Tmpfs& )=NULL)
00087             {
00088             IterPair<TmpfsInter> p( (TmpfsInter(begin())), (TmpfsInter(end())) );
00089             return( TmpfsIter( TmpfsPIterator( p, Check )) );
00090             }
00091         TmpfsIter tmpfsEnd( bool (* Check)( const Tmpfs& )=NULL)
00092             {
00093             IterPair<TmpfsInter> p( (TmpfsInter(begin())), (TmpfsInter(end())) );
00094             return( TmpfsIter( TmpfsPIterator( p, Check, true )) );
00095             }
00096 
00097         ConstTmpfsPair tmpfsPair( bool (* Check)( const Tmpfs& )=NULL) const
00098             {
00099             return( ConstTmpfsPair( tmpfsBegin( Check ), tmpfsEnd( Check ) ));
00100             }
00101         ConstTmpfsIter tmpfsBegin( bool (* Check)( const Tmpfs& )=NULL) const
00102             {
00103             IterPair<TmpfsCInter> p( (TmpfsCInter(begin())), (TmpfsCInter(end())) );
00104             return( ConstTmpfsIter( TmpfsCPIterator( p, Check )) );
00105             }
00106         ConstTmpfsIter tmpfsEnd( bool (* Check)( const Tmpfs& )=NULL) const
00107             {
00108             IterPair<TmpfsCInter> p( (TmpfsCInter(begin())), (TmpfsCInter(end())) );
00109             return( ConstTmpfsIter( TmpfsCPIterator( p, Check, true )) );
00110             }
00111 
00112         void getTmpfsData(const EtcFstab& fstab, SystemInfo& systeminfo);
00113         bool findTmpfs( const string& mp, TmpfsIter& i );
00114 
00115         virtual void print( std::ostream& s ) const { s << *this; }
00116         virtual Container* getCopy() const { return( new TmpfsCo( *this ) ); }
00117 
00118     private:
00119 
00120         TmpfsCo& operator=(const TmpfsCo&); // disallow
00121         
00122     };
00123 
00124 }
00125 
00126 #endif