Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

LoopCo.h

Go to the documentation of this file.
00001 #ifndef LOOP_CO_H
00002 #define LOOP_CO_H
00003 
00004 #include "y2storage/Container.h"
00005 #include "y2storage/Loop.h"
00006 
00007 class LoopCo : public Container
00008     {
00009     friend class Storage;
00010 
00011     public:
00012         LoopCo( Storage * const s, bool detect );
00013         LoopCo( const LoopCo& rhs );
00014 
00015         virtual ~LoopCo();
00016         static storage::CType const staticType() { return storage::LOOP; }
00017         friend std::ostream& operator<< (std::ostream&, const LoopCo& );
00018 
00019         int createLoop( const string& file, bool reuseExisting, 
00020                         unsigned long long sizeK, string& device );
00021         int removeLoop( const string& file, bool removeFile = false );
00022 
00023         int removeVolume( Volume* v );
00024         bool equalContent( const LoopCo& rhs ) const;
00025         void logDifference( const LoopCo& d ) const;
00026         
00027     protected:
00028         // iterators over LOOP volumes
00029         // protected typedefs for iterators over LOOP volumes
00030         typedef CastIterator<VIter, Loop *> LoopInter;
00031         typedef CastIterator<CVIter, const Loop *> LoopCInter;
00032         template< class Pred >
00033             struct LoopPI { typedef ContainerIter<Pred, LoopInter> type; };
00034         template< class Pred >
00035             struct LoopCPI { typedef ContainerIter<Pred, LoopCInter> type; };
00036         typedef CheckFnc<const Loop> CheckFncLoop;
00037         typedef CheckerIterator< CheckFncLoop, LoopPI<CheckFncLoop>::type,
00038                                  LoopInter, Loop > LoopPIterator;
00039         typedef CheckerIterator< CheckFncLoop, LoopCPI<CheckFncLoop>::type,
00040                                  LoopCInter, const Loop > LoopCPIterator;
00041         typedef DerefIterator<LoopPIterator,Loop> LoopIter;
00042         typedef DerefIterator<LoopCPIterator,const Loop> ConstLoopIter;
00043         typedef IterPair<LoopIter> LoopPair;
00044         typedef IterPair<ConstLoopIter> ConstLoopPair;
00045 
00046         LoopPair loopPair( bool (* Check)( const Loop& )=NULL)
00047             {
00048             return( LoopPair( loopBegin( Check ), loopEnd( Check ) ));
00049             }
00050         LoopIter loopBegin( bool (* Check)( const Loop& )=NULL)
00051             {
00052             IterPair<LoopInter> p( (LoopInter(begin())), (LoopInter(end())) );
00053             return( LoopIter( LoopPIterator( p, Check )) );
00054             }
00055         LoopIter loopEnd( bool (* Check)( const Loop& )=NULL)
00056             {
00057             IterPair<LoopInter> p( (LoopInter(begin())), (LoopInter(end())) );
00058             return( LoopIter( LoopPIterator( p, Check, true )) );
00059             }
00060 
00061         ConstLoopPair loopPair( bool (* Check)( const Loop& )=NULL) const
00062             {
00063             return( ConstLoopPair( loopBegin( Check ), loopEnd( Check ) ));
00064             }
00065         ConstLoopIter loopBegin( bool (* Check)( const Loop& )=NULL) const
00066             {
00067             IterPair<LoopCInter> p( (LoopCInter(begin())), (LoopCInter(end())) );
00068             return( ConstLoopIter( LoopCPIterator( p, Check )) );
00069             }
00070         ConstLoopIter loopEnd( bool (* Check)( const Loop& )=NULL) const
00071             {
00072             IterPair<LoopCInter> p( (LoopCInter(begin())), (LoopCInter(end())) );
00073             return( ConstLoopIter( LoopCPIterator( p, Check, true )) );
00074             }
00075 
00076         LoopCo( Storage * const s, const string& File );
00077 
00078         void getLoopData();
00079         bool findLoop( unsigned num, LoopIter& i );
00080         bool findLoop( unsigned num ); 
00081         bool findLoop( const string& dev, LoopIter& i );
00082         bool findLoop( const string& dev ); 
00083         void addLoop( Loop* m );
00084         void checkLoop( Loop* m );
00085         void updateEntry( const Loop* m );
00086         static int getFreeLoop( string& dev );
00087 
00088         void init();
00089 
00090         virtual void print( std::ostream& s ) const { s << *this; }
00091         virtual Container* getCopy() const { return( new LoopCo( *this ) ); }
00092 
00093         int doCreate( Volume* v );
00094         int doRemove( Volume* v );
00095 
00096         void logData( const string& Dir );
00097     };
00098 
00099 #endif

Generated on Wed Sep 14 11:27:07 2005 for yast2-storage by  doxygen 1.4.4