00001 #ifndef STORAGE_H
00002 #define STORAGE_H
00003
00004 #include <iostream>
00005 #include <list>
00006 #include <map>
00007
00008 #include "y2storage/StorageInterface.h"
00009 #include "y2storage/StorageTypes.h"
00010 #include "y2storage/StorageTmpl.h"
00011 #include "y2storage/Container.h"
00012 #include "y2storage/Volume.h"
00013 #include "y2storage/Disk.h"
00014 #include "y2storage/Partition.h"
00015 #include "y2storage/LvmVg.h"
00016 #include "y2storage/LvmLv.h"
00017 #include "y2storage/EvmsCo.h"
00018 #include "y2storage/Evms.h"
00019 #include "y2storage/DmraidCo.h"
00020 #include "y2storage/Dmraid.h"
00021 #include "y2storage/MdCo.h"
00022 #include "y2storage/Md.h"
00023 #include "y2storage/DmCo.h"
00024 #include "y2storage/LoopCo.h"
00025 #include "y2storage/Loop.h"
00026 #include "y2storage/FilterIterator.h"
00027 #include "y2storage/DerefIterator.h"
00028 #include "y2storage/ListListIterator.h"
00029 #include "y2storage/IterPair.h"
00030
00031 namespace storage
00032 {
00033 template <int Value>
00034 class CheckType
00035 {
00036 public:
00037 bool operator()( const Container& d ) const
00038 {
00039 return( d.type()==Value );
00040 }
00041 };
00042
00043 template< class Iter, int Value, class CastResult >
00044 class CastCheckIterator : public CheckType<Value>,
00045 public FilterIterator< CheckType<Value>, Iter >
00046 {
00047 typedef FilterIterator<CheckType<Value>, Iter> _bclass;
00048 public:
00049 typedef CastResult value_type;
00050 typedef CastResult& reference;
00051 typedef CastResult* pointer;
00052
00053 CastCheckIterator() : _bclass() {}
00054 CastCheckIterator( const Iter& b, const Iter& e, bool atend=false) :
00055 _bclass( b, e, *this, atend ) {}
00056 CastCheckIterator( const IterPair<Iter>& pair, bool atend=false) :
00057 _bclass( pair, *this, atend ) {}
00058 CastCheckIterator( const CastCheckIterator& i) { *this=i;}
00059 CastResult operator*() const
00060 {
00061 return( static_cast<CastResult>(_bclass::operator*()) );
00062 }
00063 CastResult* operator->() const
00064 {
00065 return( static_cast<CastResult*>(_bclass::operator->()) );
00066 }
00067 CastCheckIterator& operator++()
00068 {
00069 _bclass::operator++(); return(*this);
00070 }
00071 CastCheckIterator operator++(int)
00072 {
00073 y2warning( "Expensive ++ CastCheckIterator" );
00074 CastCheckIterator tmp(*this);
00075 _bclass::operator++();
00076 return(tmp);
00077 }
00078 CastCheckIterator& operator--()
00079 {
00080 _bclass::operator--(); return(*this);
00081 }
00082 CastCheckIterator operator--(int)
00083 {
00084 y2warning( "Expensive -- CastCheckIterator" );
00085 CastCheckIterator tmp(*this);
00086 _bclass::operator--();
00087 return(tmp);
00088 }
00089 };
00090
00091 template < bool (* FncP)( const Container& c ) >
00092 class CheckByFnc
00093 {
00094 public:
00095 bool operator()( const Container& d ) const
00096 {
00097 return( (*FncP)(d) );
00098 }
00099 };
00100
00101 template< class Iter, bool (* FncP)( const Container& c ), class CastResult >
00102 class CastCheckFncIterator : public CheckByFnc<FncP>,
00103 public FilterIterator< CheckByFnc<FncP>, Iter >
00104 {
00105 typedef FilterIterator<CheckByFnc<FncP>, Iter> _bclass;
00106 public:
00107 typedef CastResult value_type;
00108 typedef CastResult& reference;
00109 typedef CastResult* pointer;
00110
00111 CastCheckFncIterator() : _bclass() {}
00112 CastCheckFncIterator( const Iter& b, const Iter& e, bool atend=false) :
00113 _bclass( b, e, *this, atend ) {}
00114 CastCheckFncIterator( const IterPair<Iter>& pair, bool atend=false) :
00115 _bclass( pair, *this, atend ) {}
00116 CastCheckFncIterator( const CastCheckFncIterator& i) { *this=i;}
00117 CastResult operator*() const
00118 {
00119 return( static_cast<CastResult>(_bclass::operator*()) );
00120 }
00121 CastResult* operator->() const
00122 {
00123 return( static_cast<CastResult*>(_bclass::operator->()) );
00124 }
00125 CastCheckFncIterator& operator++()
00126 {
00127 _bclass::operator++(); return(*this);
00128 }
00129 CastCheckFncIterator operator++(int)
00130 {
00131 y2warning( "Expensive ++ CastCheckFncIterator" );
00132 CastCheckFncIterator tmp(*this);
00133 _bclass::operator++();
00134 return(tmp);
00135 }
00136 CastCheckFncIterator& operator--()
00137 {
00138 _bclass::operator--(); return(*this);
00139 }
00140 CastCheckFncIterator operator--(int)
00141 {
00142 y2warning( "Expensive -- CastCheckFncIterator" );
00143 CastCheckFncIterator tmp(*this);
00144 _bclass::operator--();
00145 return(tmp);
00146 }
00147 };
00148
00164 class EtcFstab;
00165 class DiskData;
00166
00167 class Storage : public storage::StorageInterface
00168 {
00169 protected:
00170
00171 typedef std::list<Container*> CCont;
00172 typedef CCont::iterator CIter;
00173 typedef CCont::const_iterator CCIter;
00174
00175 static bool isMd( const Container&d )
00176 { return( d.type()==storage::MD ); }
00177 static bool isLoop( const Container&d )
00178 { return( d.type()==storage::LOOP ); }
00179 static bool isDm( const Container&d )
00180 { return( d.type()==storage::DM ); }
00181 struct FreeInfo
00182 {
00183 unsigned long long resize_free;
00184 unsigned long long df_free;
00185 unsigned long long used;
00186 bool win;
00187 bool rok;
00188 FreeInfo() { resize_free=df_free=used=0; win=rok=false; }
00189 FreeInfo( unsigned long long df,
00190 unsigned long long resize,
00191 unsigned long long usd, bool w=false, bool r=true )
00192 { resize_free=resize; df_free=df; used=usd; win=w; rok=r; }
00193 };
00194
00195 public:
00196 struct SkipDeleted { bool operator()(const Container&d) const {return( !d.deleted());}};
00197 static SkipDeleted SkipDel;
00198 static bool notDeleted( const Container&d ) { return( !d.deleted() ); };
00199 static bool isDmPart( const Container&d )
00200 { return( d.type()==storage::DMRAID ); }
00201
00202 static void initDefaultLogger ();
00203
00204 Storage( bool ronly=false, bool testmode=false, bool autodetect=true );
00205 bool test() const { return( testmode ); }
00206 bool instsys() const { return( inst_sys ); }
00207 void setCacheChanges( bool val=true ) { cache = val; }
00208 bool isCacheChanges() const { return( cache ); }
00209 void assertInit() { if( !initialized ) initialize(); }
00210 void rescanEverything();
00211 int checkCache();
00212 const string& tDir() const { return( testdir ); }
00213 const string& root() const { return( rootprefix ); }
00214 const string& tmpDir() const;
00215 static const string& arch() { return( proc_arch ); }
00216 static const string& sysfsDir() { return( sysfs_dir ); }
00217 static bool isPPCMac() { return( is_ppc_mac ); }
00218 static bool isPPCPegasos() { return( is_ppc_pegasos ); }
00219 EtcFstab* getFstab() { return fstab; }
00220 void handleLogFile( const string& name );
00221 static bool testFilesEqual( const string& n1, const string& n2 );
00222 void printInfo( std::ostream& str ) { printInfo( str, "" ); }
00223 void printInfo( std::ostream& str, const string& name );
00224 void printInfoCo( std::ostream& str, const string& name ) { printInfo( str, name ); }
00225 void logCo( Container* c );
00226 void logCo( const string& device );
00227 void logProcData( const string& l="" );
00228 storage::UsedByType usedBy( const string& dev );
00229 bool usedBy( const string& dev, storage::usedBy& ub );
00230 bool setUsedBy( const string& dev, storage::UsedByType typ,
00231 const string& name );
00232 bool canUseDevice( const string& dev, bool disks_allowed=false );
00233 bool knownDevice( const string& dev, bool disks_allowed=false );
00234 bool deletedDevice( const string& dev );
00235 bool isDisk( const string& dev );
00236 const Volume* getVolume( const string& dev );
00237 unsigned long long deviceSize( const string& dev );
00238 string deviceByNumber( const string& majmin );
00239 void rootMounted();
00240 bool isRootMounted() const { return( root_mounted ); }
00241 string findNormalDevice( const string& device );
00242 bool findVolume( const string& device, Volume const* &vol );
00243
00244 virtual ~Storage();
00245
00246
00247
00248 void getContainers( deque<storage::ContainerInfo>& infos );
00249 int getDiskInfo( const string& disk, storage::DiskInfo& info);
00250 int getLvmVgInfo( const string& name, storage::LvmVgInfo& info);
00251 int getEvmsCoInfo( const string& name, storage::EvmsCoInfo& info);
00252 int getDmraidCoInfo( const string& name, storage::DmraidCoInfo& info);
00253 int getContDiskInfo( const string& disk, storage::ContainerInfo& cinfo,
00254 storage::DiskInfo& info);
00255 int getContLvmVgInfo( const string& name, storage::ContainerInfo& cinfo,
00256 storage::LvmVgInfo& info);
00257 int getContEvmsCoInfo( const string& name,
00258 storage::ContainerInfo& cinfo,
00259 storage::EvmsCoInfo& info );
00260 int getContDmraidCoInfo( const string& name,
00261 storage::ContainerInfo& cinfo,
00262 storage::DmraidCoInfo& info );
00263 void getVolumes (deque<storage::VolumeInfo>& vlist);
00264 int getVolume( const string& device, storage::VolumeInfo& info);
00265 int getPartitionInfo( const string& disk,
00266 deque<storage::PartitionInfo>& plist );
00267 int getLvmLvInfo( const string& name,
00268 deque<storage::LvmLvInfo>& plist );
00269 int getEvmsInfo( const string& name,
00270 deque<storage::EvmsInfo>& plist );
00271 int getMdInfo( deque<storage::MdInfo>& plist );
00272 int getDmInfo( deque<storage::DmInfo>& plist );
00273 int getLoopInfo( deque<storage::LoopInfo>& plist );
00274 int getDmraidInfo( const string& name,
00275 deque<storage::DmraidInfo>& plist );
00276
00277 bool getFsCapabilities( storage::FsType fstype,
00278 storage::FsCapabilities& fscapabilities) const;
00279 void setExtError( const string& txt );
00280 int createPartition( const string& disk, storage::PartitionType type,
00281 unsigned long start, unsigned long size,
00282 string& device );
00283 int resizePartition( const string& device, unsigned long sizeCyl );
00284 int resizePartitionNoFs( const string& device, unsigned long sizeCyl );
00285 int nextFreePartition( const string& disk, storage::PartitionType type,
00286 unsigned &nr, string& device );
00287 int updatePartitionArea( const string& device,
00288 unsigned long start, unsigned long size );
00289 int createPartitionKb( const string& disk, storage::PartitionType type,
00290 unsigned long long start,
00291 unsigned long long sizek, string& device );
00292 int createPartitionAny( const string& disk, unsigned long long size,
00293 string& device );
00294 int createPartitionMax( const string& disk, storage::PartitionType type,
00295 string& device );
00296 unsigned long kbToCylinder( const string& disk, unsigned long long size );
00297 unsigned long long cylinderToKb( const string& disk, unsigned long size );
00298 int removePartition( const string& partition );
00299 int changePartitionId( const string& partition, unsigned id );
00300 int forgetChangePartitionId( const string& partition );
00301 int destroyPartitionTable( const string& disk, const string& label );
00302 int initializeDisk( const string& disk, bool value );
00303 string defaultDiskLabel() const;
00304
00305 int changeFormatVolume( const string& device, bool format,
00306 storage::FsType fs );
00307 int changeLabelVolume( const string& device, const string& label );
00308 int changeMkfsOptVolume( const string& device, const string& opts );
00309 int changeDescText( const string& device, const string& txt );
00310 int changeMountPoint( const string& device, const string& mount );
00311 int getMountPoint( const string& device, string& mount );
00312 int changeMountBy( const string& device, storage::MountByType mby );
00313 int getMountBy( const string& device, storage::MountByType& mby );
00314 int changeFstabOptions( const string&, const string& options );
00315 int getFstabOptions( const string& device, string& options );
00316 int addFstabOptions( const string&, const string& options );
00317 int removeFstabOptions( const string&, const string& options );
00318 int setCryptPassword( const string& device, const string& pwd );
00319 int forgetCryptPassword( const string& device );
00320 int getCryptPassword( const string& device, string& pwd );
00321 int setCrypt( const string& device, bool val );
00322 int getCrypt( const string& device, bool& val );
00323 int setIgnoreFstab( const string& device, bool val );
00324 int getIgnoreFstab( const string& device, bool& val );
00325 int addFstabEntry( const string& device, const string& mount,
00326 const string& vfs, const string& options,
00327 unsigned freq, unsigned passno );
00328 int resizeVolume( const string& device, unsigned long long newSizeMb );
00329 int resizeVolumeNoFs( const string& device, unsigned long long newSizeMb );
00330 int forgetResizeVolume( const string& device );
00331 void setRecursiveRemoval( bool val=true );
00332 bool getRecursiveRemoval() const { return recursiveRemove; }
00333 void setZeroNewPartitions( bool val=true );
00334 bool getZeroNewPartitions() const { return zeroNewPartitions; }
00335 void setDefaultMountBy (MountByType mby = MOUNTBY_DEVICE);
00336 MountByType getDefaultMountBy() const { return defaultMountBy; }
00337 void setDetectMountedVolumes( bool val=true );
00338 bool getDetectMountedVolumes() const { return detectMounted; }
00339 void setRootPrefix( const string& root );
00340 int removeVolume( const string& device );
00341 int removeUsing( const string& device, const storage::usedBy& uby );
00342 bool checkDeviceMounted( const string& device, string& mp );
00343 bool umountDevice( const string& device );
00344 bool mountDevice( const string& device, const string& mp );
00345 bool readFstab( const string& dir, deque<storage::VolumeInfo>& infos);
00346 bool getFreeInfo( const string& device, unsigned long long& resize_free,
00347 unsigned long long& df_free,
00348 unsigned long long& used, bool& win, bool use_cache );
00349 int createBackupState( const string& name );
00350 int removeBackupState( const string& name );
00351 int restoreBackupState( const string& name );
00352 bool checkBackupState( const string& name );
00353 bool equalBackupStates( const string& lhs, const string& rhs,
00354 bool verbose_log ) const;
00355
00356 int createLvmVg( const string& name, unsigned long long peSizeK,
00357 bool lvm1, const deque<string>& devs );
00358 int removeLvmVg( const string& name );
00359 int extendLvmVg( const string& name, const deque<string>& devs );
00360 int shrinkLvmVg( const string& name, const deque<string>& devs );
00361 int createLvmLv( const string& vg, const string& name,
00362 unsigned long long sizeM, unsigned stripe,
00363 string& device );
00364 int removeLvmLvByDevice( const string& device );
00365 int removeLvmLv( const string& vg, const string& name );
00366 int changeLvStripeSize( const string& vg, const string& name,
00367 unsigned long long stripeSize );
00368
00369 int evmsActivate();
00370 int createEvmsContainer( const string& name, unsigned long long peSizeK,
00371 bool lvm1, const deque<string>& devs );
00372 int modifyEvmsContainer( const string& old_name, const string& new_name,
00373 unsigned long long peSizeK, bool lvm1 );
00374 int removeEvmsContainer( const string& name );
00375 int extendEvmsContainer( const string& name, const deque<string>& devs );
00376 int shrinkEvmsContainer( const string& name, const deque<string>& devs );
00377 int createEvmsVolume( const string& vg, const string& name,
00378 unsigned long long sizeM, unsigned stripe,
00379 string& device );
00380 int removeEvmsVolumeByDevice( const string& device );
00381 int removeEvmsVolume( const string& vg, const string& name );
00382 int changeEvmsStripeSize( const string& coname, const string& name,
00383 unsigned long long stripeSize );
00384
00385 int createMd( const string& name, storage::MdType rtype,
00386 const deque<string>& devs );
00387 int createMdAny( storage::MdType rtype, const deque<string>& devs,
00388 string& device );
00389 int removeMd( const string& name, bool destroySb=true );
00390 int extendMd( const string& name, const string& dev );
00391 int shrinkMd( const string& name, const string& dev );
00392 int changeMdType( const string& name, storage::MdType rtype );
00393 int changeMdChunk( const string& name, unsigned long chunk );
00394 int changeMdParity( const string& name, storage::MdParity ptype );
00395 int checkMd( const string& name );
00396
00397 int createFileLoop( const string& lname, bool reuseExisting,
00398 unsigned long long sizeK, const string& mp,
00399 const string& pwd, string& device );
00400 int modifyFileLoop( const string& device, const string& lname,
00401 bool reuseExisting, unsigned long long sizeK );
00402 int removeFileLoop( const string& lname, bool removeFile );
00403
00404 int removeDmraid( const string& name );
00405
00406 deque<string> getCommitActions( bool mark_destructive );
00407 const string& getLastAction() const { return lastAction; }
00408 const string& getExtendedErrorMessage() const { return extendedError; }
00409 void eraseFreeInfo( const string& device );
00410 int waitForDevice() const;
00411 int waitForDevice( const string& device ) const;
00412 void checkDeviceExclusive( const string& device, unsigned secs );
00413 void getDiskList( bool (* CheckFnc)( const Disk& ),
00414 std::list<Disk*>& dl );
00415
00416 int commit();
00417 void activateHld( bool val=true );
00418 void removeDmTableTo( const Volume& vol );
00419 void removeDmTableTo( const string& device );
00420 bool removeDmTable( const string& table );
00421 bool removeDmMapsTo( const string& dev, bool also_evms=false );
00422 bool checkDmMapsTo( const string& dev );
00423 void updateDmEmptyPeMap();
00424 void dumpObjectList();
00425
00426 void setCallbackProgressBar( storage::CallbackProgressBar pfnc )
00427 { progress_bar_cb=pfnc; }
00428 storage::CallbackProgressBar getCallbackProgressBar() const
00429 { return progress_bar_cb; }
00430 void setCallbackShowInstallInfo( storage::CallbackShowInstallInfo pfnc )
00431 { install_info_cb=pfnc; }
00432 storage::CallbackShowInstallInfo getCallbackShowInstallInfo() const
00433 { return install_info_cb; }
00434 void setCallbackInfoPopup( storage::CallbackInfoPopup pfnc )
00435 { info_popup_cb=pfnc; }
00436 storage::CallbackInfoPopup getCallbackInfoPopup() const
00437 { return info_popup_cb; }
00438 void setCallbackYesNoPopup( storage::CallbackYesNoPopup pfnc )
00439 { yesno_popup_cb=pfnc; }
00440 storage::CallbackYesNoPopup getCallbackYesNoPopup() const
00441 { return yesno_popup_cb; }
00442 void addInfoPopupText( const string& disk, const string txt );
00443
00444 static void setCallbackProgressBarYcp( storage::CallbackProgressBar pfnc )
00445 { progress_bar_cb_ycp=pfnc; }
00446 static storage::CallbackProgressBar getCallbackProgressBarYcp()
00447 { return progress_bar_cb_ycp; }
00448 static void setCallbackShowInstallInfoYcp( storage::CallbackShowInstallInfo pfnc )
00449 { install_info_cb_ycp=pfnc; }
00450 static storage::CallbackShowInstallInfo getCallbackShowInstallInfoYcp()
00451 { return install_info_cb_ycp; }
00452 static void setCallbackInfoPopupYcp( storage::CallbackInfoPopup pfnc )
00453 { info_popup_cb_ycp=pfnc; }
00454 static storage::CallbackInfoPopup getCallbackInfoPopupYcp()
00455 { return info_popup_cb_ycp; }
00456 static void setCallbackYesNoPopupYcp( storage::CallbackYesNoPopup pfnc )
00457 { yesno_popup_cb_ycp=pfnc; }
00458 static storage::CallbackYesNoPopup getCallbackYesNoPopupYcp()
00459 { return yesno_popup_cb_ycp; }
00460
00461 storage::CallbackProgressBar getCallbackProgressBarTheOne() const
00462 { return progress_bar_cb ? progress_bar_cb : progress_bar_cb_ycp; }
00463 storage::CallbackShowInstallInfo getCallbackShowInstallInfoTheOne() const
00464 { return install_info_cb ? install_info_cb : install_info_cb_ycp; }
00465 storage::CallbackInfoPopup getCallbackInfoPopupTheOne() const
00466 { return info_popup_cb ? info_popup_cb : info_popup_cb_ycp; }
00467 storage::CallbackYesNoPopup getCallbackYesNoPopupTheOne() const
00468 { return yesno_popup_cb ? yesno_popup_cb : yesno_popup_cb_ycp; }
00469
00470 void progressBarCb( const string& id, unsigned cur, unsigned max );
00471 void showInfoCb( const string& info );
00472 void infoPopupCb( const string& info );
00473 bool yesnoPopupCb( const string& info );
00474
00475
00476 protected:
00477
00478 template< class Pred >
00479 struct ConstContainerPI { typedef ContainerIter<Pred, CCIter> type; };
00480 typedef CheckFnc<const Container> CheckFncCont;
00481 typedef CheckerIterator< CheckFncCont, ConstContainerPI<CheckFncCont>::type,
00482 CCIter, Container > ConstContPIterator;
00483 template< class Pred >
00484 struct ContainerPI { typedef ContainerIter<Pred, CIter> type; };
00485 template< class Pred >
00486 struct ContainerI
00487 { typedef ContainerDerIter<Pred, typename ContainerPI<Pred>::type,
00488 Container> type; };
00489 typedef CheckerIterator< CheckFncCont, ContainerPI<CheckFncCont>::type,
00490 CIter, Container > ContPIterator;
00491 typedef DerefIterator<ContPIterator,Container> ContIterator;
00492 typedef IterPair<ContIterator> CPair;
00493
00494 public:
00495
00496 template< class Pred >
00497 struct ConstContainerI
00498 { typedef ContainerDerIter<Pred, typename ConstContainerPI<Pred>::type,
00499 const Container> type; };
00500 template< class Pred >
00501 struct ContCondIPair { typedef MakeCondIterPair<Pred,
00502 typename ConstContainerI<Pred>::type> type;};
00503 typedef DerefIterator<ConstContPIterator,const Container> ConstContIterator;
00504 typedef IterPair<ConstContIterator> ConstContPair;
00505
00506
00507 ConstContPair contPair( bool (* CheckFnc)( const Container& )=NULL ) const
00508 {
00509 return( ConstContPair( contBegin( CheckFnc ), contEnd( CheckFnc ) ));
00510 }
00511 ConstContIterator contBegin( bool (* CheckFnc)( const Container& )=NULL ) const
00512 {
00513 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00514 }
00515 ConstContIterator contEnd( bool (* CheckFnc)( const Container& )=NULL ) const
00516 {
00517 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00518 }
00519 template< class Pred > typename ContCondIPair<Pred>::type contCondPair( const Pred& p ) const
00520 {
00521 return( typename ContCondIPair<Pred>::type( contCondBegin( p ), contCondEnd( p ) ) );
00522 }
00523 template< class Pred > typename ConstContainerI<Pred>::type contCondBegin( const Pred& p ) const
00524 {
00525 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p )) );
00526 }
00527 template< class Pred > typename ConstContainerI<Pred>::type contCondEnd( const Pred& p ) const
00528 {
00529 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p, true )) );
00530 }
00531 protected:
00532
00533 CPair cPair( bool (* CheckFnc)( const Container& )=NULL )
00534 {
00535 return( CPair( cBegin(CheckFnc), cEnd(CheckFnc) ));
00536 }
00537 ContIterator cBegin( bool (* CheckFnc)( const Container& )=NULL )
00538 {
00539 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00540 }
00541 ContIterator cEnd( bool (* CheckFnc)( const Container& )=NULL )
00542 {
00543 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00544 }
00545
00546
00547 protected:
00548
00549 typedef CastCheckIterator<CCIter, storage::DISK, const Disk *> ContainerCDiskIter;
00550 template< class Pred >
00551 struct ConstDiskPI { typedef ContainerIter<Pred, ContainerCDiskIter> type; };
00552 typedef CastCheckIterator<CIter, storage::DISK, Disk *> ContainerDiskIter;
00553 template< class Pred >
00554 struct DiskPI { typedef ContainerIter<Pred, ContainerDiskIter> type; };
00555 template< class Pred >
00556 struct DiskI { typedef ContainerDerIter<Pred, typename DiskPI<Pred>::type, Disk> type; };
00557 typedef CheckFnc<const Disk> CheckFncDisk;
00558 typedef CheckerIterator< CheckFncDisk, ConstDiskPI<CheckFncDisk>::type,
00559 ContainerCDiskIter, Disk > ConstDiskPIterator;
00560 typedef CheckerIterator< CheckFncDisk, DiskPI<CheckFncDisk>::type,
00561 ContainerDiskIter, Disk > DiskPIterator;
00562 typedef DerefIterator<DiskPIterator,Disk> DiskIterator;
00563 typedef IterPair<DiskIterator> DiskPair;
00564
00565 public:
00566
00567 typedef DerefIterator<ConstDiskPIterator,const Disk> ConstDiskIterator;
00568 template< class Pred >
00569 struct ConstDiskI
00570 { typedef ContainerDerIter<Pred, typename ConstDiskPI<Pred>::type,
00571 const Disk> type; };
00572 template< class Pred >
00573 struct DiskCondIPair { typedef MakeCondIterPair<Pred, typename ConstDiskI<Pred>::type> type; };
00574 typedef IterPair<ConstDiskIterator> ConstDiskPair;
00575
00576
00577 ConstDiskPair diskPair( bool (* CheckFnc)( const Disk& )=NULL ) const
00578 {
00579 return( ConstDiskPair( diskBegin( CheckFnc ), diskEnd( CheckFnc ) ));
00580 }
00581 ConstDiskIterator diskBegin( bool (* CheckFnc)( const Disk& )=NULL ) const
00582 {
00583 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00584 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00585 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc )) );
00586 }
00587 ConstDiskIterator diskEnd( bool (* CheckFnc)( const Disk& )=NULL ) const
00588 {
00589 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00590 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00591 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc, true )) );
00592 }
00593 template< class Pred > typename DiskCondIPair<Pred>::type diskCondPair( const Pred& p ) const
00594 {
00595 return( typename DiskCondIPair<Pred>::type( diskCondBegin( p ), diskCondEnd( p ) ) );
00596 }
00597 template< class Pred > typename ConstDiskI<Pred>::type diskCondBegin( const Pred& p ) const
00598 {
00599 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00600 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00601 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p )) );
00602 }
00603 template< class Pred > typename ConstDiskI<Pred>::type diskCondEnd( const Pred& p ) const
00604 {
00605 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00606 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00607 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p, true )) );
00608 }
00609 protected:
00610
00611 DiskPair dPair( bool (* CheckFnc)( const Disk& )=NULL )
00612 {
00613 return( DiskPair( dBegin( CheckFnc ), dEnd( CheckFnc ) ));
00614 }
00615 DiskIterator dBegin( bool (* CheckFnc)( const Disk& )=NULL )
00616 {
00617 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00618 ContainerDiskIter( cont.begin(), cont.end(), true ));
00619 return( DiskIterator( DiskPIterator( p, CheckFnc )) );
00620 }
00621 DiskIterator dEnd( bool (* CheckFnc)( const Disk& )=NULL )
00622 {
00623 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00624 ContainerDiskIter( cont.begin(), cont.end(), true ));
00625 return( DiskIterator( DiskPIterator( p, CheckFnc, true )) );
00626 }
00627
00628
00629
00630 protected:
00631
00632 typedef CastCheckIterator<CCIter, storage::LVM, const LvmVg *> ContainerCLvmVgIter;
00633 template< class Pred >
00634 struct ConstLvmVgPI { typedef ContainerIter<Pred, ContainerCLvmVgIter> type; };
00635 typedef CastCheckIterator<CIter, storage::LVM, LvmVg *> ContainerLvmVgIter;
00636 template< class Pred >
00637 struct LvmVgPI { typedef ContainerIter<Pred, ContainerLvmVgIter> type; };
00638 template< class Pred >
00639 struct LvmVgI { typedef ContainerDerIter<Pred, typename LvmVgPI<Pred>::type, LvmVg> type; };
00640 typedef CheckFnc<const LvmVg> CheckFncLvmVg;
00641 typedef CheckerIterator< CheckFncLvmVg, ConstLvmVgPI<CheckFncLvmVg>::type,
00642 ContainerCLvmVgIter, LvmVg > ConstLvmVgPIterator;
00643 typedef CheckerIterator< CheckFncLvmVg, LvmVgPI<CheckFncLvmVg>::type,
00644 ContainerLvmVgIter, LvmVg > LvmVgPIterator;
00645 typedef DerefIterator<LvmVgPIterator,LvmVg> LvmVgIterator;
00646 typedef IterPair<LvmVgIterator> LvmVgPair;
00647
00648 public:
00649
00650 typedef DerefIterator<ConstLvmVgPIterator,const LvmVg> ConstLvmVgIterator;
00651 template< class Pred >
00652 struct ConstLvmVgI
00653 { typedef ContainerDerIter<Pred, typename ConstLvmVgPI<Pred>::type,
00654 const LvmVg> type; };
00655 template< class Pred >
00656 struct LvmVgCondIPair { typedef MakeCondIterPair<Pred, typename ConstLvmVgI<Pred>::type> type; };
00657 typedef IterPair<ConstLvmVgIterator> ConstLvmVgPair;
00658
00659
00660 ConstLvmVgPair lvmVgPair( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00661 {
00662 return( ConstLvmVgPair( lvmVgBegin( CheckFnc ), lvmVgEnd( CheckFnc ) ));
00663 }
00664 ConstLvmVgIterator lvmVgBegin( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00665 {
00666 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00667 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00668 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc )) );
00669 }
00670 ConstLvmVgIterator lvmVgEnd( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00671 {
00672 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00673 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00674 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc, true )) );
00675 }
00676 template< class Pred > typename LvmVgCondIPair<Pred>::type lvmVgCondPair( const Pred& p ) const
00677 {
00678 return( typename LvmVgCondIPair<Pred>::type( lvmVgCondBegin( p ), lvmVgCondEnd( p ) ) );
00679 }
00680 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondBegin( const Pred& p ) const
00681 {
00682 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00683 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00684 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p )) );
00685 }
00686 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondEnd( const Pred& p ) const
00687 {
00688 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00689 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00690 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p, true )) );
00691 }
00692 protected:
00693
00694 LvmVgPair lvgPair( bool (* CheckFnc)( const LvmVg& )=NULL )
00695 {
00696 return( LvmVgPair( lvgBegin( CheckFnc ), lvgEnd( CheckFnc ) ));
00697 }
00698 LvmVgIterator lvgBegin( bool (* CheckFnc)( const LvmVg& )=NULL )
00699 {
00700 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00701 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00702 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc )) );
00703 }
00704 LvmVgIterator lvgEnd( bool (* CheckFnc)( const LvmVg& )=NULL )
00705 {
00706 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00707 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00708 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc, true )) );
00709 }
00710
00711
00712 protected:
00713
00714 typedef CastCheckIterator<CCIter, storage::EVMS, const EvmsCo *> ContainerCEvmsIter;
00715 template< class Pred >
00716 struct ConstEvmsCoPI { typedef ContainerIter<Pred, ContainerCEvmsIter> type; };
00717 typedef CastCheckIterator<CIter, storage::EVMS, EvmsCo *> ContainerEvmsIter;
00718 template< class Pred >
00719 struct EvmsCoPI { typedef ContainerIter<Pred, ContainerEvmsIter> type; };
00720 template< class Pred >
00721 struct EvmsCoI { typedef ContainerDerIter<Pred, typename EvmsCoPI<Pred>::type, EvmsCo> type; };
00722 typedef CheckFnc<const EvmsCo> CheckFncEvmsCo;
00723 typedef CheckerIterator< CheckFncEvmsCo, ConstEvmsCoPI<CheckFncEvmsCo>::type,
00724 ContainerCEvmsIter, EvmsCo > ConstEvmsCoPIterator;
00725 typedef CheckerIterator< CheckFncEvmsCo, EvmsCoPI<CheckFncEvmsCo>::type,
00726 ContainerEvmsIter, EvmsCo > EvmsCoPIterator;
00727 typedef DerefIterator<EvmsCoPIterator,EvmsCo> EvmsCoIterator;
00728 typedef IterPair<EvmsCoIterator> EvmsCoPair;
00729
00730 public:
00731
00732 typedef DerefIterator<ConstEvmsCoPIterator,const EvmsCo> ConstEvmsCoIterator;
00733 template< class Pred >
00734 struct ConstEvmsCoI
00735 { typedef ContainerDerIter<Pred, typename ConstEvmsCoPI<Pred>::type,
00736 const EvmsCo> type; };
00737 template< class Pred >
00738 struct EvmsCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstEvmsCoI<Pred>::type> type; };
00739 typedef IterPair<ConstEvmsCoIterator> ConstEvmsCoPair;
00740
00741
00742 ConstEvmsCoPair evmsCoPair( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00743 {
00744 return( ConstEvmsCoPair( evmsCoBegin( CheckFnc ), evmsCoEnd( CheckFnc ) ));
00745 }
00746 ConstEvmsCoIterator evmsCoBegin( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00747 {
00748 IterPair<ContainerCEvmsIter> p( ContainerCEvmsIter( cont.begin(), cont.end() ),
00749 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00750 return( ConstEvmsCoIterator( ConstEvmsCoPIterator( p, CheckFnc )) );
00751 }
00752 ConstEvmsCoIterator evmsCoEnd( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00753 {
00754 IterPair<ContainerCEvmsIter> p( ContainerCEvmsIter( cont.begin(), cont.end() ),
00755 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00756 return( ConstEvmsCoIterator( ConstEvmsCoPIterator( p, CheckFnc, true )) );
00757 }
00758 template< class Pred > typename EvmsCoCondIPair<Pred>::type evmsCoCondPair( const Pred& p ) const
00759 {
00760 return( typename EvmsCoCondIPair<Pred>::type( evmsCoCondBegin( p ), evmsCoCondEnd( p ) ) );
00761 }
00762 template< class Pred > typename ConstEvmsCoI<Pred>::type evmsCoCondBegin( const Pred& p ) const
00763 {
00764 IterPair<ContainerCEvmsIter> pair( ContainerCEvmsIter( cont.begin(), cont.end() ),
00765 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00766 return( typename ConstEvmsCoI<Pred>::type( typename ConstEvmsCoPI<Pred>::type( pair, p )) );
00767 }
00768 template< class Pred > typename ConstEvmsCoI<Pred>::type evmsCoCondEnd( const Pred& p ) const
00769 {
00770 IterPair<ContainerCEvmsIter> pair( ContainerCEvmsIter( cont.begin(), cont.end() ),
00771 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00772 return( typename ConstEvmsCoI<Pred>::type( typename ConstEvmsCoPI<Pred>::type( pair, p, true )) );
00773 }
00774 protected:
00775
00776 EvmsCoPair evCoPair( bool (* CheckFnc)( const EvmsCo& )=NULL )
00777 {
00778 return( EvmsCoPair( evCoBegin( CheckFnc ), evCoEnd( CheckFnc ) ));
00779 }
00780 EvmsCoIterator evCoBegin( bool (* CheckFnc)( const EvmsCo& )=NULL )
00781 {
00782 IterPair<ContainerEvmsIter> p( ContainerEvmsIter( cont.begin(), cont.end() ),
00783 ContainerEvmsIter( cont.begin(), cont.end(), true ));
00784 return( EvmsCoIterator( EvmsCoPIterator( p, CheckFnc )) );
00785 }
00786 EvmsCoIterator evCoEnd( bool (* CheckFnc)( const EvmsCo& )=NULL )
00787 {
00788 IterPair<ContainerEvmsIter> p( ContainerEvmsIter( cont.begin(), cont.end() ),
00789 ContainerEvmsIter( cont.begin(), cont.end(), true ));
00790 return( EvmsCoIterator( EvmsCoPIterator( p, CheckFnc, true )) );
00791 }
00792
00793
00794 protected:
00795
00796 typedef CastCheckFncIterator<CCIter, isDmPart, const DmPartCo *> ContainerCDmPartIter;
00797 template< class Pred >
00798 struct ConstDmPartCoPI { typedef ContainerIter<Pred, ContainerCDmPartIter> type; };
00799 typedef CastCheckFncIterator<CIter, isDmPart, DmPartCo *> ContainerDmPartIter;
00800 template< class Pred >
00801 struct DmPartCoPI { typedef ContainerIter<Pred, ContainerDmPartIter> type; };
00802 template< class Pred >
00803 struct DmPartCoI { typedef ContainerDerIter<Pred, typename DmPartCoPI<Pred>::type, DmPartCo> type; };
00804 typedef CheckFnc<const DmPartCo> CheckFncDmPartCo;
00805 typedef CheckerIterator< CheckFncDmPartCo, ConstDmPartCoPI<CheckFncDmPartCo>::type,
00806 ContainerCDmPartIter, DmPartCo > ConstDmPartCoPIterator;
00807 typedef CheckerIterator< CheckFncDmPartCo, DmPartCoPI<CheckFncDmPartCo>::type,
00808 ContainerDmPartIter, DmPartCo > DmPartCoPIterator;
00809 typedef DerefIterator<DmPartCoPIterator,DmPartCo> DmPartCoIterator;
00810 typedef IterPair<DmPartCoIterator> DmPartCoPair;
00811
00812 public:
00813
00814 typedef DerefIterator<ConstDmPartCoPIterator,const DmPartCo> ConstDmPartCoIterator;
00815 template< class Pred >
00816 struct ConstDmPartCoI
00817 { typedef ContainerDerIter<Pred, typename ConstDmPartCoPI<Pred>::type,
00818 const DmPartCo> type; };
00819 template< class Pred >
00820 struct DmPartCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmPartCoI<Pred>::type> type; };
00821 typedef IterPair<ConstDmPartCoIterator> ConstDmPartCoPair;
00822
00823
00824 ConstDmPartCoPair dmpartCoPair( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00825 {
00826 return( ConstDmPartCoPair( dmpartCoBegin( CheckFnc ), dmpartCoEnd( CheckFnc ) ));
00827 }
00828 ConstDmPartCoIterator dmpartCoBegin( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00829 {
00830 IterPair<ContainerCDmPartIter> p( ContainerCDmPartIter( cont.begin(), cont.end() ),
00831 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00832 return( ConstDmPartCoIterator( ConstDmPartCoPIterator( p, CheckFnc )) );
00833 }
00834 ConstDmPartCoIterator dmpartCoEnd( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00835 {
00836 IterPair<ContainerCDmPartIter> p( ContainerCDmPartIter( cont.begin(), cont.end() ),
00837 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00838 return( ConstDmPartCoIterator( ConstDmPartCoPIterator( p, CheckFnc, true )) );
00839 }
00840 template< class Pred > typename DmPartCoCondIPair<Pred>::type dmPartCoCondPair( const Pred& p ) const
00841 {
00842 return( typename DmPartCoCondIPair<Pred>::type( dmpartCoCondBegin( p ), dmpartCoCondEnd( p ) ) );
00843 }
00844 template< class Pred > typename ConstDmPartCoI<Pred>::type dmpartCoCondBegin( const Pred& p ) const
00845 {
00846 IterPair<ContainerCDmPartIter> pair( ContainerCDmPartIter( cont.begin(), cont.end() ),
00847 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00848 return( typename ConstDmPartCoI<Pred>::type( typename ConstDmPartCoPI<Pred>::type( pair, p )) );
00849 }
00850 template< class Pred > typename ConstDmPartCoI<Pred>::type dmpartCoCondEnd( const Pred& p ) const
00851 {
00852 IterPair<ContainerCDmPartIter> pair( ContainerCDmPartIter( cont.begin(), cont.end() ),
00853 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00854 return( typename ConstDmPartCoI<Pred>::type( typename ConstDmPartCoPI<Pred>::type( pair, p, true )) );
00855 }
00856 protected:
00857
00858 DmPartCoPair dmpCoPair( bool (* CheckFnc)( const DmPartCo& )=NULL )
00859 {
00860 return( DmPartCoPair( dmpCoBegin( CheckFnc ), dmpCoEnd( CheckFnc ) ));
00861 }
00862 DmPartCoIterator dmpCoBegin( bool (* CheckFnc)( const DmPartCo& )=NULL )
00863 {
00864 IterPair<ContainerDmPartIter> p( ContainerDmPartIter( cont.begin(), cont.end() ),
00865 ContainerDmPartIter( cont.begin(), cont.end(), true ));
00866 return( DmPartCoIterator( DmPartCoPIterator( p, CheckFnc )) );
00867 }
00868 DmPartCoIterator dmpCoEnd( bool (* CheckFnc)( const DmPartCo& )=NULL )
00869 {
00870 IterPair<ContainerDmPartIter> p( ContainerDmPartIter( cont.begin(), cont.end() ),
00871 ContainerDmPartIter( cont.begin(), cont.end(), true ));
00872 return( DmPartCoIterator( DmPartCoPIterator( p, CheckFnc, true )) );
00873 }
00874
00875
00876 protected:
00877
00878 typedef CastCheckIterator<CCIter, storage::DMRAID, const DmraidCo *> ContainerCDmraidIter;
00879 template< class Pred >
00880 struct ConstDmraidCoPI { typedef ContainerIter<Pred, ContainerCDmraidIter> type; };
00881 typedef CastCheckIterator<CIter, storage::DMRAID, DmraidCo *> ContainerDmraidIter;
00882 template< class Pred >
00883 struct DmraidCoPI { typedef ContainerIter<Pred, ContainerDmraidIter> type; };
00884 template< class Pred >
00885 struct DmraidCoI { typedef ContainerDerIter<Pred, typename DmraidCoPI<Pred>::type, DmraidCo> type; };
00886 typedef CheckFnc<const DmraidCo> CheckFncDmraidCo;
00887 typedef CheckerIterator< CheckFncDmraidCo, ConstDmraidCoPI<CheckFncDmraidCo>::type,
00888 ContainerCDmraidIter, DmraidCo > ConstDmraidCoPIterator;
00889 typedef CheckerIterator< CheckFncDmraidCo, DmraidCoPI<CheckFncDmraidCo>::type,
00890 ContainerDmraidIter, DmraidCo > DmraidCoPIterator;
00891 typedef DerefIterator<DmraidCoPIterator,DmraidCo> DmraidCoIterator;
00892 typedef IterPair<DmraidCoIterator> DmraidCoPair;
00893
00894 public:
00895
00896 typedef DerefIterator<ConstDmraidCoPIterator,const DmraidCo> ConstDmraidCoIterator;
00897 template< class Pred >
00898 struct ConstDmraidCoI
00899 { typedef ContainerDerIter<Pred, typename ConstDmraidCoPI<Pred>::type,
00900 const DmraidCo> type; };
00901 template< class Pred >
00902 struct DmraidCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmraidCoI<Pred>::type> type; };
00903 typedef IterPair<ConstDmraidCoIterator> ConstDmraidCoPair;
00904
00905
00906 ConstDmraidCoPair dmraidCoPair( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00907 {
00908 return( ConstDmraidCoPair( dmraidCoBegin( CheckFnc ), dmraidCoEnd( CheckFnc ) ));
00909 }
00910 ConstDmraidCoIterator dmraidCoBegin( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00911 {
00912 IterPair<ContainerCDmraidIter> p( ContainerCDmraidIter( cont.begin(), cont.end() ),
00913 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00914 return( ConstDmraidCoIterator( ConstDmraidCoPIterator( p, CheckFnc )) );
00915 }
00916 ConstDmraidCoIterator dmraidCoEnd( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00917 {
00918 IterPair<ContainerCDmraidIter> p( ContainerCDmraidIter( cont.begin(), cont.end() ),
00919 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00920 return( ConstDmraidCoIterator( ConstDmraidCoPIterator( p, CheckFnc, true )) );
00921 }
00922 template< class Pred > typename DmraidCoCondIPair<Pred>::type dmraidCoCondPair( const Pred& p ) const
00923 {
00924 return( typename DmraidCoCondIPair<Pred>::type( dmraidCoCondBegin( p ), dmraidCoCondEnd( p ) ) );
00925 }
00926 template< class Pred > typename ConstDmraidCoI<Pred>::type dmraidCoCondBegin( const Pred& p ) const
00927 {
00928 IterPair<ContainerCDmraidIter> pair( ContainerCDmraidIter( cont.begin(), cont.end() ),
00929 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00930 return( typename ConstDmraidCoI<Pred>::type( typename ConstDmraidCoPI<Pred>::type( pair, p )) );
00931 }
00932 template< class Pred > typename ConstDmraidCoI<Pred>::type dmraidCoCondEnd( const Pred& p ) const
00933 {
00934 IterPair<ContainerCDmraidIter> pair( ContainerCDmraidIter( cont.begin(), cont.end() ),
00935 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00936 return( typename ConstDmraidCoI<Pred>::type( typename ConstDmraidCoPI<Pred>::type( pair, p, true )) );
00937 }
00938 protected:
00939
00940 DmraidCoPair dmrCoPair( bool (* CheckFnc)( const DmraidCo& )=NULL )
00941 {
00942 return( DmraidCoPair( dmrCoBegin( CheckFnc ), dmrCoEnd( CheckFnc ) ));
00943 }
00944 DmraidCoIterator dmrCoBegin( bool (* CheckFnc)( const DmraidCo& )=NULL )
00945 {
00946 IterPair<ContainerDmraidIter> p( ContainerDmraidIter( cont.begin(), cont.end() ),
00947 ContainerDmraidIter( cont.begin(), cont.end(), true ));
00948 return( DmraidCoIterator( DmraidCoPIterator( p, CheckFnc )) );
00949 }
00950 DmraidCoIterator dmrCoEnd( bool (* CheckFnc)( const DmraidCo& )=NULL )
00951 {
00952 IterPair<ContainerDmraidIter> p( ContainerDmraidIter( cont.begin(), cont.end() ),
00953 ContainerDmraidIter( cont.begin(), cont.end(), true ));
00954 return( DmraidCoIterator( DmraidCoPIterator( p, CheckFnc, true )) );
00955 }
00956
00957
00958 protected:
00959
00960 typedef ListListIterator<Container::ConstPlainIterator, ConstContIterator> ConstVolInter;
00961 template< class Pred >
00962 struct ConstVolumePI { typedef ContainerIter<Pred, ConstVolInter> type; };
00963 typedef CheckFnc<const Volume> CheckFncVol;
00964 typedef CheckerIterator< CheckFncVol, ConstVolumePI<CheckFncVol>::type,
00965 ConstVolInter, Volume > ConstVolPIterator;
00966 typedef ListListIterator<Container::PlainIterator, ContIterator> VolPart;
00967 template< class Pred >
00968 struct VolumeI { typedef ContainerIter<Pred, VolPart> type; };
00969 typedef CheckerIterator< CheckFncVol, VolumeI<CheckFncVol>::type,
00970 VolPart, Volume > VolPIterator;
00971 typedef DerefIterator<VolPIterator,Volume> VolIterator;
00972 typedef IterPair<VolIterator> VPair;
00973
00974 public:
00975
00976 template< class Pred >
00977 struct ConstVolumeI { typedef ContainerDerIter<Pred, typename ConstVolumePI<Pred>::type, const Volume> type; };
00978 template< class Pred >
00979 struct VolCondIPair { typedef MakeCondIterPair<Pred, typename ConstVolumeI<Pred>::type> type;};
00980 typedef DerefIterator<ConstVolPIterator,const Volume> ConstVolIterator;
00981 typedef IterPair<ConstVolIterator> ConstVolPair;
00982
00983
00984 ConstVolPair volPair( bool (* CheckCnt)( const Container& )) const
00985 {
00986 return( ConstVolPair( volBegin( CheckCnt ), volEnd( CheckCnt ) ));
00987 }
00988 ConstVolPair volPair( bool (* CheckVol)( const Volume& )=NULL,
00989 bool (* CheckCnt)( const Container& )=NULL) const
00990 {
00991 return( ConstVolPair( volBegin( CheckVol, CheckCnt ),
00992 volEnd( CheckVol, CheckCnt ) ));
00993 }
00994 ConstVolIterator volBegin( bool (* CheckCnt)( const Container& )) const
00995 {
00996 return( volBegin( NULL, CheckCnt ) );
00997 }
00998 ConstVolIterator volBegin( bool (* CheckVol)( const Volume& )=NULL,
00999 bool (* CheckCnt)( const Container& )=NULL) const
01000 {
01001 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
01002 (ConstVolInter( contPair( CheckCnt ), true )));
01003 return( ConstVolIterator( ConstVolPIterator(p, CheckVol )));
01004 }
01005 ConstVolIterator volEnd( bool (* CheckCnt)( const Container& )) const
01006 {
01007 return( volEnd( NULL, CheckCnt ) );
01008 }
01009 ConstVolIterator volEnd( bool (* CheckVol)( const Volume& )=NULL,
01010 bool (* CheckCnt)( const Container& )=NULL) const
01011 {
01012 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
01013 (ConstVolInter( contPair( CheckCnt ), true )));
01014 return( ConstVolIterator( ConstVolPIterator(p, CheckVol, true )));
01015 }
01016 template< class Pred > typename VolCondIPair<Pred>::type volCondPair( const Pred& p ) const
01017 {
01018 return( typename VolCondIPair<Pred>::type( volCondBegin( p ), volCondEnd( p ) ) );
01019 }
01020 template< class Pred > typename ConstVolumeI<Pred>::type volCondBegin( const Pred& p ) const
01021 {
01022 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
01023 (ConstVolInter( contPair(), true )));
01024 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p) ) );
01025 }
01026 template< class Pred > typename ConstVolumeI<Pred>::type volCondEnd( const Pred& p ) const
01027 {
01028 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
01029 (ConstVolInter( contPair(), true )));
01030 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p, true )) );
01031 }
01032
01033 protected:
01034
01035 VPair vPair( bool (* CheckCnt)( const Container& ))
01036 {
01037 return( VPair( vBegin( CheckCnt ), vEnd( CheckCnt ) ));
01038 }
01039 VPair vPair( bool (* CheckVol)( const Volume& )=NULL,
01040 bool (* CheckCnt)( const Container& )=NULL)
01041 {
01042 return( VPair( vBegin( CheckVol, CheckCnt ),
01043 vEnd( CheckVol, CheckCnt ) ));
01044 }
01045 VolIterator vBegin( bool (* CheckCnt)( const Container& ))
01046 {
01047 return( vBegin( NULL, CheckCnt ) );
01048 }
01049 VolIterator vBegin( bool (* CheckVol)( const Volume& )=NULL,
01050 bool (* CheckCnt)( const Container& )=NULL)
01051 {
01052 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
01053 (VolPart( cPair( CheckCnt ), true )));
01054 return( VolIterator( VolPIterator( p, CheckVol )));
01055 }
01056 VolIterator vEnd( bool (* CheckCnt)( const Container& ))
01057 {
01058 return( vEnd( NULL, CheckCnt ) );
01059 }
01060 VolIterator vEnd( bool (* CheckVol)( const Volume& )=NULL,
01061 bool (* CheckCnt)( const Container& )=NULL)
01062 {
01063 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
01064 (VolPart( cPair( CheckCnt ), true )));
01065 return( VolIterator( VolPIterator( p, CheckVol, true )));
01066 }
01067
01068
01069 protected:
01070
01071 typedef ListListIterator<Container::ConstPlainIterator, ConstDiskIterator> ConstPartInter;
01072 typedef CastIterator<ConstPartInter, Partition *> ConstPartInter2;
01073 template< class Pred >
01074 struct ConstPartitionPI { typedef ContainerIter<Pred, ConstPartInter2> type; };
01075 typedef CheckFnc<const Partition> CheckFncPartition;
01076 typedef CheckerIterator< CheckFncPartition, ConstPartitionPI<CheckFncPartition>::type,
01077 ConstPartInter2, Partition > ConstPartPIterator;
01078 public:
01079
01080 template< class Pred >
01081 struct ConstPartitionI
01082 { typedef ContainerDerIter<Pred, typename ConstPartitionPI<Pred>::type,
01083 const Partition> type; };
01084 template< class Pred >
01085 struct PartCondIPair
01086 { typedef MakeCondIterPair<Pred, typename ConstPartitionI<Pred>::type> type;};
01087 typedef DerefIterator<ConstPartPIterator, const Partition> ConstPartIterator;
01088 typedef IterPair<ConstPartIterator> ConstPartPair;
01089
01090
01091 ConstPartPair partPair( bool (* CheckCnt)( const Disk& )) const
01092 {
01093 return( ConstPartPair( partBegin( CheckCnt ), partEnd( CheckCnt ) ));
01094 }
01095 ConstPartPair partPair( bool (* CheckPart)( const Partition& )=NULL,
01096 bool (* CheckCnt)( const Disk& )=NULL) const
01097 {
01098 return( ConstPartPair( partBegin( CheckPart, CheckCnt ),
01099 partEnd( CheckPart, CheckCnt ) ));
01100 }
01101 ConstPartIterator partBegin( bool (* CheckDisk)( const Disk& )) const
01102 {
01103 return( partBegin( NULL, CheckDisk ) );
01104 }
01105 ConstPartIterator partBegin( bool (* CheckPart)( const Partition& )=NULL,
01106 bool (* CheckDisk)( const Disk& )=NULL) const
01107 {
01108 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
01109 (ConstPartInter(diskPair( CheckDisk ), true )));
01110 return( ConstPartIterator( ConstPartPIterator(p, CheckPart )));
01111 }
01112 ConstPartIterator partEnd( bool (* CheckDisk)( const Disk& )) const
01113 {
01114 return( partEnd( NULL, CheckDisk ) );
01115 }
01116 ConstPartIterator partEnd( bool (* CheckPart)( const Partition& )=NULL,
01117 bool (* CheckDisk)( const Disk& )=NULL) const
01118 {
01119 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
01120 (ConstPartInter(diskPair( CheckDisk ), true )));
01121 return( ConstPartIterator( ConstPartPIterator(p, CheckPart, true )));
01122 }
01123 template< class Pred > typename PartCondIPair<Pred>::type partCondPair( const Pred& p ) const
01124 {
01125 return( typename PartCondIPair<Pred>::type( partCondBegin( p ), partCondEnd( p ) ) );
01126 }
01127 template< class Pred > typename ConstPartitionI<Pred>::type partCondBegin( const Pred& p ) const
01128 {
01129 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
01130 (ConstPartInter( diskPair(), true )));
01131 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p) ) );
01132 }
01133 template< class Pred > typename ConstPartitionI<Pred>::type partCondEnd( const Pred& p ) const
01134 {
01135 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
01136 (ConstPartInter( diskPair(), true )));
01137 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p, true )) );
01138 }
01139
01140
01141 protected:
01142
01143 typedef ListListIterator<Container::ConstPlainIterator, ConstLvmVgIterator> ConstLvmLvInter;
01144 typedef CastIterator<ConstLvmLvInter, LvmLv *> ConstLvmLvInter2;
01145 template< class Pred >
01146 struct ConstLvmLvPI { typedef ContainerIter<Pred, ConstLvmLvInter2> type; };
01147 typedef CheckFnc<const LvmLv> CheckFncLvmLv;
01148 typedef CheckerIterator< CheckFncLvmLv, ConstLvmLvPI<CheckFncLvmLv>::type,
01149 ConstLvmLvInter2, LvmLv > ConstLvmLvPIterator;
01150 public:
01151
01152 template< class Pred >
01153 struct ConstLvmLvI
01154 { typedef ContainerDerIter<Pred, typename ConstLvmLvPI<Pred>::type,
01155 const LvmLv> type; };
01156 template< class Pred >
01157 struct LvmLvCondIPair
01158 { typedef MakeCondIterPair<Pred, typename ConstLvmLvI<Pred>::type> type;};
01159 typedef DerefIterator<ConstLvmLvPIterator, const LvmLv> ConstLvmLvIterator;
01160 typedef IterPair<ConstLvmLvIterator> ConstLvmLvPair;
01161
01162
01163 ConstLvmLvPair lvmLvPair( bool (* CheckLvmVg)( const LvmVg& )) const
01164 {
01165 return( ConstLvmLvPair( lvmLvBegin( CheckLvmVg ), lvmLvEnd( CheckLvmVg ) ));
01166 }
01167 ConstLvmLvPair lvmLvPair( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01168 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01169 {
01170 return( ConstLvmLvPair( lvmLvBegin( CheckLvmLv, CheckLvmVg ),
01171 lvmLvEnd( CheckLvmLv, CheckLvmVg ) ));
01172 }
01173 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmVg)( const LvmVg& )) const
01174 {
01175 return( lvmLvBegin( NULL, CheckLvmVg ) );
01176 }
01177 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01178 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01179 {
01180 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
01181 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
01182 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv )));
01183 }
01184 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmVg)( const LvmVg& )) const
01185 {
01186 return( lvmLvEnd( NULL, CheckLvmVg ) );
01187 }
01188 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01189 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01190 {
01191 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
01192 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
01193 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv, true )));
01194 }
01195 template< class Pred > typename LvmLvCondIPair<Pred>::type lvmLvCondPair( const Pred& p ) const
01196 {
01197 return( typename LvmLvCondIPair<Pred>::type( lvmLvCondBegin( p ), lvmLvCondEnd( p ) ) );
01198 }
01199 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondBegin( const Pred& p ) const
01200 {
01201 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
01202 (ConstLvmLvInter( lvmVgPair(), true )));
01203 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p) ) );
01204 }
01205 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondEnd( const Pred& p ) const
01206 {
01207 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
01208 (ConstLvmLvInter( lvmVgPair(), true )));
01209 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p, true )) );
01210 }
01211
01212
01213 protected:
01214
01215 typedef ListListIterator<Container::ConstPlainIterator, ConstEvmsCoIterator> ConstEvmsInter;
01216 typedef CastIterator<ConstEvmsInter, Evms *> ConstEvmsInter2;
01217 template< class Pred >
01218 struct ConstEvmsPI { typedef ContainerIter<Pred, ConstEvmsInter2> type; };
01219 typedef CheckFnc<const Evms> CheckFncEvms;
01220 typedef CheckerIterator< CheckFncEvms, ConstEvmsPI<CheckFncEvms>::type,
01221 ConstEvmsInter2, Evms > ConstEvmsPIterator;
01222 public:
01223
01224 template< class Pred >
01225 struct ConstEvmsI
01226 { typedef ContainerDerIter<Pred, typename ConstEvmsPI<Pred>::type,
01227 const Evms> type; };
01228 template< class Pred >
01229 struct EvmsCondIPair
01230 { typedef MakeCondIterPair<Pred, typename ConstEvmsI<Pred>::type> type;};
01231 typedef DerefIterator<ConstEvmsPIterator, const Evms> ConstEvmsIterator;
01232 typedef IterPair<ConstEvmsIterator> ConstEvmsPair;
01233
01234
01235 ConstEvmsPair evmsPair( bool (* CheckEvmsCo)( const EvmsCo& )) const
01236 {
01237 return( ConstEvmsPair( evmsBegin( CheckEvmsCo ), evmsEnd( CheckEvmsCo ) ));
01238 }
01239 ConstEvmsPair evmsPair( bool (* CheckEvms)( const Evms& )=NULL,
01240 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
01241 {
01242 return( ConstEvmsPair( evmsBegin( CheckEvms, CheckEvmsCo ),
01243 evmsEnd( CheckEvms, CheckEvmsCo ) ));
01244 }
01245 ConstEvmsIterator evmsBegin( bool (* CheckEvmsCo)( const EvmsCo& )) const
01246 {
01247 return( evmsBegin( NULL, CheckEvmsCo ) );
01248 }
01249 ConstEvmsIterator evmsBegin( bool (* CheckEvms)( const Evms& )=NULL,
01250 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
01251 {
01252 IterPair<ConstEvmsInter2> p( (ConstEvmsInter(evmsCoPair( CheckEvmsCo ))),
01253 (ConstEvmsInter(evmsCoPair( CheckEvmsCo ), true )));
01254 return( ConstEvmsIterator( ConstEvmsPIterator(p, CheckEvms )));
01255 }
01256 ConstEvmsIterator evmsEnd( bool (* CheckEvmsCo)( const EvmsCo& )) const
01257 {
01258 return( evmsEnd( NULL, CheckEvmsCo ) );
01259 }
01260 ConstEvmsIterator evmsEnd( bool (* CheckEvms)( const Evms& )=NULL,
01261 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
01262 {
01263 IterPair<ConstEvmsInter2> p( (ConstEvmsInter(evmsCoPair( CheckEvmsCo ))),
01264 (ConstEvmsInter(evmsCoPair( CheckEvmsCo ), true )));
01265 return( ConstEvmsIterator( ConstEvmsPIterator(p, CheckEvms, true )));
01266 }
01267 template< class Pred > typename EvmsCondIPair<Pred>::type evmsCondPair( const Pred& p ) const
01268 {
01269 return( typename EvmsCondIPair<Pred>::type( evmsCondBegin( p ), evmsCondEnd( p ) ) );
01270 }
01271 template< class Pred > typename ConstEvmsI<Pred>::type evmsCondBegin( const Pred& p ) const
01272 {
01273 IterPair<ConstEvmsInter2> pair( (ConstEvmsInter( evmsCoPair())),
01274 (ConstEvmsInter( evmsCoPair(), true )));
01275 return( typename ConstEvmsI<Pred>::type( typename ConstEvmsPI<Pred>::type(pair, p) ) );
01276 }
01277 template< class Pred > typename ConstEvmsI<Pred>::type evmsCondEnd( const Pred& p ) const
01278 {
01279 IterPair<ConstEvmsInter2> pair( (ConstEvmsInter( evmsCoPair())),
01280 (ConstEvmsInter( evmsCoPair(), true )));
01281 return( typename ConstEvmsI<Pred>::type( typename ConstEvmsPI<Pred>::type(pair, p, true )) );
01282 }
01283
01284
01285 protected:
01286
01287 typedef CastIterator<ConstVolInter, Md *> ConstMdInter;
01288 template< class Pred >
01289 struct ConstMdPI { typedef ContainerIter<Pred,
01290 ConstMdInter> type; };
01291 typedef CheckFnc<const Md> CheckFncMd;
01292 typedef CheckerIterator< CheckFncMd, ConstMdPI<CheckFncMd>::type,
01293 ConstMdInter, Md > ConstMdPIterator;
01294 public:
01295
01296 template< class Pred >
01297 struct ConstMdI
01298 { typedef ContainerDerIter<Pred, typename ConstMdPI<Pred>::type,
01299 const Md> type; };
01300 template< class Pred >
01301 struct MdCondIPair
01302 { typedef MakeCondIterPair<Pred, typename ConstMdI<Pred>::type> type;};
01303 typedef DerefIterator<ConstMdPIterator, const Md> ConstMdIterator;
01304 typedef IterPair<ConstMdIterator> ConstMdPair;
01305
01306
01307 ConstMdPair mdPair( bool (* CheckMd)( const Md& )=NULL ) const
01308 {
01309 return( ConstMdPair( mdBegin( CheckMd ), mdEnd( CheckMd ) ));
01310 }
01311 ConstMdIterator mdBegin( bool (* CheckMd)( const Md& )=NULL ) const
01312 {
01313 ConstVolInter b( contPair( isMd ) );
01314 ConstVolInter e( contPair( isMd ), true );
01315 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01316 return( ConstMdIterator( ConstMdPIterator(p, CheckMd )));
01317 }
01318 ConstMdIterator mdEnd( bool (* CheckMd)( const Md& )=NULL ) const
01319 {
01320 ConstVolInter b( contPair( isMd ) );
01321 ConstVolInter e( contPair( isMd ), true );
01322 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01323 return( ConstMdIterator( ConstMdPIterator(p, CheckMd, true )));
01324 }
01325 template< class Pred > typename MdCondIPair<Pred>::type mdCondPair( const Pred& p ) const
01326 {
01327 return( typename MdCondIPair<Pred>::type( mdCondBegin( p ), mdCondEnd( p ) ) );
01328 }
01329 template< class Pred > typename ConstMdI<Pred>::type mdCondBegin( const Pred& p ) const
01330 {
01331 ConstVolInter b( contPair( isMd ) );
01332 ConstVolInter e( contPair( isMd ), true );
01333 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01334 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p) ) );
01335 }
01336 template< class Pred > typename ConstMdI<Pred>::type mdCondEnd( const Pred& p ) const
01337 {
01338 ConstVolInter b( contPair( isMd ) );
01339 ConstVolInter e( contPair( isMd ), true );
01340 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01341 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p, true )) );
01342 }
01343
01344
01345 protected:
01346
01347 typedef CastIterator<ConstVolInter, Loop *> ConstLoopInter;
01348 template< class Pred >
01349 struct ConstLoopPI { typedef ContainerIter<Pred,
01350 ConstLoopInter> type; };
01351 typedef CheckFnc<const Loop> CheckFncLoop;
01352 typedef CheckerIterator< CheckFncLoop, ConstLoopPI<CheckFncLoop>::type,
01353 ConstLoopInter, Loop > ConstLoopPIterator;
01354 public:
01355
01356 template< class Pred >
01357 struct ConstLoopI
01358 { typedef ContainerDerIter<Pred, typename ConstLoopPI<Pred>::type,
01359 const Loop> type; };
01360 template< class Pred >
01361 struct LoopCondIPair
01362 { typedef MakeCondIterPair<Pred, typename ConstLoopI<Pred>::type> type;};
01363 typedef DerefIterator<ConstLoopPIterator, const Loop> ConstLoopIterator;
01364 typedef IterPair<ConstLoopIterator> ConstLoopPair;
01365
01366
01367 ConstLoopPair loopPair( bool (* CheckLoop)( const Loop& )=NULL ) const
01368 {
01369 return( ConstLoopPair( loopBegin( CheckLoop ), loopEnd( CheckLoop ) ));
01370 }
01371 ConstLoopIterator loopBegin( bool (* CheckLoop)( const Loop& )=NULL ) const
01372 {
01373 ConstVolInter b( contPair( isLoop ) );
01374 ConstVolInter e( contPair( isLoop ), true );
01375 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01376 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop )));
01377 }
01378 ConstLoopIterator loopEnd( bool (* CheckLoop)( const Loop& )=NULL ) const
01379 {
01380 ConstVolInter b( contPair( isLoop ) );
01381 ConstVolInter e( contPair( isLoop ), true );
01382 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01383 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop, true )));
01384 }
01385 template< class Pred > typename LoopCondIPair<Pred>::type loopCondPair( const Pred& p ) const
01386 {
01387 return( typename LoopCondIPair<Pred>::type( loopCondBegin( p ), loopCondEnd( p ) ) );
01388 }
01389 template< class Pred > typename ConstLoopI<Pred>::type loopCondBegin( const Pred& p ) const
01390 {
01391 ConstVolInter b( contPair( isLoop ) );
01392 ConstVolInter e( contPair( isLoop ), true );
01393 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01394 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p) ) );
01395 }
01396 template< class Pred > typename ConstLoopI<Pred>::type loopCondEnd( const Pred& p ) const
01397 {
01398 ConstVolInter b( contPair( isLoop ) );
01399 ConstVolInter e( contPair( isLoop ), true );
01400 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01401 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p, true )) );
01402 }
01403
01404
01405 protected:
01406
01407 typedef CastIterator<ConstVolInter, Dm *> ConstDmInter;
01408 template< class Pred >
01409 struct ConstDmPI { typedef ContainerIter<Pred,
01410 ConstDmInter> type; };
01411 typedef CheckFnc<const Dm> CheckFncDm;
01412 typedef CheckerIterator< CheckFncDm, ConstDmPI<CheckFncDm>::type,
01413 ConstDmInter, Dm > ConstDmPIterator;
01414 public:
01415
01416 template< class Pred >
01417 struct ConstDmI
01418 { typedef ContainerDerIter<Pred, typename ConstDmPI<Pred>::type,
01419 const Dm> type; };
01420 template< class Pred >
01421 struct DmCondIPair
01422 { typedef MakeCondIterPair<Pred, typename ConstDmI<Pred>::type> type;};
01423 typedef DerefIterator<ConstDmPIterator, const Dm> ConstDmIterator;
01424 typedef IterPair<ConstDmIterator> ConstDmPair;
01425
01426
01427 ConstDmPair dmPair( bool (* CheckDm)( const Dm& )=NULL ) const
01428 {
01429 return( ConstDmPair( dmBegin( CheckDm ), dmEnd( CheckDm ) ));
01430 }
01431 ConstDmIterator dmBegin( bool (* CheckDm)( const Dm& )=NULL ) const
01432 {
01433 ConstVolInter b( contPair( isDm ) );
01434 ConstVolInter e( contPair( isDm ), true );
01435 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01436 return( ConstDmIterator( ConstDmPIterator(p, CheckDm )));
01437 }
01438 ConstDmIterator dmEnd( bool (* CheckDm)( const Dm& )=NULL ) const
01439 {
01440 ConstVolInter b( contPair( isDm ) );
01441 ConstVolInter e( contPair( isDm ), true );
01442 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01443 return( ConstDmIterator( ConstDmPIterator(p, CheckDm, true )));
01444 }
01445 template< class Pred > typename DmCondIPair<Pred>::type dmCondPair( const Pred& p ) const
01446 {
01447 return( typename DmCondIPair<Pred>::type( dmCondBegin( p ), dmCondEnd( p ) ) );
01448 }
01449 template< class Pred > typename ConstDmI<Pred>::type dmCondBegin( const Pred& p ) const
01450 {
01451 ConstVolInter b( contPair( isDm ) );
01452 ConstVolInter e( contPair( isDm ), true );
01453 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01454 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p) ) );
01455 }
01456 template< class Pred > typename ConstDmI<Pred>::type dmCondEnd( const Pred& p ) const
01457 {
01458 ConstVolInter b( contPair( isDm ) );
01459 ConstVolInter e( contPair( isDm ), true );
01460 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01461 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p, true )) );
01462 }
01463
01464
01465 protected:
01466
01467 typedef ListListIterator<Container::ConstPlainIterator, ConstDmraidCoIterator> ConstDmraidInter;
01468 typedef CastIterator<ConstDmraidInter, Dmraid *> ConstDmraidInter2;
01469 template< class Pred >
01470 struct ConstDmraidPI { typedef ContainerIter<Pred, ConstDmraidInter2> type; };
01471 typedef CheckFnc<const Dmraid> CheckFncDmraid;
01472 typedef CheckerIterator< CheckFncDmraid, ConstDmraidPI<CheckFncDmraid>::type,
01473 ConstDmraidInter2, Dmraid > ConstDmraidPIterator;
01474 public:
01475
01476 template< class Pred >
01477 struct ConstDmraidI
01478 { typedef ContainerDerIter<Pred, typename ConstDmraidPI<Pred>::type,
01479 const Dmraid> type; };
01480 template< class Pred >
01481 struct DmraidCondIPair
01482 { typedef MakeCondIterPair<Pred, typename ConstDmraidI<Pred>::type> type;};
01483 typedef DerefIterator<ConstDmraidPIterator, const Dmraid> ConstDmraidIterator;
01484 typedef IterPair<ConstDmraidIterator> ConstDmraidPair;
01485
01486
01487 ConstDmraidPair dmrPair( bool (* CheckDmraidCo)( const DmraidCo& )) const
01488 {
01489 return( ConstDmraidPair( dmrBegin( CheckDmraidCo ), dmrEnd( CheckDmraidCo ) ));
01490 }
01491 ConstDmraidPair dmrPair( bool (* CheckDmraid)( const Dmraid& )=NULL,
01492 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01493 {
01494 return( ConstDmraidPair( dmrBegin( CheckDmraid, CheckDmraidCo ),
01495 dmrEnd( CheckDmraid, CheckDmraidCo ) ));
01496 }
01497 ConstDmraidIterator dmrBegin( bool (* CheckDmraidCo)( const DmraidCo& )) const
01498 {
01499 return( dmrBegin( NULL, CheckDmraidCo ) );
01500 }
01501 ConstDmraidIterator dmrBegin( bool (* CheckDmraid)( const Dmraid& )=NULL,
01502 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01503 {
01504 IterPair<ConstDmraidInter2> p( (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ))),
01505 (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ), true )));
01506 return( ConstDmraidIterator( ConstDmraidPIterator(p, CheckDmraid )));
01507 }
01508 ConstDmraidIterator dmrEnd( bool (* CheckDmraidCo)( const DmraidCo& )) const
01509 {
01510 return( dmrEnd( NULL, CheckDmraidCo ) );
01511 }
01512 ConstDmraidIterator dmrEnd( bool (* CheckDmraid)( const Dmraid& )=NULL,
01513 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01514 {
01515 IterPair<ConstDmraidInter2> p( (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ))),
01516 (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ), true )));
01517 return( ConstDmraidIterator( ConstDmraidPIterator(p, CheckDmraid, true )));
01518 }
01519 template< class Pred > typename DmraidCondIPair<Pred>::type dmrCondPair( const Pred& p ) const
01520 {
01521 return( typename DmraidCondIPair<Pred>::type( dmrCondBegin( p ), dmrCondEnd( p ) ) );
01522 }
01523 template< class Pred > typename ConstDmraidI<Pred>::type dmrCondBegin( const Pred& p ) const
01524 {
01525 IterPair<ConstDmraidInter2> pair( (ConstDmraidInter( dmraidCoPair())),
01526 (ConstDmraidInter( dmraidCoPair(), true )));
01527 return( typename ConstDmraidI<Pred>::type( typename ConstDmraidPI<Pred>::type(pair, p) ) );
01528 }
01529 template< class Pred > typename ConstDmraidI<Pred>::type dmrCondEnd( const Pred& p ) const
01530 {
01531 IterPair<ConstDmraidInter2> pair( (ConstDmraidInter( dmrCoPair())),
01532 (ConstDmraidInter( dmrCoPair(), true )));
01533 return( typename ConstDmraidI<Pred>::type( typename ConstDmraidPI<Pred>::type(pair, p, true )) );
01534 }
01535
01536 protected:
01537
01538 void initialize();
01539 void detectDisks( ProcPart& ppart );
01540 void autodetectDisks( ProcPart& ppart );
01541 void detectMultipath();
01542 void detectMds();
01543 void detectLoops( ProcPart& ppart );
01544 void detectLvmVgs();
01545 void detectEvms();
01546 void detectDmraid( ProcPart& ppart );
01547 void detectDm( ProcPart& ppart );
01548 void initDisk( DiskData& data, ProcPart& pp );
01549 void detectFsData( const VolIterator& begin, const VolIterator& end );
01550 void detectFsDataTestMode( const string& file,
01551 const VolIterator& begin,
01552 const VolIterator& end );
01553 int resizeVolume( const string& device, unsigned long long newSizeMb,
01554 bool ignore_fs );
01555 int resizePartition( const string& device, unsigned long sizeCyl,
01556 bool ignore_fs );
01557 static void detectArch();
01558 void addToList( Container* e )
01559 { pointerIntoSortedList<Container>( cont, e ); }
01560 DiskIterator findDisk( const string& disk );
01561 LvmVgIterator findLvmVg( const string& name );
01562 EvmsCoIterator findEvmsCo( const string& name );
01563 DmraidCoIterator findDmraidCo( const string& name );
01564 DmPartCoIterator findDmPartCo( const string& name );
01565 bool findVolume( const string& device, ContIterator& c,
01566 VolIterator& v );
01567 bool findVolume( const string& device, VolIterator& v,
01568 bool also_del=false );
01569 bool findContainer( const string& device, ContIterator& c );
01570
01571 bool haveMd( MdCo*& md );
01572 bool haveLoop( LoopCo*& loop );
01573 bool haveEvms();
01574 void handleEvmsRemoveDevice( const Disk* disk, const string& d,
01575 bool rename );
01576 void handleEvmsCreateDevice( const string& disk, const string& dev,
01577 bool extended=false );
01578
01579 int removeContainer( Container* val, bool call_del=true );
01580 void logVolumes( const string& Dir );
01581 int commitPair( CPair& p, bool (* fnc)( const Container& ) );
01582 void sortCommitLists( storage::CommitStage stage,
01583 std::list<Container*>& co,
01584 std::list<Volume*>& vl,
01585 std::list<storage::commitAction*>& todo );
01586 bool ignoreError( std::list<commitAction*>::iterator i,
01587 std::list<commitAction*>& al );
01588 void evmsActivateDevices();
01589 string backupStates() const;
01590 void detectObjects();
01591 void deleteClist( CCont& co );
01592 void deleteBackups();
01593 void setFreeInfo( const string& device, unsigned long long df_free,
01594 unsigned long long resize_free,
01595 unsigned long long used, bool win, bool resize_ok );
01596 bool getFreeInf( const string& device, unsigned long long& df_free,
01597 unsigned long long& resize_free,
01598 unsigned long long& used, bool& win, bool& resize_ok );
01599
01600
01601 bool readonly;
01602 bool testmode;
01603 bool inst_sys;
01604 bool cache;
01605 bool initialized;
01606 bool autodetect;
01607 bool recursiveRemove;
01608 bool zeroNewPartitions;
01609 MountByType defaultMountBy;
01610 bool detectMounted;
01611 bool root_mounted;
01612 string testdir;
01613 string tempdir;
01614 string rootprefix;
01615 string logdir;
01616 static string proc_arch;
01617 static string sysfs_dir;
01618 static bool is_ppc_mac;
01619 static bool is_ppc_pegasos;
01620 CCont cont;
01621 EtcFstab *fstab;
01622
01623 storage::CallbackProgressBar progress_bar_cb;
01624 storage::CallbackShowInstallInfo install_info_cb;
01625 storage::CallbackInfoPopup info_popup_cb;
01626 storage::CallbackYesNoPopup yesno_popup_cb;
01627 static storage::CallbackProgressBar progress_bar_cb_ycp;
01628 static storage::CallbackShowInstallInfo install_info_cb_ycp;
01629 static storage::CallbackInfoPopup info_popup_cb_ycp;
01630 static storage::CallbackYesNoPopup yesno_popup_cb_ycp;
01631 friend std::ostream& operator<< (std::ostream& s, Storage &v );
01632
01633 unsigned max_log_num;
01634 string lastAction;
01635 string extendedError;
01636 std::map<string,CCont> backups;
01637 std::map<string,FreeInfo> freeInfo;
01638 std::list<std::pair<string,string> > infoPopupTxts;
01639 };
01640
01641 inline std::ostream& operator<< (std::ostream& s, commitAction &a )
01642 {
01643 s << "stage:" << a.stage
01644 << " type:" << a.type
01645 << " cont:" << a.container
01646 << " dest:" << a.destructive;
01647 if( a.container && a.co() )
01648 s << " name:" << a.co()->name();
01649 else if( a.vol() )
01650 s << " name:" << a.vol()->name();
01651 if( !a.descr.empty() )
01652 s << " desc:" << a.descr;
01653 return( s );
01654 };
01655
01656 }
01657
01658 #endif